osgManipulator.TranslateInPlaneCommand是OpenSceneGraph中的一个命令类,主要用于在平面内进行移动操作。该操作命令实现了拖拽某个物体时,只在一个平面内移动而不改变物体的深度。该命令可以在独立的场景图上进行操作,也可以与其他命令组合使用。
osgManipulator::TranslateInPlaneCommand* cmd = new osgManipulator::TranslateInPlaneCommand(osg::Plane::YX_PLANE);
cmd->setTranslation(osg::Vec3(0.0f, 0.0f, 0.0f));    
cmd->setLocalToWorld(osg::Matrix::identity());
TranslateInPlaneCommand(const osg::Plane& plane);
参数:
osg::Plane& plane - 平面参数。virtual bool execute(const osg::Vec3d& pointer, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
参数:
osg::Vec3d& pointer - 光标点的坐标。osgGA::GUIEventAdapter& ea - 事件适配器。osgGA::GUIActionAdapter& aa - 操作适配器。返回值:
bool - 如果操作成功,则返回true,否则返回false。bool setLocalToWorld(const osg::Matrix& matrix);
参数:
osg::Matrix& matrix - 本地坐标系到世界坐标系变换矩阵。返回值:
bool - 如果成功设置,则返回true,否则返回false。bool setNode(osg::Node* node);
参数:
osg::Node* node - 需要进行移动的场景图节点。返回值:
bool - 如果成功设置,则返回true,否则返回false。bool setTranslation(const osg::Vec3& translation);
参数:
osg::Vec3& translation - 平移向量。返回值:
bool - 如果成功设置,则返回true,否则返回false。