参考资料:OpenSceneGraph Documentation
osgManipulator.PointerInfo类包含了一些必要的信息,可以让用户来交互式地操纵相机、物体,场景等。
// osgManipulator/PointerInfo
class PointerInfo : public Object
{
public:
typedef Object base_class;
typedef osg::ref_ptr<PointerInfo> PointerInfoRefPtr;
enum DrillPickResult {
DRILL_HIT_NOTHING,
DRILL_HIT_WORLD,
DRILL_HIT_OBJECT
};
enum IntersectionType {
// The pointer's ray hit geometry, and no selected axis or plane was provided.
POINT_INTERSECTED,
NORMAL_INTERSECTED,
// The pointer's ray did not hit any geometry.
NOTHING_INTERSECTED,
// The pointer hit an axis or plane, and no further intersection testing should be performed.
HANDLE_INTERSECTED
};
PointerInfo();
PointerInfo(const PointerInfo& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
/** Get a new pointer info object, with the same reference frame as this object. */
PointerInfo getNewPointerInfo() const;
/** Reset the pointer info object to it's original paramters.*/
void reset();
void setCamera(const osg::Camera* camera) { _camera = camera; }
const osg::Camera* getCamera() const { return _camera; }
void setCameraViewMatrix(const osg::Matrixd& viewMatrix) { _cameraViewMatrix = viewMatrix; }
const osg::Matrixd& getCameraViewMatrix() const { return _cameraViewMatrix; }
void setCameraProjectionMatrix(const osg::Matrixd& projectionMatrix) { _cameraProjectionMatrix = projectionMatrix; }
const osg::Matrixd& getCameraProjectionMatrix() const { return _cameraProjectionMatrix; }
void setCameraModelMatrix(const osg::Matrixd& modelMatrix) { _cameraModelMatrix = modelMatrix; }
const osg::Matrixd& getCameraModelMatrix() const { return _cameraModelMatrix; }
void setCameraPosition(const osg::Vec3d& position) { _cameraPosition = position; }
const osg::Vec3d& getCameraPosition() const { return _cameraPosition; }
void setCanvasViewport(const osg::Viewport* viewport) { _canvasViewport = viewport; }
const osg::Viewport* getCanvasViewport() const { return _canvasViewport; }
void setCanvasPixelSize(const osg::Vec2d& pixelSize) { _canvasPixelSize = pixelSize; }
const osg::Vec2d& getCanvasPixelSize() const { return _canvasPixelSize; }
void setLocalToWorld(const osg::Matrixd& matrix) { _localToWorld = matrix; }
const osg::Matrixd& getLocalToWorld() const { return _localToWorld; }
void setLineStart(const osg::Vec3d& lineStart) { _lineStart = lineStart; }
const osg::Vec3d& getLineStart() const { return _lineStart; }
void setLineEnd(const osg::Vec3d& lineEnd) { _lineEnd = lineEnd; }
const osg::Vec3d& getLineEnd() const { return _lineEnd; }
void setMousePosition(const osg::Vec2& mousePosition) { _mousePosition = mousePosition; }
const osg::Vec2& getMousePosition() const { return _mousePosition; }
void setWorldPt(const osg::Vec3d& worldPt) { _worldPt = worldPt; }
const osg::Vec3d& getWorldPt() const { return _worldPt; }
void setNodePath(const osg::NodePath& nodePath) { _nodePath = nodePath; }
const osg::NodePath& getNodePath() const { return _nodePath; }
void setPinchPoints(const osg::Vec2s& pinchPoints) { _pinchPoints = pinchPoints; }
const osg::Vec2s& getPinchPoints() const { return _pinchPoints; }
void setRadius(float radius) { _radius = radius; }
float getRadius() const { return _radius; }
/** Set the currently selected axis or plane representing the currently
activated axis or plane handle. */
void setHandleAxis(osgManipulator::Selection::Axis axis) { _handleAxis = axis; }
osgManipulator::Selection::Axis getHandleAxis() const { return _handleAxis; }
/** Set the currently selected axis or plane representing the currently
activated axis or plane handle. */
void setHandlePlane(osgManipulator::Selection::Plane plane) { _handlePlane = plane; }
osgManipulator::Selection::Plane getHandlePlane() const { return _handlePlane; }
/** Set the number of intersections to be found in the RayIntersector. */
void setIntersectionLimit(unsigned int intersectionLimit) { _intersectionLimit = intersectionLimit; }
/** Get the number of intersections to be found in the RayIntersector. */
unsigned int getIntersectionLimit() const { return _intersectionLimit; }
/** Set the minimum distance from the pointer that to consider for intersection. */
void setMinIntersectionDistance(double distance) { _minIntersectionDistance = distance; }
/** Get the minimum distance from the pointer that to consider for intersection. */
double getMinIntersectionDistance() const { return _minIntersectionDistance; }
/** Set the object that is currently being manipulated. */
void setNode(osg::Node* node){ _node = node; }
/** Get the object that is currently being manipulated. */
osg::Node* getNode() { return _node.get(); }
/** Get the object that is currently being manipulated. */
const osg::Node* getNode() const { return _node.get(); }
/** Set the picked intersection point. */
void setPickIntersection(const osg::Vec3d& pickIntersection) { _pickIntersection = pickIntersection; }
/** Get the picked intersection point. */
const osg::Vec3d& getPickIntersection() const { return _pickIntersection; }
/** Set the drill pick result. */
void setDrillPickResult(DrillPickResult dp) { _drillPickResult = dp; }
/** Get the drill pick result. */
DrillPickResult getDrillPickResult() const { return _drillPickResult; }
void setIntersectionType(IntersectionType type) { _intersectionType = type; }
IntersectionType getIntersectionType() const { return _intersectionType; }
void setButtonMask(unsigned int mask) { _buttonMask = mask; }
unsigned int getButtonMask() const { return _buttonMask; }
void setActionButtonMask(unsigned int mask) { _actionButtonMask = mask; }
unsigned int getActionButtonMask() const { return _actionButtonMask; }
void setModKeyMask(unsigned int mask) { _modKeyMask = mask; }
unsigned int getModKeyMask() const { return _modKeyMask; }
void setPickCandidate(osgManipulator::Dragger* candidate) { _pickCandidate = candidate; }
osgManipulator::Dragger* getPickCandidate() const { return _pickCandidate; }
void setPointer(osgManipulator::PointerData* pointer) { _pointer = pointer; }
osgManipulator::PointerData* getPointer() { return _pointer.get(); }
const osgManipulator::PointerData* getPointer() const { return _pointer.get(); }
protected:
osg::Matrixd _cameraViewMatrix;
osg::Matrixd _cameraProjectionMatrix;
osg::Matrixd _cameraModelMatrix;
osg::Vec3d _cameraPosition;
osg::ref_ptr<const osg::Camera> _camera;
osg::ref_ptr<const osg::Viewport> _canvasViewport;
osg::Vec2d _canvasPixelSize;
osg::Matrixd _localToWorld;
osg::Vec3d _lineStart;
osg::Vec3d _lineEnd;
osg::Vec2 _mousePosition;
osg::Vec3d _worldPt;
unsigned int _buttonMask;
unsigned int _actionButtonMask;
unsigned int _modKeyMask;
osg::Vec2s _pinchPoints;
osg::ref_ptr<osgManipulator::PointerData> _pointer;
osg::NodePath _nodePath;
float _radius;
osgManipulator::Selection::Axis _handleAxis;
osgManipulator::Selection::Plane _handlePlane;
osg::ref_ptr<osg::Node> _node;
osg::Vec3d _pickIntersection;
DrillPickResult _drillPickResult;
IntersectionType _intersectionType;
unsigned int _intersectionLimit;
double _minIntersectionDistance;
osgManipulator::Dragger* _pickCandidate;
};
变量 | 描述 |
---|---|
_cameraViewMatrix | 相机在视图坐标系中的矩阵。 |
_cameraProjectionMatrix | 相机在投影坐标系中的矩阵。 |
_cameraModelMatrix | 相机在相机坐标系中的矩阵。 |
_cameraPosition | 相机在世界坐标系中的位置。 |
_camera | 存放渲染状态的相机。 |
_canvasViewport | 目标canvas的视口。 |
_canvasPixelSize | 目标canvas的像素大小。 |
_localToWorld | 当前点选的坐标系到世界坐标系的变换矩阵。 |
_lineStart | 当前点选的直线的起始位置坐标。 |
_lineEnd | 当前点选的直线的终止位置坐标。 |
_mousePosition | 鼠标在canvas上的坐标。 |
_worldPt | 世界坐标系中的交点位置。 |
_buttonMask | 存放当前键盘键位。 |
_actionButtonMask | 存放当前鼠标键位。 |
_modKeyMask | 存放当前键盘修饰键位。 |
_pinchPoints | 处理触屏时当前的注册点。 |
_pointer | osgManipulator::PointerData指针。 |
_nodePath | 点选节点的路径。 |
_radius | 相交的半径大小。 |
_handleAxis | 活动的轴或平面的枚举类型。 |
_handlePlane | 活动的轴或平面的枚举类型。 |
_node | 当前操作的节点。 |
_pickIntersection | 相交点,当没有被击中时,可以用于重新计算交集。 |
_drillPickResult | 一个枚举类型,表示碰撞结果。 |
_intersectionType | 活动选择器的当前起始点的类型(例如鼠标或光标的位置是否在选择器上)。 |
_intersectionLimit | 确定是否启用了更多的交叉测试。 |
_minIntersectionDistance | 交点范围距离最小值。 |
_pickCandidate | 存储当前正在拖动的拖动器。 |
类名 | 描述 |
---|---|
osgManipulator::PointerInfo::DrillPickResult |
点选结果枚举类型。 |
osgManipulator::PointerInfo::IntersectionType |
交点类型枚举类型。 |
osgManipulator::PointerInfo::PointerInfoRefPtr |
osgManipulator.PointerInfo的引用计数智能指针。 |
PointerInfo()
PointerInfo(const PointerInfo& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY)
PointerInfo getNewPointerInfo() const
void reset()
void setCamera(const osg::Camera* camera)
const osg::Camera* getCamera() const
void setCameraViewMatrix(const osg::Matrixd& viewMatrix)
const osg::Matrixd& getCameraViewMatrix() const
void setCameraProjectionMatrix(const osg::Matrixd& projectionMatrix)
const osg::Matrixd& getCameraProjectionMatrix() const
void setCameraModelMatrix(const osg::Matrixd& modelMatrix)
const osg::Matrixd& getCameraModelMatrix() const
void setCameraPosition(const osg::Vec3d& position)
const osg::Vec3d& getCameraPosition() const
void setCanvasViewport(const osg::Viewport* viewport)
const osg::Viewport* getCanvasViewport() const
void setCanvasPixelSize(const osg::Vec2d& pixelSize)
const osg::Vec2d& getCanvasPixelSize() const
void setLocalToWorld(const osg::Matrixd& matrix)
const osg::Matrixd& getLocalToWorld() const
void setLineStart(const osg::Vec3d& lineStart)
const osg::Vec3d& getLineStart() const
void setLineEnd(const osg::Vec3d& lineEnd)
const osg::Vec3d& getLineEnd() const
void setMousePosition(const osg::Vec2& mousePosition)
const osg::Vec2& getMousePosition() const
void setWorldPt(const osg::Vec3d& worldPt)
const osg::Vec3d& getWorldPt() const
void setNode