我正在尝试使用 osgGA::AnimationPathManipulator 将 osg::AnimationPath 应用于我的 osgViewer::Viewer 实例的相机。我的问题是 AnimationPathManipulator 只对相机应用旋转的变化而没有位置的变化。所以它只旋转但不平移。
我正在使用 OpenSceneGraph 库 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);
}