|
各位大牛,求指导:我在程序中加载了一个人物动画,我想在开始路径回调的时候播放动画,然后到达路径终点后停止动画,但是不知道如何判断节点是否到达路径终点!是要重写AnimationPathCallback,然后在里面加上判断条件?还是AnimationPathCallback本身就有方法判断已经到达终点?- osg::AnimationPath* CreatePath()
- {
- osg::Vec3 yoz(1.0,0.0,0.0),xoz(0.0,1.0,0.0),xoy(0.0,0.0,1.0);
- osg::ref_ptr<osg::AnimationPath> path = new osg::AnimationPath;
- path->insert(0.0,osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,0.0),osg::Quat(0.0,yoz,0.0,xoz,0.0,xoy)));
- path->insert(2.0,osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,0.0),osg::Quat(osg::PI,yoz,0.0,xoz,0.0,xoy)));
- path->insert(4.0,osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,0.0),osg::Quat(osg::PI,yoz,0.0,xoz,osg::PI,xoy)));
- path->insert(6.0,osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,0.0),osg::Quat(0.0,yoz,0.0,xoz,osg::PI,xoy)));
- path->insert(8.0,osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,0.0),osg::Quat(0.0,yoz,0.0,xoz,0.0,xoy)));
- return path.release();
- }
-
- bool handle(const osgGA::GUIEventAdapter&ea,osgGA::GUIActionAdapter& aa)
- {
- switch(ea.getEventType())
- {
- case osgGA::GUIEventAdapter::KEYDOWN:
- {
- if (ea.getKey()=='w')
- {
- AnimationManagerFinder finder;
- node_walk->accept(finder);
- const osgAnimation::AnimationList& animations = finder._am->getAnimationList();
- finder._am->playAnimation( animations[0].get() );
- osg::AnimationPath* path = CreatePath();
- path->setLoopMode(osg::AnimationPath::NO_LOOPING);
- pat->setUpdateCallback(new osg::AnimationPathCallback(path));
- }
- }
- break;
- default:
- break;
- }
- return false;
- }
复制代码 |
|