15 #ifndef OSGMANIPULATOR_DRAGGER
16 #define OSGMANIPULATOR_DRAGGER 1
18 #include <osgManipulator/Constraint>
19 #include <osgManipulator/Command>
21 #include <osg/BoundingSphere>
22 #include <osg/MatrixTransform>
23 #include <osgUtil/SceneView>
24 #include <osgUtil/IntersectVisitor>
25 #include <osgGA/GUIEventAdapter>
26 #include <osgGA/GUIActionAdapter>
31 class CompositeDragger;
33 class TranslateInLineCommand;
34 class TranslateInPlaneCommand;
37 class ScaleUniformCommand;
38 class Rotate3DCommand;
50 HANDLE_TRANSLATE_IN_LINE = 1<<0,
51 HANDLE_TRANSLATE_IN_PLANE = 1<<1,
52 HANDLE_SCALED_1D = 1<<2,
53 HANDLE_SCALED_2D = 1<<3,
54 HANDLE_SCALED_UNIFORM = 1<<4,
55 HANDLE_ROTATE_3D = 1<<5,
56 HANDLE_ALL = 0x8ffffff
91 _hitList(rhs._hitList),
92 _nearPoint(rhs._nearPoint),
93 _farPoint(rhs._farPoint),
96 _hitIter = _hitList.begin();
102 _hitIter = _hitList.begin();
107 bool completed()
const {
return _hitIter==_hitList.end(); }
111 if (!completed()) ++_hitIter;
123 _nearPoint = nearPoint;
125 _eyeDir = farPoint - nearPoint;
131 nearPoint = _nearPoint;
132 farPoint = _farPoint;
135 bool contains(
const osg::Node* node)
const;
144 _inverseMVPW.invert(_MVPW);
147 _eyeDir = eye - center;
152 _MVPW.makeIdentity();
153 _inverseMVPW.makeIdentity();
161 bool needToResetHitIter = _hitList.empty();
162 _hitList.push_back(NodePathIntersectionPair(nodePath, intersectionPoint));
163 if (needToResetHitIter) _hitIter = _hitList.begin();
168 projectWindowXYIntoObject(
osg::Vec2d(pixel_x, pixel_y), _nearPoint, _farPoint);
206 virtual
void setParentDragger(
Dragger* parent) { _parentDragger = parent; }
217 void setHandleEvents(
bool flag);
239 void removeConstraint(
Constraint* constraint);
254 void removeTransformUpdating(MatrixTransform* transform);
312 typedef std::vector< osg::ref_ptr<Dragger> > DraggerList;
317 virtual void setParentDragger(
Dragger* parent);
322 virtual bool addDragger(
Dragger* dragger);
323 virtual bool removeDragger(
Dragger* dragger);
327 bool containsDragger(
const Dragger* dragger)
const;
328 DraggerList::iterator findDragger(
const Dragger* dragger);
bool getHandleEvents() const
void getNearFarPoints(osg::Vec3d &nearPoint, osg::Vec3d &farPoint) const
PointerInfo(const PointerInfo &rhs)
Dragger * getDragger(unsigned int i)
std::pair< osg::NodePath, osg::Vec3d > NodePathIntersectionPair
unsigned int getActivationMouseButtonMask() const
virtual META_Node(osgManipulator, CompositeDragger) typedef std const CompositeDragger * getComposite() const
Vec3f postMult(const Vec3f &v) const
bool _activationPermittedByModKeyMask
osg::Matrixd & getProjectionMatrix()
virtual void setupDefaultGeometry()
osg::ref_ptr< DraggerCallback > _selfUpdater
#define OSGMANIPULATOR_EXPORT
const Constraints & getConstraints() const
bool _activationPermittedByKeyEvent
int getActivationKeyEvent() const
bool getDraggerActive() const
const osg::Matrix computeWindowMatrix() const
virtual CompositeDragger * getComposite()
bool _activationPermittedByMouseButtonMask
DraggerCallbacks & getDraggerCallbacks()
void setActivationModKeyMask(unsigned int mask)
Constraints & getConstraints()
#define META_Node(library, name)
std::vector< osg::ref_ptr< DraggerCallback > > DraggerCallbacks
virtual const CompositeDragger * getComposite() const
virtual bool handle(const PointerInfo &, const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &)
const osg::Vec3d & getEyeDir() const
void setDraggerActive(bool active)
void setMousePosition(float pixel_x, float pixel_y)
unsigned int _activationMouseButtonMask
void setCamera(osg::Camera *camera)
OSGMANIPULATOR_EXPORT void computeNodePathToRoot(osg::Node &node, osg::NodePath &np)
const Viewport * getViewport() const
unsigned int getNumDraggers() const
void getLookAt(Vec3f &eye, Vec3f ¢er, Vec3f &up, value_type lookDistance=1.0f) const
META_Node(osgManipulator, Dragger) virtual void setParentDragger(Dragger *parent)
const Dragger * getDragger(unsigned int i) const
virtual CompositeDragger * getComposite()
unsigned int _activationModKeyMask
void OSGMANIPULATOR_EXPORT setMaterialColor(const osg::Vec4 &color, osg::Node &node)
IntersectionList _hitList
std::list< NodePathIntersectionPair > IntersectionList
void OSGMANIPULATOR_EXPORT setDrawableToAlwaysCull(osg::Drawable &drawable)
osg::Node::NodeMask getIntersectionMask() const
const DraggerCallbacks & getDraggerCallbacks() const
virtual ~CompositeDragger()
const Dragger * getParentDragger() const
osg::Node::NodeMask _intersectionMask
DraggerCallbacks _draggerCallbacks
osgManipulator::PointerInfo _pointer
void setActivationMouseButtonMask(unsigned int mask)
osg::Matrixd & getViewMatrix()
std::vector< osg::ref_ptr< Constraint > > Constraints
void setActivationKeyEvent(int key)
void setNearFarPoints(osg::Vec3d nearPoint, osg::Vec3d farPoint)
virtual void setIntersectionMask(osg::Node::NodeMask intersectionMask)
Dragger * getParentDragger()
std::vector< Node * > NodePath
unsigned int getActivationModKeyMask() const
void addIntersection(const osg::NodePath &nodePath, const osg::Vec3d &intersectionPoint)
osg::Vec3d getLocalIntersectPoint() const
IntersectionList::const_iterator _hitIter