[osg-users] osgText::Text rotation
vincent.bourdier at gmail.com
Wed Mar 11 09:46:25 PDT 2009
Maybe you have the same problem than I had :
(sorry no solution...)
2009/3/11 Dirk Uys <dirkcuys at gmail.com>
> I'm new to OSG, but not so new to scene graphs in general.
> I'm trying to make some changes to osgGIS to suit my needs. I wish to
> change the BuildLabelsFilter to rotate labels so that they face away
> from the terrain. Here is a short piece of code to show what I've done
> osg::Vec3d up( input->getExtent().getSRS()->getUpVector(point) );
> osg::Quat rotation;
> rotation.makeRotate( up, osg::Vec3d(0, 0, 1) );
> // build the drawable:
> osgText::Text* t = new osgText::Text();
> t->setAutoRotateToScreen( false );
> t->setCharacterSizeMode( osgText::Text::SCREEN_COORDS );
> t->setAlignment( osgText::Text::CENTER_CENTER );
> t->setText( text.c_str() );
> t->setColor( color );
> t->setCharacterSize( (float)font_size );
> t->setPosition( point );
> t->setBackdropType( osgText::Text::OUTLINE );
> t->setBackdropColor( osg::Vec4(0,0,0,1) );
> But the results are not correct (see screenshot).
> If I add a line from point to (point + rotation*Vec3d(0, 0, 1)), the
> line gets rotated correctly and coincides with the up vector.
> I also tried using
> but in this case the text completely disappears.
> If I change rotation.makeRotate( up, osg::Vec3d(0, 0, 1) ); to
> rotation.makeRotate( 0.0, osg::X_AXIS, osg::inDegrees(80.0),
> osg::Y_AXIS, 0.0, osg::Z_AXIS );
> It looks like the text are rotated by 80 degrees around the Y axes and
> then projected onto the XY plane?
> Rotating around the Z axis seems to be working fine
> I looked at the osgtext example and the setAxisAlignment() works as
> Am I understanding the use of osgText::Text::rotate() incorrectly, or
> is there something else I'm doing wrong?
> I'm using OSG 2.8.0 and OSGGIS from the svn repository - last updated
> to rev 179.
> osg-users mailing list
> osg-users at lists.openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the osg-users