Re: [osg-users] Problem with rotations using PositionAttitudeTransform
Thank you very much Vincent! That was my error, I was calling to the osg::Quad constructor with a wrong order in the params Cheers, Manuel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=24049#24049 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with rotations using PositionAttitudeTransform
Hi Manuel, You use the osg::Quat(x,y,z,w) constructor, but your arguments are not in the good order. You may use osg::Quat(angle, osg::vec3d(x,y,z)) to be sure. Hope this can help you. Regards, Vincent. Manuel Garea a écrit : Hi, I'm trying to make some rotation of objects, but the results are not the desired I want to draw the coordinate axis. The following function draw an axis with the given rotation: Code: osg::PositionAttitudeTransform* createAxis(osg::Vec4f color, osg::Quat rotation){ osg::StateSet* axisStateSet = createColorStateSet(color); osg::Geode* axisGeode = new osg::Geode(); osg::Cylinder* axisCylinder = new osg::Cylinder(osg::Vec3(0.0f,0.0f,0.0f), 20, 5); osg::ShapeDrawable* axisDrawable = new osg::ShapeDrawable(axisCylinder); axisDrawable->setStateSet(axisStateSet); osg::PositionAttitudeTransform* axisTransform = new osg::PositionAttitudeTransform; axisTransform->setAttitude(rotation); axisGeode->addDrawable(axisDrawable); axisTransform->addChild(axisGeode); return axisTransform; } And the following function draw the 3 axis giving the rotations: Code: osg::Group* createCoordinatesAxis(){ osg::PositionAttitudeTransform* xTransform = createAxis(osg::Vec4f(1,0,0,1), osg::Quat(osg::DegreesToRadians(90.0), 0, 1, 0)); osg::PositionAttitudeTransform* yTransform = createAxis(osg::Vec4f(0,1,0,1), osg::Quat(osg::DegreesToRadians(90.0), 0, 0, 1)); osg::PositionAttitudeTransform* zTransform = createAxis(osg::Vec4f(0,0,1,1), osg::Quat(0, 1, 0, 0)); osg::Group* axisGroup = new osg::Group(); axisGroup->addChild(xTransform); axisGroup->addChild(yTransform); axisGroup->addChild(zTransform); return axisGroup; } The result is in the following image, but the axis (red, green and blue) are not turned 90 degrees!!! do someone know why??? Thank you! Cheers, Manuel[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=24030#24030 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org __ Information from ESET NOD32 Antivirus, version of virus signature database 4858 (20100211) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with rotations using PositionAttitudeTransform
Hi, I'm trying to make some rotation of objects, but the results are not the desired I want to draw the coordinate axis. The following function draw an axis with the given rotation: Code: osg::PositionAttitudeTransform* createAxis(osg::Vec4f color, osg::Quat rotation){ osg::StateSet* axisStateSet = createColorStateSet(color); osg::Geode* axisGeode = new osg::Geode(); osg::Cylinder* axisCylinder = new osg::Cylinder(osg::Vec3(0.0f,0.0f,0.0f), 20, 5); osg::ShapeDrawable* axisDrawable = new osg::ShapeDrawable(axisCylinder); axisDrawable->setStateSet(axisStateSet); osg::PositionAttitudeTransform* axisTransform = new osg::PositionAttitudeTransform; axisTransform->setAttitude(rotation); axisGeode->addDrawable(axisDrawable); axisTransform->addChild(axisGeode); return axisTransform; } And the following function draw the 3 axis giving the rotations: Code: osg::Group* createCoordinatesAxis(){ osg::PositionAttitudeTransform* xTransform = createAxis(osg::Vec4f(1,0,0,1), osg::Quat(osg::DegreesToRadians(90.0), 0, 1, 0)); osg::PositionAttitudeTransform* yTransform = createAxis(osg::Vec4f(0,1,0,1), osg::Quat(osg::DegreesToRadians(90.0), 0, 0, 1)); osg::PositionAttitudeTransform* zTransform = createAxis(osg::Vec4f(0,0,1,1), osg::Quat(0, 1, 0, 0)); osg::Group* axisGroup = new osg::Group(); axisGroup->addChild(xTransform); axisGroup->addChild(yTransform); axisGroup->addChild(zTransform); return axisGroup; } The result is in the following image, but the axis (red, green and blue) are not turned 90 degrees!!! do someone know why??? Thank you! Cheers, Manuel[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=24030#24030 <>___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org