From f8b44c3b3313c07f0c619b8421f487117364694c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 27 Sep 2010 16:18:20 +0000 Subject: [PATCH] Added support for osgText::Style into osgText::Text3D. Refactored Text3D implementation to use new GlyphGeometry class. Implemented GlyphGeometry backend and cleaned up Glyph3D interface. --- examples/osgtext3D/osgtext3D_orig.cpp | 6 + include/osgText/Glyph | 44 +++----- include/osgText/Text3D | 24 +++- src/osgPlugins/freetype/FreeTypeFont.cpp | 3 - src/osgText/Glyph.cpp | 135 +++++++++++++++++------ src/osgText/GlyphGeometry.cpp | 41 +++---- src/osgText/GlyphGeometry.h | 4 +- src/osgText/Text3D.cpp | 68 ++++++------ 8 files changed, 195 insertions(+), 130 deletions(-) diff --git a/examples/osgtext3D/osgtext3D_orig.cpp b/examples/osgtext3D/osgtext3D_orig.cpp index b9c5dbb50..7ff252775 100644 --- a/examples/osgtext3D/osgtext3D_orig.cpp +++ b/examples/osgtext3D/osgtext3D_orig.cpp @@ -82,8 +82,14 @@ osg::Group* create3DText(const osg::Vec3& center,float radius) text3->setText("XZ_PLANE"); geode->addDrawable(text3); + osg::ref_ptr style = new osgText::Style; + osg::ref_ptr bevel = new osgText::Bevel; + bevel->roundedBevel2(0.25); + style->setBevel(bevel.get()); + osgText::Text3D* text7 = new osgText::Text3D; text7->setFont("fonts/times.ttf"); + text7->setStyle(style.get()); text7->setCharacterSize(characterSize); text7->setCharacterDepth(characterSize*0.2f); text7->setPosition(center - osg::Vec3(0.0, 0.0, 0.6)); diff --git a/include/osgText/Glyph b/include/osgText/Glyph index 46647474e..6bee19e7c 100644 --- a/include/osgText/Glyph +++ b/include/osgText/Glyph @@ -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