openscenegraph
Text3D
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14#ifndef OSGTEXT_TEXT3D
15#define OSGTEXT_TEXT3D 1
16
17
18#include <osgText/TextBase>
19#include <osgText/Style>
20
21namespace osgText {
22
23
25{
26 public:
27
30 {
32 PER_GLYPH
33 };
34
37
39
40
41 float getCharacterDepth() const;
42
44 void setCharacterDepth(float characterDepth);
45
47 RenderMode getRenderMode() const { return _renderMode; }
49 void setRenderMode(RenderMode renderMode) { _renderMode = renderMode; }
50
51
53 osg::StateSet* getWallStateSet() { return _wallStateSet.get(); }
55 const osg::StateSet* getWallStateSet() const { return _wallStateSet.get(); }
58 {
59 if (_wallStateSet.valid() == false) _wallStateSet = new osg::StateSet;
60 return _wallStateSet.get();
61 }
63 void setWallStateSet(osg::StateSet* wallStateSet) { _wallStateSet = wallStateSet; }
64
66 osg::StateSet* getBackStateSet() { return _backStateSet.get(); }
68 osg::StateSet* getBackStateSet() const { return _backStateSet.get(); }
70 osg::StateSet* getOrCreateBackStateSet() { if (_backStateSet.valid() == false) _backStateSet = new osg::StateSet; return _backStateSet.get(); }
72 void setBackStateSet(osg::StateSet* backStateSet) { _backStateSet = backStateSet; }
73
74
75
77 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
78
80 virtual bool supports(const osg::Drawable::AttributeFunctor&) const { return false; }
81
83 virtual bool supports(const osg::Drawable::ConstAttributeFunctor&) const { return false; }
84
87
89 virtual bool supports(const osg::PrimitiveFunctor&) const { return false; }
90
92 virtual void accept(osg::PrimitiveFunctor& pf) const;
93
95 virtual void resizeGLObjectBuffers(unsigned int maxSize);
96
100 virtual void releaseGLObjects(osg::State* state=0) const;
101
102 // make Font a friend to allow it set the _font to 0 if the font is
103 // forcefully unloaded.
104 friend class Font;
105
107
108
109 protected:
110
111 virtual ~Text3D() {}
112
113 String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
114
116
117 void copyAndOffsetPrimitiveSets(osg::Geometry::PrimitiveSetList& dest_PrimitiveSetList, osg::Geometry::PrimitiveSetList& src_PrimitiveSetList, unsigned int offset);
118
122
123 // ** glyph and other information to render the glyph
125 {
127 _glyphGeometry(glyphGeometry),
128 _position(pos) {}
129
132 };
133
134 typedef std::vector<GlyphRenderInfo> LineRenderInfo;
135 typedef std::vector<LineRenderInfo> TextRenderInfo;
136
138
139 // deprecated value no longer used.
141
144};
145
146}
147
148
149#endif
Definition Font:68
Definition Glyph:134
Definition Text3D:25
void setCharacterDepth(float characterDepth)
virtual void accept(osg::Drawable::ConstAttributeFunctor &af) const
osg::ref_ptr< osg::StateSet > _wallStateSet
Definition Text3D:142
std::vector< GlyphRenderInfo > LineRenderInfo
Definition Text3D:134
osg::Geometry::PrimitiveSetList _wallPrimitiveSetList
Definition Text3D:120
osg::StateSet * getOrCreateWallStateSet()
Definition Text3D:57
virtual bool supports(const osg::Drawable::ConstAttributeFunctor &) const
Definition Text3D:83
void copyAndOffsetPrimitiveSets(osg::Geometry::PrimitiveSetList &dest_PrimitiveSetList, osg::Geometry::PrimitiveSetList &src_PrimitiveSetList, unsigned int offset)
virtual bool supports(const osg::PrimitiveFunctor &) const
Definition Text3D:89
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
virtual void resizeGLObjectBuffers(unsigned int maxSize)
META_Object(osgText, Text3D) float getCharacterDepth() const
void setWallStateSet(osg::StateSet *wallStateSet)
Definition Text3D:63
void setRenderMode(RenderMode renderMode)
Definition Text3D:49
virtual osg::BoundingBox computeBoundingBox() const
osg::Geometry::PrimitiveSetList _backPrimitiveSetList
Definition Text3D:121
RenderMode getRenderMode() const
Definition Text3D:47
std::vector< LineRenderInfo > TextRenderInfo
Definition Text3D:135
RenderMode
Definition Text3D:30
@ PER_FACE
Definition Text3D:31
virtual void accept(osg::PrimitiveFunctor &pf) const
const osg::StateSet * getWallStateSet() const
Definition Text3D:55
RenderMode _renderMode
Definition Text3D:140
virtual ~Text3D()
Definition Text3D:111
void setBackStateSet(osg::StateSet *backStateSet)
Definition Text3D:72
osg::StateSet * getBackStateSet()
Definition Text3D:66
osg::StateSet * getOrCreateBackStateSet()
Definition Text3D:70
String::iterator computeLastCharacterOnLine(osg::Vec2 &cursor, String::iterator first, String::iterator last)
Text3D(const Text3D &text, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void computeGlyphRepresentation()
osg::StateSet * getWallStateSet()
Definition Text3D:53
osg::Geometry::PrimitiveSetList _frontPrimitiveSetList
Definition Text3D:119
virtual bool supports(const osg::Drawable::AttributeFunctor &) const
Definition Text3D:80
TextRenderInfo _textRenderInfo
Definition Text3D:137
virtual void releaseGLObjects(osg::State *state=0) const
osg::ref_ptr< osg::StateSet > _backStateSet
Definition Text3D:143
osg::StateSet * getBackStateSet() const
Definition Text3D:68
Definition TextBase:28
Definition BoundingBox:34
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition Drawable:426
std::vector< ref_ptr< PrimitiveSet > > PrimitiveSetList
Definition Geometry:102
Definition PrimitiveSet:54
Definition RenderInfo:28
Definition StateSet:46
Definition State:80
Definition Vec2f:29
Definition Vec3f:29
Definition ref_ptr:32
#define OSGTEXT_EXPORT
Definition osgText/Export:39
osg::Vec3 _position
Definition Text3D:131
GlyphRenderInfo(GlyphGeometry *glyphGeometry, osg::Vec3 &pos)
Definition Text3D:126
osg::ref_ptr< GlyphGeometry > _glyphGeometry
Definition Text3D:130