Hi, I am trying to move a pyramid in the following manner.
(X,Y,Z,Roll,Pitch,Yaw) -> read from a txt file. Move the pyramid by (X,Y,Z) and then rotate it about its peak by (Roll, Pitch, Yaw) Here's the code I made till now: > osg::AnimationPath* animationPath = > createAnimationPath("autoPath2.txt",0.1); > > {... > Defined the Pyramid > ... > } > > const osg::BoundingSphere& bs = pyramidGeode->getBound(); > > float size = radius/bs.radius()*0.3f; > osg::MatrixTransform* positioned = new osg::MatrixTransform; > positioned->setDataVariance(osg::Object::STATIC); > positioned->setMatrix(osg::Matrix::translate(-bs.center())* > osg::Matrix::scale(size,size,size)* > > osg::Matrix::rotate(osg::inDegrees(-90.0f),0.0f,0.0f,1.0f)); > > positioned->addChild(pyramidGeode); > > osg::PositionAttitudeTransform* xform = new > osg::PositionAttitudeTransform; > xform->setUpdateCallback(new > osg::AnimationPathCallback(animationPath,0.0,1.0)); > xform->addChild(positioned); > > model->addChild(xform); My animation is defined as follows: > osg::AnimationPath* createAnimationPath(std::string filename,double deltatime) > { > std::ifstream infile; > infile.open(filename.c_str(),std::ios::in); > double time=0.0f; > > osg::AnimationPath* animationPath = new osg::AnimationPath; > animationPath->setLoopMode(osg::AnimationPath::LOOP); > > > > while(infile.is_open() && !infile.eof()) > { > > double x,y,z,r,p,ya; > infile >> x >> y >> z>> r>> p>>ya; > osg::Vec3 position(x,y,z); > osg::Quat rotation; > > rotation.makeRotate( osg::DegreesToRadians(r), osg::Vec3(-1,0,0), > osg::DegreesToRadians(p), osg::Vec3(0,-1,0) , > osg::DegreesToRadians(ya), osg::Vec3(0,0,1) ); > > > animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation)); > time += deltatime; > } > > infile.close(); > > return animationPath; > > } But what this does is move the pyramid by X,Y,Z and rotate it by Roll,Pitch,Yaw about the ORIGIN! I want to rotate it around its peak and not the origin. Can you suggest any modifications? Thank you! Cheers, John ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=25432#25432 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org