From Dan Minor, "osgText::Text does not currently have a getAxisAlignment method. The

attached code adds this, along with a member variable to keep track of
the setting.  It is based on the latest subversion version, and was
tested by creating a new text object with the same axis alignment as an
existing one (e.g.
new_text->setAxisAlignment(old_text->getAxisAlignment()); )."

From Robert Osfield, " I originally didn't add a getAxisAlignment()
as all setAxisAlignment does is set the Rotation member variable, and
potentially one could apply user defined Rotation setting after the
setAxisAlignment() which would bring it out of sync with the
setAxisAlignment.

Rather than reject your submission on the ground of potentially
getting out of sync and therefore misleading users I've added a
USED_DEFINED_ROTATION to AxisAlignment enum, and set this in the
serRotation and then override this setting of _axisAlignment in the
setAxisAlingment method.  I've also removed the lazy updating
optimization you've added to the top of setAxisAlignment to avoid
potential problems as well."
This commit is contained in:
Robert Osfield 2007-09-30 15:06:59 +00:00
parent 91900254f0
commit 40ded29902
2 changed files with 8 additions and 1 deletions

View File

@ -181,10 +181,12 @@ public:
REVERSED_XZ_PLANE,
YZ_PLANE,
REVERSED_YZ_PLANE,
SCREEN
SCREEN,
USER_DEFINED_ROTATION
};
void setAxisAlignment(AxisAlignment axis);
AxisAlignment getAxisAlignment() const { return _axisAlignment; }
void setRotation(const osg::Quat& quat);
const osg::Quat& getRotation() const { return _rotation; }
@ -533,6 +535,7 @@ protected:
String _text;
osg::Vec3 _position;
AlignmentType _alignment;
AxisAlignment _axisAlignment;
osg::Quat _rotation;
bool _autoRotateToScreen;
Layout _layout;

View File

@ -41,6 +41,7 @@ Text::Text():
_maximumHeight(0.0f),
_lineSpacing(0.0f),
_alignment(BASE_LINE),
_axisAlignment(XY_PLANE),
_autoRotateToScreen(false),
_layout(LEFT_TO_RIGHT),
_color(1.0f,1.0f,1.0f,1.0f),
@ -77,6 +78,7 @@ Text::Text(const Text& text,const osg::CopyOp& copyop):
_text(text._text),
_position(text._position),
_alignment(text._alignment),
_axisAlignment(text._axisAlignment),
_rotation(text._rotation),
_autoRotateToScreen(text._autoRotateToScreen),
_layout(text._layout),
@ -199,6 +201,8 @@ void Text::setAlignment(AlignmentType alignment)
void Text::setAxisAlignment(AxisAlignment axis)
{
_axisAlignment = axis;
switch(axis)
{
case XZ_PLANE: