Added support for setting the axis which the text should be aligned along.
This commit is contained in:
parent
a4404a388d
commit
d7692f83d7
@ -63,6 +63,13 @@ class OSGTEXT_EXPORT Text : public osg::Drawable
|
|||||||
ALIGNMENT = 1<<2,
|
ALIGNMENT = 1<<2,
|
||||||
DEFAULT = TEXT,
|
DEFAULT = TEXT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum AxisAlignment
|
||||||
|
{
|
||||||
|
XY_PLANE,
|
||||||
|
XZ_PLANE,
|
||||||
|
YZ_PLANE
|
||||||
|
};
|
||||||
|
|
||||||
Text();
|
Text();
|
||||||
Text(const Text& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
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);
|
void setAlignment(int alignment);
|
||||||
int getAlignment() const { return _alignment; }
|
int getAlignment() const { return _alignment; }
|
||||||
|
|
||||||
|
void setAxisAlignment(AxisAlignment axis) { _axisAlignment = axis; dirtyDisplayList(); }
|
||||||
|
AxisAlignment getAxisAlignment() const { return _axisAlignment; }
|
||||||
|
|
||||||
void setFont(Font* font);
|
void setFont(Font* font);
|
||||||
Font* getFont() { return _font.get(); }
|
Font* getFont() { return _font.get(); }
|
||||||
@ -137,6 +147,7 @@ class OSGTEXT_EXPORT Text : public osg::Drawable
|
|||||||
int _alignment;
|
int _alignment;
|
||||||
int _drawMode;
|
int _drawMode;
|
||||||
int _boundingBoxType;
|
int _boundingBoxType;
|
||||||
|
AxisAlignment _axisAlignment;
|
||||||
|
|
||||||
osg::Vec3 _pos;
|
osg::Vec3 _pos;
|
||||||
osg::Vec3 _alignmentPos;
|
osg::Vec3 _alignmentPos;
|
||||||
|
@ -45,6 +45,7 @@ Text::Text(const Text& text,const osg::CopyOp& copyop):
|
|||||||
_alignment(text._alignment),
|
_alignment(text._alignment),
|
||||||
_drawMode(text._drawMode),
|
_drawMode(text._drawMode),
|
||||||
_boundingBoxType(text._boundingBoxType),
|
_boundingBoxType(text._boundingBoxType),
|
||||||
|
_axisAlignment(text._axisAlignment),
|
||||||
_pos(text._pos),
|
_pos(text._pos),
|
||||||
_alignmentPos(text._alignmentPos),
|
_alignmentPos(text._alignmentPos),
|
||||||
_color(text._color)
|
_color(text._color)
|
||||||
@ -122,8 +123,11 @@ setDefaults()
|
|||||||
_boundingBoxType=GLYPH;
|
_boundingBoxType=GLYPH;
|
||||||
_boundingBoxType=GEOMETRY;
|
_boundingBoxType=GEOMETRY;
|
||||||
|
|
||||||
|
_axisAlignment = XY_PLANE;
|
||||||
|
|
||||||
_initAlignment=false;
|
_initAlignment=false;
|
||||||
|
|
||||||
|
|
||||||
_useDisplayList=false;
|
_useDisplayList=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +213,8 @@ void Text::drawImplementation(State& state) const
|
|||||||
{
|
{
|
||||||
case POLYGON:
|
case POLYGON:
|
||||||
glTranslatef(drawPos.x(),drawPos.y(),drawPos.z());
|
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());
|
_font->output(state,_text.c_str());
|
||||||
break;
|
break;
|
||||||
case OUTLINE:
|
case OUTLINE:
|
||||||
|
Loading…
Reference in New Issue
Block a user