[osg-users] CallBack issue

Paul Martz pmartz at skew-matrix.com
Fri Mar 27 16:24:20 PDT 2009


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-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at 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<osg::MatrixTransform*>(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<osg::MatrixTransform> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090327/2f26a834/attachment-0003.htm>


More information about the osg-users mailing list