From d7692f83d746815b68ac190da851f32ed2f8863b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 5 Dec 2002 12:01:38 +0000 Subject: [PATCH] Added support for setting the axis which the text should be aligned along. --- include/osgText/Text | 11 +++++++++++ src/osgText/Text.cpp | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/include/osgText/Text b/include/osgText/Text index 17d5026ee..f7e91d942 100644 --- a/include/osgText/Text +++ b/include/osgText/Text @@ -63,6 +63,13 @@ class OSGTEXT_EXPORT Text : public osg::Drawable ALIGNMENT = 1<<2, DEFAULT = TEXT, }; + + enum AxisAlignment + { + XY_PLANE, + XZ_PLANE, + YZ_PLANE + }; Text(); Text(const Text& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); @@ -92,6 +99,9 @@ class OSGTEXT_EXPORT Text : public osg::Drawable void setAlignment(int alignment); int getAlignment() const { return _alignment; } + + void setAxisAlignment(AxisAlignment axis) { _axisAlignment = axis; dirtyDisplayList(); } + AxisAlignment getAxisAlignment() const { return _axisAlignment; } void setFont(Font* font); Font* getFont() { return _font.get(); } @@ -137,6 +147,7 @@ class OSGTEXT_EXPORT Text : public osg::Drawable int _alignment; int _drawMode; int _boundingBoxType; + AxisAlignment _axisAlignment; osg::Vec3 _pos; osg::Vec3 _alignmentPos; diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index a2fb9f4ca..941217c26 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -45,6 +45,7 @@ Text::Text(const Text& text,const osg::CopyOp& copyop): _alignment(text._alignment), _drawMode(text._drawMode), _boundingBoxType(text._boundingBoxType), + _axisAlignment(text._axisAlignment), _pos(text._pos), _alignmentPos(text._alignmentPos), _color(text._color) @@ -122,8 +123,11 @@ setDefaults() _boundingBoxType=GLYPH; _boundingBoxType=GEOMETRY; + _axisAlignment = XY_PLANE; + _initAlignment=false; + _useDisplayList=false; } @@ -209,6 +213,8 @@ void Text::drawImplementation(State& state) const { case POLYGON: glTranslatef(drawPos.x(),drawPos.y(),drawPos.z()); + if(_axisAlignment==XZ_PLANE) glRotatef(90.0f,1.0f,0.0f,0.0f); + else if (_axisAlignment==YZ_PLANE) { glRotatef(90.0f,0.0f,0.0f,1.0f); glRotatef(90.0f,1.0f,0.0f,0.0f);} _font->output(state,_text.c_str()); break; case OUTLINE: