Re: [osg-users] CallBack issue
Hello Ami, On 28/3/09 8:50 AM, ami guru wrote: virtual void operator()(osg::Node *node, osg::NodeVisitor *nv) { osg::Matrix mR; mR.makeRotate(m_angle, osg::Vec3(0.0f,0.0f,1.0f)); mtLeft->setMatrix(mR); ... osg::Vec3f teapotTransVec = osg::Vec3f(5,2,-12); osg::Vec3f teapotScaleVec = osg::Vec3f(20.1f,20.1f,20.1f); teapotTransMat.makeTranslate(teapotTransVec); teapotScaleMat.makeScale(teapotScaleVec); teapotPos->setMatrix(teapotTransMat * teapotScaleMat); You're originally including a scaling transform in the Matrix. The Callback operator replaces this with only a rotation matrix i.e. the scaling part is lost hence the object looks smaller. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] CallBack issue
It looks like your callback is setting a matrix that contains only a rotate, but doesn't include the scale and translate that you initialize it with. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com <http://www.skew-matrix.com/> +1 303 859 9466 _ From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of ami guru Sent: Friday, March 27, 2009 3:50 PM To: OpenSceneGraph Users Subject: [osg-users] CallBack issue Hello forum, I am trying to rorate an object continuously through a call back. Before calling the calback i am doing some affine transformation over that object The final rendered the scaled down to a tiny object . In the callback subclass i am overloading the () operator and i am performing the rotation, not any kind of scaling down. **code**' class RotateCB : public osg::NodeCallback { public: RotateCB() : m_angle(0) { } virtual void operator()(osg::Node *node, osg::NodeVisitor *nv) { /* Normally, check to make sure that we have an update visitor, not necessary in this simple example */ osg::MatrixTransform * mtLeft = dynamic_cast(node); osg::Matrix mR; mR.makeRotate(m_angle, osg::Vec3(0.0f,0.0f,1.0f)); mtLeft->setMatrix(mR); //Increment the angle for the next from m_angle += 0.01; /* Continue traversing so that OSG can process any other nodes with callbacks */ traverse(node,nv); } . osg::ref_ptr teapotPos = new osg::MatrixTransform; osg::Matrix teapotTransMat; osg::Matrix teapotScaleMat; osg::Vec3f teapotTransVec = osg::Vec3f(5,2,-12); osg::Vec3f teapotScaleVec = osg::Vec3f(20.1f,20.1f,20.1f); teapotTransMat.makeTranslate(teapotTransVec); teapotScaleMat.makeScale(teapotScaleVec); teapotPos->setMatrix(teapotTransMat * teapotScaleMat); //SET THE data variance to dynamic to let OSG know that //we shall modify this node during update traversal teapotPos->setDataVariance(osg::Object::DYNAMIC); //SET THE update callback teapotPos->setUpdateCallback(new RotateCB); ... *' Any hint? Sajjad ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] CallBack issue
Hello forum, I am trying to rorate an object continuously through a call back. Before calling the calback i am doing some affine transformation over that object The final rendered the scaled down to a tiny object . In the callback subclass i am overloading the () operator and i am performing the rotation, not any kind of scaling down. **code**' class RotateCB : public osg::NodeCallback { public: RotateCB() : m_angle(0) { } virtual void operator()(osg::Node *node, osg::NodeVisitor *nv) { /* Normally, check to make sure that we have an update visitor, not necessary in this simple example */ osg::MatrixTransform * mtLeft = dynamic_cast(node); osg::Matrix mR; mR.makeRotate(m_angle, osg::Vec3(0.0f,0.0f,1.0f)); mtLeft->setMatrix(mR); //Increment the angle for the next from m_angle += 0.01; /* Continue traversing so that OSG can process any other nodes with callbacks */ traverse(node,nv); } . osg::ref_ptr teapotPos = new osg::MatrixTransform; osg::Matrix teapotTransMat; osg::Matrix teapotScaleMat; osg::Vec3f teapotTransVec = osg::Vec3f(5,2,-12); osg::Vec3f teapotScaleVec = osg::Vec3f(20.1f,20.1f,20.1f); teapotTransMat.makeTranslate(teapotTransVec); teapotScaleMat.makeScale(teapotScaleVec); teapotPos->setMatrix(teapotTransMat * teapotScaleMat); //SET THE data variance to dynamic to let OSG know that //we shall modify this node during update traversal teapotPos->setDataVariance(osg::Object::DYNAMIC); //SET THE update callback teapotPos->setUpdateCallback(new RotateCB); ... *' Any hint? Sajjad ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org