Hi Paul; >So in OSG first of all I try to do it with a <osg::Switch> but seems that this node accumulate the transformations... is that right?
What do you mean about osg::Switch. It's not specific feaute on accumulating trasformation for osg::Switch as I know. It actual target is switching node while rendering scene graph. What type gridOrientation is? Be careful while multiplying the matricies because precedence is important for kind of these operations : result = rotation * translation; Regards. Ümit Uzun 2009/7/17 Pau Moreno Font <tekka...@gmail.com> > Hi, > > 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 ); > > glBegin( GL_POINTS ) > ........ > glEnd(); > glPopMatrix(); > } > > > So in OSG first of all I try to do it with a <osg::Switch> but seems that > this node accumulate the transformations... is that right?? So what I > finally do is to attach a diferent node in each iteration and detach the > previous one. But the real problem is that OSG is not doing the same as OGL. > I do this for each node: > > { > osg::Matrixf rotation; > osg::Matrixf translation; > osg::Matrixf result; > > 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 ); > > result = rotation * translation; > > osg::MatrixTransform * transformation = new osg::MatrixTransform(); > > transformation->addChild( gNode ); > transformation->setMatrix( result ); > } > > > 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 ); > > m_root->addChild( transformation ); > > ..... > > > What I'm doing wrong? I've tried a lot of combinations of creating rotation > , translation, result, but no one is the correct!! I think I'm doing > something wrong I cannot apreciate. > > > Thanks!! > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org