The problem was that another active camera manipulator has also updated the position of the camera. The osgGA::AnimationPathManipulator itself works as it should.
OSG: Camera flight with AnimationPathManipulator
-
01-06-2022 - |
Pergunta
I'm trying to apply an osg::AnimationPath to the camera of my osgViewer::Viewer instance by using an osgGA::AnimationPathManipulator. My problem is that the AnimationPathManipulator only applies the change of rotation and no change of position to the camera. So it only rotates but doesn't translate.
I am using OpenSceneGraph Library 3.0.1.
For a better insight, this is my current code:
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);
}
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow