|
您书中的路径动画控制的例子中,路径控制ok,但是键盘控制(pause,start,reset)没有反应。求解释
- class AnimationEventHandler:public osgGA::GUIEventHandler
- {
- public:
- AnimationEventHandler(osgViewer::Viewer &vr):viewer(vr){}
- virtual bool handler(const osgGA::GUIEventAdapter&ea,osgGA::GUIActionAdapter&aa)
- {
- osg::AnimationPathCallback *animationPathCallback=new osg::AnimationPathCallback();
- osg::Group*group=dynamic_cast<osg::Group *>(viewer.getSceneData());
- animationPathCallback=dynamic_cast<osg::AnimationPathCallback*>(group->getChild(0)->getUpdateCallback());
- switch(ea.getEventType ())
- {
- case(osgGA::GUIEventAdapter ::KEYDOWN ):
- {
- if (ea.getKey ()=='p')
- {
- animationPathCallback->setPause (true);
- return true;
- }
- if (ea.getKey ()=='s')
- {
- animationPathCallback->setPause (false);
- return true;
- }
- if (ea.getKey ()=='r')
- {
- animationPathCallback->reset ();
- return true;
- }
- break;
- }
- default:break;
- }
- return false;
- }
- osgViewer::Viewer&viewer;
- };
复制代码 |
|