|
我想把自己写的关于摄像机的控制类结合array写的osgActiveX结合到一起,发现有问题,下面我把我的部分代码贴出来,望大家指点指点
这个是array调用我的地方,最后一句就是我自己写的类,当然参照了一些教程
-
- // Create viewer
- m_Viewer = new osgViewer::Viewer;
- m_Viewer->setThreadingModel( osgViewer::Viewer::SingleThreaded );
- m_Viewer->setCamera( camera.get() );
- m_Viewer->setCameraWithFocus(camera.get());
- m_Viewer->setCameraManipulator( new osgGA::TrackballManipulator );
- CTravelManipulator::TravelToScene(m_Viewer);
复制代码
下面是我对这个CTravelManipulator的实现
-
- class CTravelManipulator : public osgGA::MatrixManipulator
- {
- public:
- CTravelManipulator();
- CTravelManipulator(Vec3& position);
- ~CTravelManipulator();
- static CTravelManipulator* TravelToScene(ref_ptr<osgViewer::Viewer> viewer);
- virtual void setByMatrix(const osg::Matrixd& matrix);
- virtual void setByInverseMatrix(const osg::Matrixd& matrix);
- virtual osg::Matrixd getMatrix(void) const;
- virtual osg::Matrixd getInverseMatrix(void)const;
- virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
- private:
- osg::ref_ptr<osgViewer::Viewer> m_pHostViewer; // 用来检测碰撞测试
- ...
- ...
- };
-
- // 对接口的实现
- CTravelManipulator* CTravelManipulator::TravelToScene(ref_ptr<osgViewer::Viewer> viewer)
- {
- CTravelManipulator* camera = new CTravelManipulator;
- viewer->setCameraManipulator(camera);
-
- viewer->getCamera()->setViewMatrixAsLookAt(camera->m_vPosition, Vec3(0,0,100), Vec3(0,0,0));
- camera->m_pHostViewer = viewer;
- return camera;
- }
复制代码
以上就是大致的一个框架,在网页中或者在调试时,多不能正确的显示 |
|