Added new TerrainManipulator to osgGA, and new callback for getting the

CoordinateFrame for a given X,Y,Z location.
This commit is contained in:
Robert Osfield
2004-05-06 11:01:16 +00:00
parent 1a09763515
commit 47dd0ece28
12 changed files with 740 additions and 61 deletions

View File

@@ -41,15 +41,34 @@ public:
virtual const char* className() const { return "MatrixManipulator"; }
/** set the coordinate frame which tells the manipulator which way is up, east and north.*/
virtual void setCoordinateFrame(const osg::CoordinateFrame& cf) { _coordinateFrame = cf; }
/** callback class to use to allow matrix manipulators to querry the application for the local coordinate frame.*/
class CoordinateFrameCallback : public osg::Referenced
{
public:
virtual osg::CoordinateFrame getCoordinateFrame(double X, double Y, double Z) const = 0;
protected:
virtual ~CoordinateFrameCallback() {}
};
/** set the coordinate frame which callback tells the manipulator which way is up, east and north.*/
virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb) { _coordinateFrameCallback = cb; }
/** get the coordinate frame callback which tells the manipulator which way is up, east and north.*/
CoordinateFrameCallback* getCoordinateFrameCallback() { return _coordinateFrameCallback.get(); }
/** get the coordinate frame callback which tells the manipulator which way is up, east and north.*/
const CoordinateFrameCallback* getCoordinateFrameCallback() const { return _coordinateFrameCallback.get(); }
/** get the coordinate frame.*/
const osg::CoordinateFrame& getCoordinateFrame() const { return _coordinateFrame; }
osg::CoordinateFrame getCoordinateFrame(double X, double Y, double Z) const
{
if (_coordinateFrameCallback.valid()) return _coordinateFrameCallback->getCoordinateFrame(X,Y,Z);
return osg::CoordinateFrame();
}
osg::Vec3 getSideVector() const { return osg::Vec3(_coordinateFrame(0,0),_coordinateFrame(1,0),_coordinateFrame(2,0)); }
osg::Vec3 getFromVector() const { return osg::Vec3(_coordinateFrame(0,1),_coordinateFrame(1,1),_coordinateFrame(2,1)); }
osg::Vec3 getUpVector() const { return osg::Vec3(_coordinateFrame(0,2),_coordinateFrame(1,2),_coordinateFrame(2,2)); }
osg::Vec3 getSideVector(const osg::CoordinateFrame& cf) const { return osg::Vec3(cf(0,0),cf(0,1),cf(0,2)); }
osg::Vec3 getFrontVector(const osg::CoordinateFrame& cf) const { return osg::Vec3(cf(1,0),cf(1,1),cf(1,2)); }
osg::Vec3 getUpVector(const osg::CoordinateFrame& cf) const { return osg::Vec3(cf(2,0),cf(2,1),cf(2,2)); }
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
virtual void setByMatrix(const osg::Matrixd& matrix) = 0;
@@ -106,7 +125,7 @@ protected:
MatrixManipulator();
virtual ~MatrixManipulator();
osg::CoordinateFrame _coordinateFrame;
osg::ref_ptr<CoordinateFrameCallback> _coordinateFrameCallback;
};
}