Made the computeLocalToWorld etc method to use const NodePath's parameters.

This commit is contained in:
Robert Osfield
2004-09-09 15:14:33 +00:00
parent 6a48a3ffe7
commit 790da0776a
5 changed files with 82 additions and 52 deletions

View File

@@ -37,6 +37,27 @@ class RefNodePath : public NodeList
}
}
RefNodePath& operator = (const RefNodePath& rhs)
{
if (&rhs == this) return *this;
NodeList::operator = (rhs);
return *this;
}
RefNodePath& operator = (const NodePath& rhs)
{
for(osg::NodePath::const_iterator itr=rhs.begin();
itr != rhs.end();
++itr)
{
push_back(*itr);
}
return *this;
}
inline operator NodePath () const
{
NodePath nodePath;

View File

@@ -27,21 +27,21 @@ namespace osg {
/** compute the matrix which transforms objects in local coords to world coords,
* by accumulating the Transform local to world matrices along the specified node path.*/
extern SG_EXPORT Matrix computeLocalToWorld(NodePath& nodePath);
extern SG_EXPORT Matrix computeLocalToWorld(const NodePath& nodePath);
/** compute the matrix which transforms objects in world coords to local coords,
* by accumulating the Transform world to local matrices along the specified node path.*/
extern SG_EXPORT Matrix computeWorldToLocal(NodePath& nodePath);
extern SG_EXPORT Matrix computeWorldToLocal(const NodePath& nodePath);
/** compute the matrix which transforms objects in local coords to world coords,
* by accumulating the Transform local to world matrices along the specified node path
* the supplied initialial camera modelview .*/
extern SG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, NodePath& nodePath);
extern SG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, const NodePath& nodePath);
/** compute the matrix which transforms objects in world coords to local coords,
* by accumulating the Transform world to local matrices along the specified node path
* the inverse of the supplied initialial camera modelview.*/
extern SG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, NodePath& nodePath);
extern SG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, const NodePath& nodePath);
/** A Transform is a group node for which all children are transformed by

View File

@@ -15,7 +15,9 @@
#define OSGGA_NODETRACKERMANIPULATOR 1
#include <osgGA/MatrixManipulator>
#include <osg/Quat>
#include <osg/RefNodePath>
namespace osgGA{
@@ -27,10 +29,15 @@ class OSGGA_EXPORT NodeTrackerManipulator : public MatrixManipulator
virtual const char* className() const { return "NodeTrackerManipulator"; }
void setTrackNode(osg::Node* node) { _trackNode = node; }
osg::Node* getTrackNode() { return _trackNode.get(); }
const osg::Node* getTrackNode() const { return _trackNode.get(); }
void setTrackNodePath(const osg::RefNodePath& nodePath) { _trackNodePath = nodePath; }
void setTrackNodePath(const osg::NodePath& nodePath) { _trackNodePath = nodePath; }
osg::RefNodePath& getTrackNodePath() { return _trackNodePath; }
const osg::RefNodePath& getTrackNodePath() const { return _trackNodePath; }
void setTrackNode(osg::Node* node);
osg::Node* getTrackNode() { return _trackNodePath.empty() ? 0 : _trackNodePath.back().get(); }
const osg::Node* getTrackNode() const { return _trackNodePath.empty() ? 0 : _trackNodePath.back().get(); }
enum TrackerMode
{
@@ -99,6 +106,21 @@ class OSGGA_EXPORT NodeTrackerManipulator : public MatrixManipulator
protected:
virtual ~NodeTrackerManipulator();
inline bool validateNodePath() const
{
if (!_trackNodePath.valid())
{
if (_trackNodePath.empty())
{
osg::notify(osg::NOTICE)<<"Warning: tracked node path has been invalidated by changes in the scene graph."<<std::endl;
NodeTrackerManipulator* non_const_this = const_cast<NodeTrackerManipulator*>(this);
non_const_this->_trackNodePath.clear();
}
return false;
}
return true;
}
/** Reset the internal GUIEvent stack.*/
void flushMouseEventStack();
@@ -133,7 +155,8 @@ class OSGGA_EXPORT NodeTrackerManipulator : public MatrixManipulator
osg::ref_ptr<const GUIEventAdapter> _ga_t0;
osg::ref_ptr<osg::Node> _node;
osg::ref_ptr<osg::Node> _trackNode;
osg::RefNodePath _trackNodePath;
TrackerMode _trackerMode;
RotationMode _rotationMode;