Hi,
Akilan Thangamani wrote:
Hi,
Yes. I changed the way I was doing. I set geometry under a matrix transform
node and trying to rotate the geometry 90 degree over Z-axis. It s getting
translated too. I want to know how much unit I have to translate it back and
If I want to rotate on other than Z-axis, what initial matrix I have to set to
MT?
osg::Camera* g_camera=new osg::Camera;
g_camera->setProjectionMatrixAsOrtho2D(0,1,0,1);
g_camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
g_camera->setClearMask(GL_DEPTH_BUFFER_BIT);
g_camera->setRenderOrder(osg::Camera::POST_RENDER);
osg::ref_ptr<osg::MatrixTransform> MT=new osg::MatrixTransform;
osg::Matrix mat(osg::Matrix::identity());
mat.makeRotate(osg::DegreesToRadians(90.),osg::Vec3f(0.0,0.0,1.0));
MT->setMatrix(mat);
MT->addChild(create_geom());
g_camera->addChild(MT.get());
osgViewer::Viewer viewer;
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); viewer.setCameraManipulator( new osgGA::TrackballManipulator() );
viewer.setSceneData(g_camera);
viewer.realize();
while(!viewer.done())
{
viewer.frame();
}
Look @ the file attached. In that, figure (1) is what my actual geometry and
figure (2) is what I wanted to result.
The geometry would rotate about its own 0 point, so if your 0 point is
not in the center, it would appear that the geometry is translating and
rotating. So, what you want to do is move your geometry first so that
the point you want to rotate around is where you want it (I don't know
the exact numbers, you will have to look in your geometry) and then do
the rotation. You can link matrixtransforms under each other, e.g. say
your geometry center is at (1,1,0) you can do
root->Rotate(90 about Z)->translate(-1,-1,0)->geom
Have a look at the Red Book here:
http://www.glprogramming.com/red/chapter03.html
especially the section:
Viewing and Modeling Transformations
jp
Thank you!
Cheers,
Akilan
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=17167#17167
------------------------------------------------------------------------
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org