1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
15#define OSGTEXT_TEXT3D 1
18#include <osgText/TextBase>
19#include <osgText/Style>
24class OSGTEXT_EXPORT Text3D : public osgText::TextBase
36 Text3D(const Text3D& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
38 META_Object(osgText,Text3D)
40 /** Get the Charactere Depth of text. */
41 float getCharacterDepth() const;
43 /** Set the Charactere Depth of text. */
44 void setCharacterDepth(float characterDepth);
46 /** Deprecated, value is now ignored. */
47 RenderMode getRenderMode() const { return _renderMode; }
48 /** Deprecated, value is now ignored. */
49 void setRenderMode(RenderMode renderMode) { _renderMode = renderMode; }
52 /** Get the wall StateSet */
53 osg::StateSet* getWallStateSet() { return _wallStateSet.get(); }
54 /** Get the wall StateSet */
55 const osg::StateSet* getWallStateSet() const { return _wallStateSet.get(); }
56 /** Get or create the wall StateSet */
57 osg::StateSet* getOrCreateWallStateSet()
59 if (_wallStateSet.valid() == false) _wallStateSet = new osg::StateSet;
60 return _wallStateSet.get();
62 /** Set the wall StateSet */
63 void setWallStateSet(osg::StateSet* wallStateSet) { _wallStateSet = wallStateSet; }
65 /** Get the back StateSet */
66 osg::StateSet* getBackStateSet() { return _backStateSet.get(); }
67 /** Get the back StateSet */
68 osg::StateSet* getBackStateSet() const { return _backStateSet.get(); }
69 /** Get or create the back StateSet */
70 osg::StateSet* getOrCreateBackStateSet() { if (_backStateSet.valid() == false) _backStateSet = new osg::StateSet; return _backStateSet.get(); }
71 /** Set the back StateSet */
72 void setBackStateSet(osg::StateSet* backStateSet) { _backStateSet = backStateSet; }
77 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
79 /** return false, osgText::Text does not support accept(AttributeFunctor&).*/
80 virtual bool supports(const osg::Drawable::AttributeFunctor&) const { return false; }
82 /** return true, osgText::Text does support accept(ConstAttributeFunctor&).*/
83 virtual bool supports(const osg::Drawable::ConstAttributeFunctor&) const { return false; }
85 /** accept an ConstAttributeFunctor and call its methods to tell it about the internal attributes that this Drawable has.*/
86 virtual void accept(osg::Drawable::ConstAttributeFunctor& af) const;
88 /** return true, osgText::Text does support accept(PrimitiveFunctor&) .*/
89 virtual bool supports(const osg::PrimitiveFunctor&) const { return false; }
91 /** accept a PrimtiveFunctor and call its methods to tell it about the internal primtives that this Drawable has.*/
92 virtual void accept(osg::PrimitiveFunctor& pf) const;
94 /** Resize any per context GLObject buffers to specified size. */
95 virtual void resizeGLObjectBuffers(unsigned int maxSize);
97 /** If State is non-zero, this function releases OpenGL objects for
98 * the specified graphics context. Otherwise, releases OpenGL objexts
99 * for all graphics contexts. */
100 virtual void releaseGLObjects(osg::State* state=0) const;
102 // make Font a friend to allow it set the _font to 0 if the font is
103 // forcefully unloaded.
106 virtual osg::BoundingBox computeBoundingBox() const;
113 String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
115 void computeGlyphRepresentation();
117 void copyAndOffsetPrimitiveSets(osg::Geometry::PrimitiveSetList& dest_PrimitiveSetList, osg::Geometry::PrimitiveSetList& src_PrimitiveSetList, unsigned int offset);
119 osg::Geometry::PrimitiveSetList _frontPrimitiveSetList;
120 osg::Geometry::PrimitiveSetList _wallPrimitiveSetList;
121 osg::Geometry::PrimitiveSetList _backPrimitiveSetList;
123 // ** glyph and other information to render the glyph
124 struct GlyphRenderInfo
126 GlyphRenderInfo(GlyphGeometry* glyphGeometry, osg::Vec3 & pos):
127 _glyphGeometry(glyphGeometry),
130 osg::ref_ptr<GlyphGeometry> _glyphGeometry;
134 typedef std::vector<GlyphRenderInfo> LineRenderInfo;
135 typedef std::vector<LineRenderInfo> TextRenderInfo;
137 TextRenderInfo _textRenderInfo;
139 // deprecated value no longer used.
140 RenderMode _renderMode;
142 osg::ref_ptr<osg::StateSet> _wallStateSet;
143 osg::ref_ptr<osg::StateSet> _backStateSet;