Added support for osgText::Style into osgText::Text3D.

Refactored Text3D implementation to use new GlyphGeometry class.
Implemented GlyphGeometry backend and cleaned up Glyph3D interface.
This commit is contained in:
Robert Osfield
2010-09-27 16:18:20 +00:00
parent 759749eb0c
commit f8b44c3b33
8 changed files with 195 additions and 130 deletions

View File

@@ -44,6 +44,9 @@ public:
Glyph(Font* font, unsigned int glyphCode);
Font* getFont() { return _font; }
const Font* getFont() const { return _font; }
unsigned int getGlyphCode() const { return _glyphCode; }
void setHorizontalBearing(const osg::Vec2& bearing);
@@ -104,7 +107,7 @@ class OSGTEXT_EXPORT GlyphGeometry : public osg::Referenced
GlyphGeometry();
void setup(const Glyph* glyph, const Style* style);
void setup(const Glyph3D* glyph, const Style* style);
bool match(const Style* style) const;
@@ -128,6 +131,9 @@ class OSGTEXT_EXPORT GlyphGeometry : public osg::Referenced
/** Get et the PrimitiveSetList for the back face. */
osg::Geometry::PrimitiveSetList& getBackPrimitiveSetList() { return _backPrimitiveSetList; }
/** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/
virtual void setThreadSafeRefUnref(bool threadSafe);
protected:
osg::ref_ptr<Style> _style;
@@ -148,6 +154,9 @@ public:
Glyph3D(Font* font, unsigned int glyphCode);
Font* getFont() { return _font; }
const Font* getFont() const { return _font; }
unsigned int getGlyphCode() const { return _glyphCode; }
void setHorizontalBearing(const osg::Vec2& bearing) { _horizontalBearing=bearing; }
@@ -172,29 +181,11 @@ public:
void setRawVertexArray(osg::Vec3Array* vertices) { _rawVertexArray = vertices; }
osg::Vec3Array* getRawVertexArray() { return _rawVertexArray.get(); }
const osg::Vec3Array* getRawVertexArray() const { return _rawVertexArray.get(); }
/** Get the PrimitiveSetList for the raw face which hasn't been tessellated. */
osg::Geometry::PrimitiveSetList & getRawFacePrimitiveSetList() { return _rawFacePrimitiveSetList; }
/** deprecated feature.*/
void computeText3DGeometryData();
/** Get the PrimitiveSetList for the front face. */
osg::Geometry::PrimitiveSetList & getFrontPrimitiveSetList() { return _frontPrimitiveSetList; }
/** Get the PrimitiveSetList for the wall face. */
osg::Geometry::PrimitiveSetList & getWallPrimitiveSetList() { return _wallPrimitiveSetList; }
/** Get et the PrimitiveSetList for the back face. */
osg::Geometry::PrimitiveSetList & getBackPrimitiveSetList() { return _backPrimitiveSetList; }
/** Set the VertexArray of the glyph. */
void setVertexArray(osg::Vec3Array * va) { _vertexArray = va; }
/** Get the VertexArray of the glyph. */
osg::Vec3Array * getVertexArray() { return _vertexArray.get(); }
/** Set the VertexArray of the glyph. */
void setNormalArray(osg::Vec3Array * na) { _normalArray = na; }
/** Get the NormalArray for the wall face. */
osg::Vec3Array * getNormalArray() { return _normalArray.get(); }
const osg::Geometry::PrimitiveSetList & getRawFacePrimitiveSetList() const { return _rawFacePrimitiveSetList; }
float getHorizontalWidth() const { return (-_horizontalBearing.x() + _horizontalAdvance); }
@@ -208,7 +199,7 @@ public:
void setHeight(float height) { _height = height; }
float getHeight() const { return _height; }
GlyphGeometry* getGlyphGeometry(Style* style);
GlyphGeometry* getGlyphGeometry(const Style* style);
protected:
@@ -229,15 +220,6 @@ protected:
float _width;
float _height;
osg::ref_ptr<osg::Vec3Array> _vertexArray;
osg::ref_ptr<osg::Vec3Array> _normalArray;
osg::Geometry::PrimitiveSetList _frontPrimitiveSetList;
osg::Geometry::PrimitiveSetList _wallPrimitiveSetList;
osg::Geometry::PrimitiveSetList _backPrimitiveSetList;
osg::ref_ptr<osg::Vec3Array> _rawVertexArray;
osg::Geometry::PrimitiveSetList _rawFacePrimitiveSetList;

View File

@@ -17,6 +17,7 @@
#include <osgText/TextBase>
#include <osgText/Font>
#include <osgText/Style>
namespace osgText {
@@ -43,10 +44,19 @@ public:
META_Object(osgText,Text3D)
/** Set the text style.*/
void setStyle(Style* style) { _style = style; }
/** Get the text style.*/
Style* getStyle() { return _style.get(); }
/** Get the const text style.*/
const Style* getStyle() const { return _style.get(); }
/** Get the Charactere Depth of text. */
float getCharacterDepth() const { return _characterDepth; }
float getCharacterDepth() const;
/** Set the Charactere Depth of text. */
void setCharacterDepth(float characterDepth) { _characterDepth = characterDepth; computeGlyphRepresentation(); }
void setCharacterDepth(float characterDepth);
/** Get the render mode used to render the text. */
RenderMode getRenderMode() const { return _renderMode; }
@@ -139,10 +149,11 @@ protected:
// ** glyph and other information to render the glyph
struct GlyphRenderInfo
{
GlyphRenderInfo(Glyph3D * glyph, osg::Vec3 & pos) :
_glyph(glyph), _position(pos) {}
GlyphRenderInfo(GlyphGeometry* glyphGeometry, osg::Vec3 & pos):
_glyphGeometry(glyphGeometry),
_position(pos) {}
osg::ref_ptr<Glyph3D> _glyph;
osg::ref_ptr<GlyphGeometry> _glyphGeometry;
osg::Vec3 _position;
};
@@ -151,7 +162,8 @@ protected:
TextRenderInfo _textRenderInfo;
osg::ref_ptr<Font> _font;
osg::ref_ptr<Font> _font;
osg::ref_ptr<Style> _style;
float _characterDepth;