[osg-users] newbie question (UNCLASSIFIED)

Konkle, Daniel T AMRDEC/Dynetics Daniel.Konkle at us.army.mil
Wed Mar 11 07:13:33 PDT 2009


Classification:  UNCLASSIFIED 
Caveats: NONE


I'm translating some opengl code to OpenSceneGraph.
I've figured out how to most of the stuff I need except 
I'm having trouble getting the rotations and translations to
play nice.

My code example that I need to translate:

    glTranslatef(hud_aspect, 0.0f, 0.0f);
    glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
    glBegin(GL_LINE_LOOP);
    glVertex2fv(hud_ctr_ref_tri[0]);
    glVertex2fv(hud_ctr_ref_tri[1]);
    glVertex2fv(hud_ctr_ref_tri[2]);


I'm able to correctly draw the line loop without the rotation.
When I try to add the rotation it doesn't work.
My code is below.  

          osg::ref_ptr<osg::Geode> triangle = new osg::Geode();
 	    triangle->addDrawable( drawLines( tri, 0 ) );

	    osg::ref_ptr<osg::MatrixTransform> translate = new
osg::MatrixTransform;
	    osg::Matrix tran_mat = osg::Matrix::translate( hud_aspect,
0.0f, 0.0f );
	    translate->setMatrix( tran_mat );

	    osg::ref_ptr<osg::MatrixTransform> rotate = new
osg::MatrixTransform;
	    osg::Matrix rot_mat = osg::Matrix::rotate( M_PI, 0.0f, 0.0f,
1.0f);
	    rotate->setMatrix( rot_mat );

	    translate->addChild( rotate.get() );
	    camera->addChild(translate.get());
	    translate->addChild( triangle.get() );

I would greatly appreciate any help in figuring out what I'm doing
wrong.

Thanks,
Danny Konkle

Classification:  UNCLASSIFIED 
Caveats: NONE




More information about the osg-users mailing list