OSG:使用AnimationPathManipulator的摄影机飞行

OSG: Camera flight with AnimationPathManipulator

本文关键字:摄影机 飞行 AnimationPathManipulator 使用 OSG      更新时间:2023-10-16

我正试图通过使用osgGA::AnimationPathManipulator将osg::AnimationPath应用于我的osgViewer::Viewer实例的相机。我的问题是,AnimationPathManipulator只对摄影机应用旋转的更改,而不应用位置的更改。所以它只旋转而不平移。

我使用的是OpenSceneGraph Library 3.0.1。

为了更好地了解,这是我当前的代码:

void CameraFlyTest::animateCamera(osgViewer::Viewer* viewer) {
  osg::AnimationPath* path = new osg::AnimationPath();
  path->setLoopMode(osg::AnimationPath::SWING);
  osg::AnimationPath::ControlPoint cp1;
  cp1.setPosition(osg::Vec3d(-200,-450,60));
  cp1.setRotation(osg::Quat(M_PI_2, osg::Vec3(1,0,0)));
  osg::AnimationPath::ControlPoint cp2;
  cp2.setPosition(osg::Vec3d(2000,-500,60));
  cp2.setRotation(osg::Quat(M_PI_4, osg::Vec3(1,0,0)));
  path->insert(1.0f,cp1);
  path->insert(3.0f,cp2);
  osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(path);
  viewer->setCameraManipulator(apm);
}

问题是另一个活动的摄影机操纵器也更新了摄影机的位置。osgGA::AnimationPathManipulator本身可以正常工作。