[osg-users] osgText::Text rotation
gwaldron at gmail.com
Wed Mar 11 10:53:30 PDT 2009
osg::Matrix cell2map = env->getInputSRS()->getInverseReferenceFrame();
osg::Vec3d feature_center = point * cell2map;
osg::Vec3d cell_center = osg::Vec3d(0,0,1) * cell2map;
q.makeRotate( cell_center, feature_center );
Glenn Waldron : Pelican Mapping : http://pelicanmapping.com :
On Wed, Mar 11, 2009 at 10:07 AM, Dirk Uys <dirkcuys at gmail.com> wrote:
> 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