Hi All
I have what seems like a straight forward problem, but my solution does not
seem to work. I want to add a world offset to all osg animation paths in a
graph so that the animation can be used for a kinematic object with
osgBullet, which requires the object be in absolute world coords (which
leaves just adding a transform above out of the question). I tried this
simple loop over the TimeControlPointMap but when the app runs the animated
object is still in the same place.
//if animation update callback is found add the
rigid body animate callback
osg::AnimationPathCallback* apc = dynamic_cast
<osg::AnimationPathCallback*>(osgTrans->getUpdateCallback());
if(apc){
osgbBullet::RigidBodyAnimation* rba =
newosgbBullet::RigidBodyAnimation;
apc->setNestedCallback(rba);
//add the world offset to the
osg::AnimationPath* aniPath = apc->
getAnimationPath();
//osg::AnimationPath* newPath = new
osg::AnimationPath();
//osg::AnimationPath::TimeControlPointMap
timeMap = aniPath->getTimeControlPointMap();
osg::AnimationPath::TimeControlPointMap tcpm =
aniPath->getTimeControlPointMap();
for(osg::AnimationPath::TimeControlPointMap::iterator
tcpmitr=tcpm.begin();
tcpmitr!=tcpm.end();
++tcpmitr)
{
//add world offset
osg::Vec3 cpPos = tcpmitr->second.
getPosition();
OSG_FATAL << "PRE POS " << cpPos.x() << ",
" << cpPos.y() << ", " << cpPos.z() << std::endl;
tcpmitr->second.setPosition(cpPos+
_worldOffset);
cpPos = tcpmitr->second.getPosition();
OSG_FATAL << "POST POS " << cpPos.x() << ",
" << cpPos.y() << ", " << cpPos.z() << std::endl;
}
}
As you can see in the loop I get the current Position value, then set it
with the addition of the world offset. The Pre and Pos Pos message show that
the two values are different but when I run the object is atill in the same
place, not offset in any way.
Am I missing a step in changing te control points (dirty or something) ?
Many thanks
Tom
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org