On 17/7/09 8:19 PM, Pau Moreno Font wrote:
I'm trying to change my OGL code to OSG but I'm having really problems
with the transformations... I have 174 data files that each contains a
cloud of points, a vector3 with the translartion, and the matrix of
rotation of each cloud. So in OGL, i just do:

{
LoadFile( x++)                          //Loads a diferent file in each
iteration
glPushMatrix();
   glTranslate( x , y , z )
   glMultMatrixf( rotation );
     ........

{
   osg::Matrixf rotation;
     ........

   rotation.set(   gridOrientation.get( 0 , 0 ) , gridOrientation.get( 0
, 1 ) , gridOrientation.get( 0 , 2 ) , 0.0,
                       gridOrientation.get( 1 , 0 ) ,
gridOrientation.get( 1 , 1 ) , gridOrientation.get( 1 , 2 ) , 0.0,
                       gridOrientation.get( 2 , 0 ) ,
gridOrientation.get( 2 , 1 ) , gridOrientation.get( 2 , 2 ) , 0.0,
                       0.0f , 0.0f , 0.0f , 1.0f );
   translation.setTrans(  x , y , z );

By the way I read the OSGQSG (page 64) the memory layout of OSG and OpenGL matrices is identical. So it should be possible to pass the 'rotation' matrix from the OGL code to the Matrix constructor and at least tie down that end.

rotationOGL.makeRotate( osg::DegreesToRadians(90.0) , osg::Vec3d( 0.0 ,
1.0 , 0.0 ));
transformationOGL->setMatrix(rotationOGL);
transformationOGL->addChild(m_root);
m_vViewer.setSceneData( transformationOGL );

Is 'rotationOGL' is supposed to convert OSG Z-up convention to OpenGL's Y-up? If that's the case you should rotate around the X-axis, not the Y-axis.

Also: this probably doesn't affect the outcome but I tend to use osg::Vec3 and osg::Matrix instead of their respective float/double versions and instead rely on OSG to pick its compile setting.

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to