[osg-users] order of MatrixTransform
Hi, I'm a little confused about something simple... the order in which to add MatrixTransform. For example I want to rotate something around x,y,z using 3 matrixtransforms. as I understand I can do this by: -translate(-x,-y,-z) -rotate -translate(x,y,z) when I add them, which is the correct order? -root- translate(-x,-y,-z) - rotate - translate(x,y,z) - geode or... -root- translate(x,y,z) - rotate - translate(-x,-y,-z) - geode thanks! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61032#61032 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] order of MatrixTransform
HI Bram, On 14 September 2014 13:23, Bram Vaessen bram.vaes...@gmail.com wrote: Hi, I'm a little confused about something simple... the order in which to add MatrixTransform. For example I want to rotate something around x,y,z using 3 matrixtransforms. as I understand I can do this by: -translate(-x,-y,-z) -rotate -translate(x,y,z) when I add them, which is the correct order? -root- translate(-x,-y,-z) - rotate - translate(x,y,z) - geode or... -root- translate(x,y,z) - rotate - translate(-x,-y,-z) - geode The second version is the correct one. You can of course do this all with a single PositionAttitudeTransform or a single Transform node, this will be neater and lead to better performance. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] order of MatrixTransform
Thanks. Is there a way to make it a single node, but still being able to easily change the rotation around the point (the point on which to rotate doesn't change) ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61035#61035 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] order of MatrixTransform
Hi Bram, If you use single MatrixTransform you can achieve the same effect in the way you are constructing the scenegraph above by multiplication of different matrices. Something like osg::MatrixTransform *mxt = new osg::MatrixTransform; mxt-setMatrix( osg::Matrix::translate(-myPoint) * osg::Matrix::rotate(myRotation) * osg::Matrix::translate(myPoint) ); And you keep track and change myRotation, which is osg::Quat. Nick On Sun, Sep 14, 2014 at 5:29 PM, Bram Vaessen bram.vaes...@gmail.com wrote: Thanks. Is there a way to make it a single node, but still being able to easily change the rotation around the point (the point on which to rotate doesn't change) ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61035#61035 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] order of MatrixTransform
Ok thanks, I would have to recalculate the matrix every time the rotation changes I assume, but in the end that is probably more efficient than having 3 matrixtransforms in the scenegraph... right? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61037#61037 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] order of MatrixTransform
yes. This is what I think Robert had in mind when he mentioned performance efficiency Nick On Sun, Sep 14, 2014 at 10:42 PM, Bram Vaessen bram.vaes...@gmail.com wrote: Ok thanks, I would have to recalculate the matrix every time the rotation changes I assume, but in the end that is probably more efficient than having 3 matrixtransforms in the scenegraph... right? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61037#61037 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org