|
发表于 2013-1-6 12:43:31
|
显示全部楼层
有一个办法你可以尝试用一下:- class CameraManipulatorProxy :public osgGA::CameraManipulator
- {
- public:
- CameraManipulatorProxy(osgGA::CameraManipulator *manipulator)
- _manipulator(manipulator){}
-
- //...
- void setByMatrix(const osg::Matrixd & matrix);
- void setByInverseMatrix(const osg::Matrixd & matrix);
- osg::Matrixd getMatrix()const;
- osg::Matrixd getInverseMatrix()const;
- void doFilter(osg::Vec3d & eye,osg::Vec3d ¢er,osg::Vec3d &up);
- //...
- private:
- osg::ref_ptr<osgGA::CameraManipulator> _manipulator;
- };
- void CameraManipulatorProxy::setByMatrix(const osg::Matrixd & matrix)
- {
- //
- osg::Vecd3 eye,center,up;
-
- osg::Matirxd mat;
- matrix->getLookAt(&eye,¢er,&up);
- doFilter(eye,center,up);
-
- mat.makeLookAt(eye,center,up);
- _manipulator->setByMatrix(mat);
- }
- void CameraManipulatorProxy::setByInverseMatrix(const osg::Matrixd & matrix)
- {
- //
- osg::Vecd3 eye,center,up;
- osg::Matirxd matinv,mat,mat_result;
- matinv = osg::Matrixd::inverse(matrix);
- matinv->getLookAt(&eye,¢er,&up);
- doFilter(eye,center,up);
- mat_result.makeLookAt(eye,center,up);
- _manipulator->setByMatrix(mat_result);
- }
- osg::Matrixd CameraManipulatorProxy::getMatrix()const
- {
- return _manipulator->getMatrix();
- }
- osg::Matrixd CameraManipulatorProxy::getInverseMatrix()const
- {
- return _namipulator->getInverseMatrix();
- }
- void doFilter(osg::Vec3d & eye,osg::Vec3d ¢er,osg::Vec3d &up)
- {
- //在这里做你自己想要的过滤
- }
复制代码 |
|