我正在尝试使用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);
}
答案 0 :(得分:2)
问题在于另一个主动相机操纵器也更新了相机的位置。 osgGA :: AnimationPathManipulator本身可以正常工作。