c++ - OSG : Camera flight with AnimationPathManipulator

标签 c++ 3d openscenegraph

我正在尝试通过使用 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);
}

最佳答案

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

关于c++ - OSG : Camera flight with AnimationPathManipulator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17233626/

相关文章:

c++ - 在 C 或 C++ 中获取系统语言

java - 检查轴对齐的边界框是否位于视锥体内

Java 捕获运行时警告/检测显卡

c++ - 在支持 obj 文件的 Linux 上静态编译 osgconv

qt - OSG +QT 切换到全屏和返回

c++ - C++ vector 的 size() 和 capacity()

c++ - 运行时检查失败 #2,同时使用 API 保存图像帧

c++ - 将 C++ 数组写入文件,避免创建 std::string

c++ - 使用旋转矩阵生成 3D 圆柱体

c++ - Qt 4.7 和 4.8 之间的 OpenSceneGraph 性能