osgGA.StateSetManipulator是一种osgGA::CameraManipulator,在场景中移动相机并控制场景中的状态集合。它提供了一些功能,例如切换深度测试、多边形模式、填充模式等。
osgGA::CameraManipulator
osgViewer::Viewer viewer;
osg::ref_ptr<osgGA::StateSetManipulator> manipulator = new osgGA::StateSetManipulator();
manipulator->setStateSet(scene->getOrCreateStateSet());
viewer.setCameraManipulator(manipulator);
在这个示例中,我们创建了一个osgGA::StateSetManipulator,并将场景中的状态集合与它关联。然后,我们将它设置为查看器的相机操纵器。
以下是该类的公共成员函数:
StateSetManipulator()构造函数。
StateSetManipulator(osg::StateSet* stateset)构造函数,将指定的状态集合与操纵器关联。
StateSetManipulator(const StateSetManipulator& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)拷贝构造函数。
virtual const char* className() const获取类的名称。
void setNode(osg::Node* node)设置要控制状态集合的场景节点。
osg::Node* getNode() const获取要控制状态集合的场景节点。
void setStateSet(osg::StateSet* stateset)设置用于控制场景的状态集合。
osg::StateSet* getStateSet() const获取当前使用的状态集合。
void setVerticalAxisFixed(bool value)设置是否固定垂直轴。
bool getVerticalAxisFixed() const获取是否固定垂直轴。
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)处理输入事件。
void setTransformation(osg::Matrix matrix)设置相机的变换矩阵。
osg::Matrixd getTransformation() const获取相机的变换矩阵。
virtual void setByMatrix(const osg::Matrixd& matrix)根据给定的矩阵设置相机的变换矩阵。
virtual void setByInverseMatrix(const osg::Matrixd& matrix)根据给定的矩阵的逆矩阵设置相机的变换矩阵。
virtual osg::Matrixd getMatrix() const获取相机的变换矩阵。
virtual osg::Matrixd getInverseMatrix() const获取相机的变换矩阵的逆矩阵。
osg::ref_ptr<osgGA::GUIEventAdapter> getGUIEventAdapter(osgGA::GUIActionAdapter& aa)获取GUI事件适配器。
osg::ref_ptr<const osgGA::GUIEventAdapter> getGUIEventAdapter(const osgGA::GUIActionAdapter& aa) const获取GUI事件适配器。
void setCoordinateFrameCallback(osg::CoordinateFrameCallback* cb)设置坐标帧回调函数。
osg::CoordinateFrameCallback* getCoordinateFrameCallback()获取坐标帧回调函数。
osgGA::StateSetManipulator实现了osgGA::CameraManipulator的所有虚函数并添加了一些额外的功能。它可以通过输入设备(例如鼠标、键盘)来控制场景中的状态集合。一些常用的状态集合控制包括切换深度测试、多边形模式、填充模式等。osgGA::StateSetManipulator还可以用于实现鼠标缩放和平移功能,并支持相机的固定垂直轴选项。
该类可以与osgGA::TrackballManipulator一起使用,以提供更多的相机控制功能。它还可以与osgViewer::Viewer一起使用,以实现相机控制和事件处理功能。