|
代码如下- osg::ref_ptr<osg::Camera> camera = new osg::Camera;
- osg::Vec3 eye(2.0,2.0,2.0);
- osg::Vec3 center(0,0,0);
- osg::Vec3 up(0.0,1.0,0.0);
-
- camera->setViewMatrixAsLookAt(eye,center,up);
- camera->setProjectionMatrixAsPerspective(100.0,2.0,4.0,10.0);
-
-
-
- CameraEventCallBack* ecb = new CameraEventCallBack; //相机的时间回调类,当点击鼠标会打印出相机的eye,center,up 的值
- osgViewer::Viewer viewer;
- viewer.setSceneData(trian.get());
- viewer.setCamera(camera);
-
- viewer.setCameraManipulator(NULL);
- viewer.getCamera()->setEventCallback(ecb);
-
- while(!viewer.done())
- {
- viewer.setCameraManipulator(NULL);
- viewer.frame();
- }
复制代码 用上面的代码运行,打印相机的eye,center以及up参数的值时,只有eye的值是和初始化值一致,center和up的值均被改动,不知道什么原因。 |
|