1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGGA_NODE_TRACKER_MANIPULATOR
15#define OSGGA_NODE_TRACKER_MANIPULATOR 1
17#include <osgGA/OrbitManipulator>
18#include <osg/ObserverNodePath>
24class OSGGA_EXPORT NodeTrackerManipulator : public OrbitManipulator
26 typedef OrbitManipulator inherited;
30 NodeTrackerManipulator( int flags = DEFAULT_SETTINGS );
32 NodeTrackerManipulator( const NodeTrackerManipulator& om,
33 const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
35 META_Object( osgGA, NodeTrackerManipulator );
37 void setTrackNodePath(const osg::NodePath& nodePath);
38 void setTrackNodePath(const osg::ObserverNodePath& nodePath) { _trackNodePath = nodePath; }
39 osg::ObserverNodePath& getTrackNodePath() { return _trackNodePath; }
41 void setTrackNode(osg::Node* node);
42 osg::Node* getTrackNode() { osg::NodePath nodePath; return _trackNodePath.getNodePath(nodePath) && !nodePath.empty() ? nodePath.back() : 0; }
43 const osg::Node* getTrackNode() const { osg::NodePath nodePath; return _trackNodePath.getNodePath(nodePath) && !nodePath.empty() ? nodePath.back() : 0; }
47 /** Track the center of the node's bounding sphere, but not rotations of the node.
48 * For databases which have a CoordinateSystemNode, the orientation is kept relative the coordinate frame if the center of the node.
51 /** Track the center of the node's bounding sphere, and the azimuth rotation (about the z axis of the current coordinate frame).
52 * For databases which have a CoordinateSystemNode, the orientation is kept relative the coordinate frame if the center of the node.
55 /** Tack the center of the node's bounding sphere, and the all rotations of the node.
57 NODE_CENTER_AND_ROTATION
60 void setTrackerMode(TrackerMode mode);
61 TrackerMode getTrackerMode() const { return _trackerMode; }
66 /** Use a trackball style manipulation of the view direction w.r.t the tracked orientation.
69 /** Allow the elevation and azimuth angles to be adjust w.r.t the tracked orientation.
74 void setRotationMode(RotationMode mode);
75 RotationMode getRotationMode() const;
78 virtual void setByMatrix(const osg::Matrixd& matrix);
79 virtual osg::Matrixd getMatrix() const;
80 virtual osg::Matrixd getInverseMatrix() const;
82 virtual void setNode(osg::Node*);
84 virtual void computeHomePosition();
88 virtual bool performMovementLeftMouseButton(const double eventTimeDelta, const double dx, const double dy);
89 virtual bool performMovementMiddleMouseButton(const double eventTimeDelta, const double dx, const double dy);
90 virtual bool performMovementRightMouseButton(const double eventTimeDelta, const double dx, const double dy);
92 void computeNodeWorldToLocal(osg::Matrixd& worldToLocal) const;
93 void computeNodeLocalToWorld(osg::Matrixd& localToWorld) const;
95 void computeNodeCenterAndRotation(osg::Vec3d& center, osg::Quat& rotation) const;
97 void computePosition(const osg::Vec3d& eye,const osg::Vec3d& lv,const osg::Vec3d& up);
100 osg::ObserverNodePath _trackNodePath;
101 TrackerMode _trackerMode;
107#endif /* OSGGA_NODE_TRACKER_MANIPULATOR */