Added support for multibuffering of tex coordinates.

This commit is contained in:
Robert Osfield
2003-05-06 13:13:31 +00:00
parent 6c60fa233e
commit 06054d9520
8 changed files with 268 additions and 159 deletions

View File

@@ -54,6 +54,12 @@ class SG_EXPORT Quat
makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
}
inline bool operator == (const Quat& rhs) const { return _fv==rhs._fv; }
inline bool operator != (const Quat& rhs) const { return _fv!=rhs._fv; }
inline bool operator < (const Quat& rhs) const { return _fv<rhs._fv; }
/* ----------------------------------
Methods to access data members
---------------------------------- */

View File

@@ -53,16 +53,19 @@ class buffered_value
return _array[pos];
}
/* // do we implement the const version???
inline T operator[] (unsigned int pos) const
{
return 0;
// automatically resize array.
if (_array.size()<=pos)
_array.resize(pos+1,0);
return _array[pos];
}
*/
protected:
std::vector<T> _array;
mutable std::vector<T> _array;
};
template<class T>
@@ -96,16 +99,20 @@ class buffered_object
return _array[pos];
}
/* // do we implement the const version???
inline T operator[] (unsigned int pos) const
inline const T& operator[] (unsigned int pos) const
{
return 0;
// automatically resize array.
if (_array.size()<=pos)
_array.resize(pos+1);
return _array[pos];
}
*/
protected:
std::vector<T> _array;
mutable std::vector<T> _array;
};
}

View File

@@ -29,18 +29,6 @@ class OSGTEXT_EXPORT String : public osg::Referenced, public std::vector<unsigne
{
public:
String() {}
String(const String& str);
virtual ~String() {} // public temporily while osgText is still in flux.
String& operator = (const String& str);
void set(const std::string& str);
/** Set the text using a wchar_t string,
* which is converted to an internal TextString.*/
void set(const wchar_t* text);
/**
* Types of string encodings supported
*/
@@ -58,6 +46,23 @@ public:
ENCODING_SIGNATURE /// detect encoding from signature
};
String() {}
String(const String& str);
String(const std::string& str) { set(str); }
String(const wchar_t* text) { set(text); }
String(const std::string& text,Encoding encoding) { set(text,encoding); }
virtual ~String() {} // public temporily while osgText is still in flux.
String& operator = (const String& str);
void set(const std::string& str);
/** Set the text using a wchar_t string,
* which is converted to an internal TextString.*/
void set(const wchar_t* text);
/** Set the text using a Unicode encoded std::string, which is converted to an internal TextString.
* The encoding parameter specificies which Unicode encodeding is used in the std::string. */
void set(const std::string& text,Encoding encoding);

View File

@@ -165,10 +165,14 @@ public:
void setAxisAlignment(AxisAlignment axis);
void setRotation(const osg::Quat& quat);
const osg::Quat& getRotation() const { return _rotation; }
void setRotation(unsigned int contextID, const osg::Quat& quat);
const osg::Quat& getRotation(unsigned int contextID=0) const { return _rotation[contextID]; }
void setScale(float scale);
float getScale() const { return _scale; }
void setScale(unsigned int contextID, float scale);
float getScale(unsigned int contextID=0) const { return _scale[contextID]; }
void setScaleAndRotation(unsigned int contextID, float scale,const osg::Quat& quat);
void setAutoUpdateEyeMovementTolerance(float tolerance) { _autoUpdateEyeMovementTolerance = tolerance; }
float getAutoUpdateEyeMovementTolerance() const { return _autoUpdateEyeMovementTolerance; }
@@ -176,8 +180,8 @@ public:
void setAutoRotateToScreen(bool autoRotateToScreen);
bool getAutoRotateToScreen() const { return _autoRotateToScreen; }
void setAutoScaleToScreen(bool autoScaleToScreen);
bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
void setAutoScaleToLimitScreenSizeToFontResolution(bool autoScaleToScreen);
bool getAutoScaleToLimitScreenSizeToFontResolution() const { return _autoScaleToLimitScreenSizeToFontResolution; }
@@ -244,10 +248,10 @@ public:
typedef std::vector<osg::Vec3> Coords3;
typedef std::vector<osg::Vec2> TexCoords;
Glyphs _glyphs;
Coords2 _coords;
Coords3 _transformedCoords;
TexCoords _texcoords;
Glyphs _glyphs;
Coords2 _coords;
osg::buffered_object<Coords3> _transformedCoords;
TexCoords _texcoords;
Glyphs getGlyphs() { return _glyphs; }
const Glyphs getGlyphs() const { return _glyphs; }
@@ -256,8 +260,8 @@ public:
Coords2& getCoords() { return _coords; }
const Coords2& getCoords() const { return _coords; }
Coords3& getTransformedCoords() { return _transformedCoords; }
const Coords3& getTransformedCoords() const { return _transformedCoords; }
Coords3& getTransformedCoords(unsigned int contexID) { return _transformedCoords[contexID]; }
const Coords3& getTransformedCoords(unsigned int contexID) const { return _transformedCoords[contexID]; }
TexCoords& getTexCoords() { return _texcoords; }
const TexCoords& getTexCoords() const { return _texcoords; }
@@ -286,40 +290,40 @@ protected:
// members which have public access.
osg::ref_ptr<Font> _font;
unsigned int _fontWidth;
unsigned int _fontHeight;
float _characterHeight;
float _characterAspectRatio;
float _maximumWidth;
float _maximumHeight;
osg::ref_ptr<Font> _font;
unsigned int _fontWidth;
unsigned int _fontHeight;
float _characterHeight;
float _characterAspectRatio;
float _maximumWidth;
float _maximumHeight;
String _text;
osg::Vec3 _position;
AlignmentType _alignment;
osg::Quat _rotation;
float _scale;
float _autoUpdateEyeMovementTolerance;
bool _autoRotateToScreen;
bool _autoScaleToScreen;
Layout _layout;
osg::Vec4 _color;
unsigned int _drawMode;
String _text;
osg::Vec3 _position;
AlignmentType _alignment;
mutable osg::buffered_object<osg::Quat> _rotation;
mutable osg::buffered_value<float> _scale;
float _autoUpdateEyeMovementTolerance;
bool _autoRotateToScreen;
bool _autoScaleToLimitScreenSizeToFontResolution;
Layout _layout;
osg::Vec4 _color;
unsigned int _drawMode;
// iternal map used for rendering. Set up by the computeGlyphRepresentation() method.
TextureGlyphQuadMap _textureGlyphQuadMap;
TextureGlyphQuadMap _textureGlyphQuadMap;
void computeGlyphRepresentation();
// internal caches of the positioning of the text.
osg::Matrix _matrix;
osg::Vec3 _offset;
osg::Vec3 _normal;
mutable osg::BoundingBox _textBB;
mutable osg::buffered_object<osg::Matrix> _matrix;
osg::Vec3 _offset;
osg::Vec3 _normal;
mutable osg::BoundingBox _textBB;
void setUpAutoCallback();
void computePositions();
void computePositions(unsigned int contextID);
};