2013-06-21 133 views
1

我想通過使用osgGA :: AnimationPathManipulator將osg :: AnimationPath應用到我的osgViewer :: Viewer實例的攝像機。我的問題是,AnimationPathManipulator只適用於旋轉的變化,而不會改變相機的位置。所以它只能旋轉但不翻譯。OSG:使用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); 
} 

回答

1

問題是另一個積極的相機操縱也更新了攝像頭的位置。 osgGA :: AnimationPathManipulator本身就像它應該那樣工作。

相關問題