Added support for automatic scaling of text to screen coords. Optimized
the text implementation to provide better speed, especially by using the alignement to screen option. Deprecated the Text::setFontSize(,) method, which is now being replaced by setFontResolution(,) Fixed typos in Texture*.cpp. Removed old deprecated methods from osg headers.
This commit is contained in:
@@ -192,24 +192,6 @@ class SG_EXPORT Drawable : public Object
|
||||
/** Get the non const UpdateCallback.*/
|
||||
UpdateCallback* getUpdateCallback() { return _updateCallback.get(); }
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
struct AppCallback : public UpdateCallback
|
||||
{
|
||||
/** do customized app code.*/
|
||||
virtual void app(osg::NodeVisitor *visitor, osg::Drawable* drawable) = 0;
|
||||
|
||||
virtual void update(osg::NodeVisitor *visitor, osg::Drawable* drawable) { app(visitor,drawable); }
|
||||
};
|
||||
|
||||
/** deprecated.*/
|
||||
void setAppCallback(AppCallback* ac) { setUpdateCallback(ac); }
|
||||
|
||||
/** deprecated.*/
|
||||
AppCallback* getAppCallback() { return getUpdateCallback(); }
|
||||
|
||||
/** deprecated.*/
|
||||
const AppCallback* getAppCallback() const { return getUpdateCallback(); }
|
||||
#endif
|
||||
|
||||
struct CullCallback : public virtual osg::Referenced
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// define used to include in API which is being fazed out
|
||||
// if you can compile your apps with this turned off you are
|
||||
// well placed for compatablity with future versions.
|
||||
//#define USE_DEPRECATED_API
|
||||
#define USE_DEPRECATED_API
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4244 )
|
||||
@@ -56,13 +56,4 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
|
||||
#define osgNew new
|
||||
#define osgDelete delete
|
||||
#define osgFree free
|
||||
#define osgMalloc malloc
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -135,17 +135,6 @@ class SG_EXPORT Node : public Object
|
||||
/** Get const update node callback, called during update traversal. */
|
||||
inline const NodeCallback* getUpdateCallback() const { return _updateCallback.get(); }
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
/** deprecated. */
|
||||
void setAppCallback(NodeCallback* nc) { setUpdateCallback(nc); }
|
||||
|
||||
/** deprecated. */
|
||||
inline NodeCallback* getAppCallback() { return getUpdateCallback(); }
|
||||
|
||||
/** deprecated. */
|
||||
inline const NodeCallback* getAppCallback() const { return getUpdateCallback(); }
|
||||
#endif
|
||||
|
||||
/** Get the number of Children of this node which require App traversal,
|
||||
* since they have an AppCallback attached to them or their children.*/
|
||||
inline unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; }
|
||||
|
||||
@@ -89,10 +89,10 @@ class SG_EXPORT Texture2D : public Texture
|
||||
|
||||
/** Set the number of mip map levels the the texture has been created with,
|
||||
should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
|
||||
void setNumMipmapLevels(unsigned int num) const { _numMimpmapLevels=num; }
|
||||
void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
|
||||
|
||||
/** Get the number of mip map levels the the texture has been created with.*/
|
||||
unsigned int getNumMipmapLevels() const { return _numMimpmapLevels; }
|
||||
unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
|
||||
|
||||
|
||||
/** Copy pixels into a 2D texture image.As per glCopyTexImage2D.
|
||||
@@ -132,7 +132,7 @@ class SG_EXPORT Texture2D : public Texture
|
||||
mutable GLsizei _textureWidth, _textureHeight;
|
||||
|
||||
// number of mip map levels the the texture has been created with,
|
||||
mutable GLsizei _numMimpmapLevels;
|
||||
mutable GLsizei _numMipmapLevels;
|
||||
|
||||
ref_ptr<SubloadCallback> _subloadCallback;
|
||||
|
||||
|
||||
@@ -99,10 +99,10 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
|
||||
/** Set the number of mip map levels the the texture has been created with,
|
||||
should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
|
||||
void setNumMipmapLevels(unsigned int num) const { _numMimpmapLevels=num; }
|
||||
void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
|
||||
|
||||
/** Get the number of mip map levels the the texture has been created with.*/
|
||||
unsigned int getNumMipmapLevels() const { return _numMimpmapLevels; }
|
||||
unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
|
||||
|
||||
/** On first apply (unless already compiled), create the minmapped
|
||||
* texture and bind it, subsequent apply will simple bind to texture.*/
|
||||
@@ -162,7 +162,7 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
mutable GLsizei _textureWidth, _textureHeight;
|
||||
|
||||
// number of mip map levels the the texture has been created with,
|
||||
mutable GLsizei _numMimpmapLevels;
|
||||
mutable GLsizei _numMipmapLevels;
|
||||
|
||||
ref_ptr<SubloadCallback> _subloadCallback;
|
||||
|
||||
|
||||
@@ -48,11 +48,20 @@ public:
|
||||
/** Get the font. Return 0 if default is being used.*/
|
||||
const Font* getFont() const { return _font.get(); }
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
|
||||
/* deprecated */
|
||||
void setFontSize(unsigned int width, unsigned int height)
|
||||
{
|
||||
setFontResolution(width,height);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Set the Font reference width and height resolution in texels.
|
||||
* Note, the size may not be supported by current font,
|
||||
* the closest supported font size will be selected.*/
|
||||
void setFontSize(unsigned int width, unsigned int height);
|
||||
|
||||
void setFontResolution(unsigned int width, unsigned int height);
|
||||
|
||||
unsigned int getFontWidth() const { return _fontWidth; }
|
||||
unsigned int getFontHeight() const { return _fontWidth; }
|
||||
|
||||
@@ -142,7 +151,6 @@ public:
|
||||
};
|
||||
|
||||
void setAlignment(AlignmentType alignment);
|
||||
|
||||
AlignmentType getAlignment() const { return _alignment; }
|
||||
|
||||
|
||||
@@ -156,13 +164,22 @@ public:
|
||||
|
||||
void setAxisAlignment(AxisAlignment axis);
|
||||
|
||||
AxisAlignment getAxisAlignment() const { return _axisAlignment; }
|
||||
|
||||
|
||||
void setRotation(const osg::Quat& quat);
|
||||
|
||||
const osg::Quat& getRotation() const { return _rotation; }
|
||||
|
||||
void setAutoUpdateEyeMovementTolerance(float tolerance) { _autoUpdateEyeMovementTolerance = tolerance; }
|
||||
float getAutoUpdateEyeMovementTolerance() const { return _autoUpdateEyeMovementTolerance; }
|
||||
|
||||
void setAutoRotateToScreen(bool autoRotateToScreen);
|
||||
bool getAutoRotateToScreen() const { return _autoRotateToScreen; }
|
||||
|
||||
void setAutoScaleToScreen(bool autoScaleToScreen);
|
||||
bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
|
||||
|
||||
void setScale(float scale);
|
||||
float getScale() const { return _scale; }
|
||||
|
||||
|
||||
|
||||
enum Layout
|
||||
{
|
||||
@@ -215,6 +232,40 @@ public:
|
||||
// make Font a friend to allow it set the _font to 0 if the font is
|
||||
// forcefully unloaded.
|
||||
friend class Font;
|
||||
public:
|
||||
|
||||
// internal structures, variable and methods used for rendering of characters.
|
||||
struct OSGTEXT_EXPORT GlyphQuads
|
||||
{
|
||||
typedef std::vector<osg::Vec2> Coords2;
|
||||
typedef std::vector<osg::Vec3> Coords3;
|
||||
typedef std::vector<osg::Vec2> TexCoords;
|
||||
|
||||
Coords2 _coords;
|
||||
Coords3 _transformedCoords;
|
||||
TexCoords _texcoords;
|
||||
|
||||
Coords2& getCoords() { return _coords; }
|
||||
const Coords2& getCoords() const { return _coords; }
|
||||
|
||||
Coords3& getTransformedCoords() { return _transformedCoords; }
|
||||
const Coords3& getTransformedCoords() const { return _transformedCoords; }
|
||||
|
||||
TexCoords& getTexCoords() { return _texcoords; }
|
||||
const TexCoords& getTexCoords() const { return _texcoords; }
|
||||
};
|
||||
|
||||
typedef std::map<osg::ref_ptr<osg::StateSet>,GlyphQuads> TextureGlyphQuadMap;
|
||||
|
||||
/** Direct Access to GlyphQuads */
|
||||
const GlyphQuads* getGlyphQuad(unsigned int index) const
|
||||
{
|
||||
if (index>=_textureGlyphQuadMap.size()) return NULL;
|
||||
|
||||
TextureGlyphQuadMap::const_iterator itGlyph = _textureGlyphQuadMap.begin();
|
||||
while((index--) && (itGlyph!=_textureGlyphQuadMap.end())) itGlyph++;
|
||||
return &itGlyph->second;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -238,44 +289,15 @@ protected:
|
||||
String _text;
|
||||
osg::Vec3 _position;
|
||||
AlignmentType _alignment;
|
||||
AxisAlignment _axisAlignment;
|
||||
float _scale;
|
||||
osg::Quat _rotation;
|
||||
float _autoUpdateEyeMovementTolerance;
|
||||
bool _autoRotateToScreen;
|
||||
bool _autoScaleToScreen;
|
||||
Layout _layout;
|
||||
osg::Vec4 _color;
|
||||
unsigned int _drawMode;
|
||||
|
||||
public:
|
||||
|
||||
// internal structures, variable and methods used for rendering of characters.
|
||||
struct OSGTEXT_EXPORT GlyphQuads
|
||||
{
|
||||
typedef std::vector<osg::Vec2> Coords;
|
||||
typedef std::vector<osg::Vec2> TexCoords;
|
||||
|
||||
Coords _coords;
|
||||
TexCoords _texcoords;
|
||||
|
||||
Coords& getCoords() { return _coords; }
|
||||
const Coords& getCoords() const { return _coords; }
|
||||
|
||||
TexCoords& getTexCoords() { return _texcoords; }
|
||||
const TexCoords& getTexCoords() const { return _texcoords; }
|
||||
};
|
||||
|
||||
typedef std::map<osg::ref_ptr<osg::StateSet>,GlyphQuads> TextureGlyphQuadMap;
|
||||
|
||||
/** Direct Access to GlyphQuads */
|
||||
const GlyphQuads* getGlyphQuad(unsigned int index) const
|
||||
{
|
||||
if (index>=_textureGlyphQuadMap.size()) return NULL;
|
||||
|
||||
TextureGlyphQuadMap::const_iterator itGlyph = _textureGlyphQuadMap.begin();
|
||||
while((index--) && (itGlyph!=_textureGlyphQuadMap.end())) itGlyph++;
|
||||
return &itGlyph->second;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// iternal map used for rendering. Set up by the computeGlyphRepresentation() method.
|
||||
TextureGlyphQuadMap _textureGlyphQuadMap;
|
||||
|
||||
@@ -284,7 +306,10 @@ protected:
|
||||
// internal caches of the positioning of the text.
|
||||
osg::Matrix _matrix;
|
||||
osg::Vec3 _offset;
|
||||
osg::Vec3 _normal;
|
||||
mutable osg::BoundingBox _textBB;
|
||||
|
||||
void setUpAutoCallback();
|
||||
|
||||
void computePositions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user