Text3D
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGTEXT_TEXT3D
#define OSGTEXT_TEXT3D 1
#include <osgText/TextBase>
#include <osgText/Style>
namespace osgText {
class OSGTEXT_EXPORT Text3D : public osgText::TextBase
{
public:
enum RenderMode
{
PER_FACE,
PER_GLYPH
};
Text3D();
Text3D(const Text3D& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgText,Text3D)
float getCharacterDepth() const;
void setCharacterDepth(float characterDepth);
RenderMode getRenderMode() const { return _renderMode; }
void setRenderMode(RenderMode renderMode) { _renderMode = renderMode; }
osg::StateSet* getWallStateSet() { return _wallStateSet.get(); }
const osg::StateSet* getWallStateSet() const { return _wallStateSet.get(); }
osg::StateSet* getOrCreateWallStateSet()
{
if (_wallStateSet.valid() == false) _wallStateSet = new osg::StateSet;
return _wallStateSet.get();
}
void setWallStateSet(osg::StateSet* wallStateSet) { _wallStateSet = wallStateSet; }
osg::StateSet* getBackStateSet() { return _backStateSet.get(); }
osg::StateSet* getBackStateSet() const { return _backStateSet.get(); }
osg::StateSet* getOrCreateBackStateSet() { if (_backStateSet.valid() == false) _backStateSet = new osg::StateSet; return _backStateSet.get(); }
void setBackStateSet(osg::StateSet* backStateSet) { _backStateSet = backStateSet; }
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
virtual bool supports(const osg::Drawable::AttributeFunctor&) const { return false; }
virtual bool supports(const osg::Drawable::ConstAttributeFunctor&) const { return false; }
virtual void accept(osg::Drawable::ConstAttributeFunctor& af) const;
virtual bool supports(const osg::PrimitiveFunctor&) const { return false; }
virtual void accept(osg::PrimitiveFunctor& pf) const;
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* state=0) const;
// make Font a friend to allow it set the _font to 0 if the font is
// forcefully unloaded.
friend class Font;
virtual osg::BoundingBox computeBoundingBox() const;
protected:
virtual ~Text3D() {}
String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
void computeGlyphRepresentation();
void copyAndOffsetPrimitiveSets(osg::Geometry::PrimitiveSetList& dest_PrimitiveSetList, osg::Geometry::PrimitiveSetList& src_PrimitiveSetList, unsigned int offset);
osg::Geometry::PrimitiveSetList _frontPrimitiveSetList;
osg::Geometry::PrimitiveSetList _wallPrimitiveSetList;
osg::Geometry::PrimitiveSetList _backPrimitiveSetList;
// ** glyph and other information to render the glyph
struct GlyphRenderInfo
{
GlyphRenderInfo(GlyphGeometry* glyphGeometry, osg::Vec3 & pos):
_glyphGeometry(glyphGeometry),
_position(pos) {}
osg::ref_ptr<GlyphGeometry> _glyphGeometry;
osg::Vec3 _position;
};
typedef std::vector<GlyphRenderInfo> LineRenderInfo;
typedef std::vector<LineRenderInfo> TextRenderInfo;
TextRenderInfo _textRenderInfo;
// deprecated value no longer used.
RenderMode _renderMode;
osg::ref_ptr<osg::StateSet> _wallStateSet;
osg::ref_ptr<osg::StateSet> _backStateSet;
};
}
#endif
TextBase
osgText::GlyphGeometry
Definition Glyph:134
osgText::Text3D::setCharacterDepth
void setCharacterDepth(float characterDepth)
osgText::Text3D::accept
virtual void accept(osg::Drawable::ConstAttributeFunctor &af) const
osgText::Text3D::_wallStateSet
osg::ref_ptr< osg::StateSet > _wallStateSet
Definition Text3D:142
osgText::Text3D::LineRenderInfo
std::vector< GlyphRenderInfo > LineRenderInfo
Definition Text3D:134
osgText::Text3D::_wallPrimitiveSetList
osg::Geometry::PrimitiveSetList _wallPrimitiveSetList
Definition Text3D:120
osgText::Text3D::getOrCreateWallStateSet
osg::StateSet * getOrCreateWallStateSet()
Definition Text3D:57
osgText::Text3D::supports
virtual bool supports(const osg::Drawable::ConstAttributeFunctor &) const
Definition Text3D:83
osgText::Text3D::copyAndOffsetPrimitiveSets
void copyAndOffsetPrimitiveSets(osg::Geometry::PrimitiveSetList &dest_PrimitiveSetList, osg::Geometry::PrimitiveSetList &src_PrimitiveSetList, unsigned int offset)
osgText::Text3D::supports
virtual bool supports(const osg::PrimitiveFunctor &) const
Definition Text3D:89
osgText::Text3D::drawImplementation
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
osgText::Text3D::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osgText::Text3D::META_Object
META_Object(osgText, Text3D) float getCharacterDepth() const
osgText::Text3D::setWallStateSet
void setWallStateSet(osg::StateSet *wallStateSet)
Definition Text3D:63
osgText::Text3D::setRenderMode
void setRenderMode(RenderMode renderMode)
Definition Text3D:49
osgText::Text3D::computeBoundingBox
virtual osg::BoundingBox computeBoundingBox() const
osgText::Text3D::_backPrimitiveSetList
osg::Geometry::PrimitiveSetList _backPrimitiveSetList
Definition Text3D:121
osgText::Text3D::getRenderMode
RenderMode getRenderMode() const
Definition Text3D:47
osgText::Text3D::TextRenderInfo
std::vector< LineRenderInfo > TextRenderInfo
Definition Text3D:135
osgText::Text3D::RenderMode
RenderMode
Definition Text3D:30
osgText::Text3D::PER_GLYPH
@ PER_GLYPH
Definition Text3D:32
osgText::Text3D::PER_FACE
@ PER_FACE
Definition Text3D:31
osgText::Text3D::accept
virtual void accept(osg::PrimitiveFunctor &pf) const
osgText::Text3D::getWallStateSet
const osg::StateSet * getWallStateSet() const
Definition Text3D:55
osgText::Text3D::_renderMode
RenderMode _renderMode
Definition Text3D:140
osgText::Text3D::~Text3D
virtual ~Text3D()
Definition Text3D:111
osgText::Text3D::setBackStateSet
void setBackStateSet(osg::StateSet *backStateSet)
Definition Text3D:72
osgText::Text3D::getBackStateSet
osg::StateSet * getBackStateSet()
Definition Text3D:66
osgText::Text3D::getOrCreateBackStateSet
osg::StateSet * getOrCreateBackStateSet()
Definition Text3D:70
osgText::Text3D::Text3D
Text3D()
osgText::Text3D::computeLastCharacterOnLine
String::iterator computeLastCharacterOnLine(osg::Vec2 &cursor, String::iterator first, String::iterator last)
osgText::Text3D::Text3D
Text3D(const Text3D &text, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgText::Text3D::computeGlyphRepresentation
void computeGlyphRepresentation()
osgText::Text3D::getWallStateSet
osg::StateSet * getWallStateSet()
Definition Text3D:53
osgText::Text3D::_frontPrimitiveSetList
osg::Geometry::PrimitiveSetList _frontPrimitiveSetList
Definition Text3D:119
osgText::Text3D::supports
virtual bool supports(const osg::Drawable::AttributeFunctor &) const
Definition Text3D:80
osgText::Text3D::Font
friend class Font
Definition Text3D:104
osgText::Text3D::_textRenderInfo
TextRenderInfo _textRenderInfo
Definition Text3D:137
osgText::Text3D::releaseGLObjects
virtual void releaseGLObjects(osg::State *state=0) const
osgText::Text3D::_backStateSet
osg::ref_ptr< osg::StateSet > _backStateSet
Definition Text3D:143
osgText::Text3D::getBackStateSet
osg::StateSet * getBackStateSet() const
Definition Text3D:68
osgText::TextBase
Definition TextBase:28
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Drawable::AttributeFunctor
Definition Drawable:426
osg::Drawable::ConstAttributeFunctor
Definition Drawable:461
osg::Geometry::PrimitiveSetList
std::vector< ref_ptr< PrimitiveSet > > PrimitiveSetList
Definition Geometry:102
osg::PrimitiveFunctor
Definition PrimitiveSet:54
osg::RenderInfo
Definition RenderInfo:28
osg::StateSet
Definition StateSet:46
osg::State
Definition State:80
osg::ref_ptr
Definition ref_ptr:32
osgText
osg::Vec2
Vec2f Vec2
Definition Vec2:21
osg::Vec3
Vec3f Vec3
Definition Vec3:21
osg::BoundingBox
BoundingBoxd BoundingBox
Definition BoundingBox:257
OSGTEXT_EXPORT
#define OSGTEXT_EXPORT
Definition osgText/Export:39
Style
osgText::Text3D::GlyphRenderInfo::_position
osg::Vec3 _position
Definition Text3D:131
osgText::Text3D::GlyphRenderInfo::GlyphRenderInfo
GlyphRenderInfo(GlyphGeometry *glyphGeometry, osg::Vec3 &pos)
Definition Text3D:126
osgText::Text3D::GlyphRenderInfo::_glyphGeometry
osg::ref_ptr< GlyphGeometry > _glyphGeometry
Definition Text3D:130