Remamed TrackerManipulator to NodeTrackerManipulator
This commit is contained in:
parent
0724243959
commit
146f4cd573
@ -143,7 +143,7 @@ SOURCE=..\..\src\osgGA\TrackballManipulator.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\src\osgGA\TrackerManipulator.cpp
|
SOURCE=..\..\src\osgGA\NodeTrackerManipulator.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ SOURCE=..\..\Include\osgGA\TrackballManipulator
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Include\osgGA\TrackerManipulator
|
SOURCE=..\..\Include\osgGA\NodeTrackerManipulator
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <osgParticle/FireEffect>
|
#include <osgParticle/FireEffect>
|
||||||
#include <osgParticle/ParticleSystemUpdater>
|
#include <osgParticle/ParticleSystemUpdater>
|
||||||
|
|
||||||
#include <osgGA/TrackerManipulator>
|
#include <osgGA/NodeTrackerManipulator>
|
||||||
|
|
||||||
// for the grid data..
|
// for the grid data..
|
||||||
#include "../osghangglide/terrain_coords.h"
|
#include "../osghangglide/terrain_coords.h"
|
||||||
@ -331,7 +331,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!fnnv._foundNodes.empty())
|
if (!fnnv._foundNodes.empty())
|
||||||
{
|
{
|
||||||
osgGA::TrackerManipulator* tm = new osgGA::TrackerManipulator;
|
osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator;
|
||||||
tm->setTrackNode(fnnv._foundNodes[0].get());
|
tm->setTrackNode(fnnv._foundNodes[0].get());
|
||||||
|
|
||||||
std::cout<<"Found "<<std::endl;
|
std::cout<<"Found "<<std::endl;
|
||||||
|
@ -11,21 +11,21 @@
|
|||||||
* OpenSceneGraph Public License for more details.
|
* OpenSceneGraph Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OSGGA_TrackerMANIPULATOR
|
#ifndef OSGGA_NODETRACKERMANIPULATOR
|
||||||
#define OSGGA_TrackerMANIPULATOR 1
|
#define OSGGA_NODETRACKERMANIPULATOR 1
|
||||||
|
|
||||||
#include <osgGA/MatrixManipulator>
|
#include <osgGA/MatrixManipulator>
|
||||||
#include <osg/Quat>
|
#include <osg/Quat>
|
||||||
|
|
||||||
namespace osgGA{
|
namespace osgGA{
|
||||||
|
|
||||||
class OSGGA_EXPORT TrackerManipulator : public MatrixManipulator
|
class OSGGA_EXPORT NodeTrackerManipulator : public MatrixManipulator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TrackerManipulator();
|
NodeTrackerManipulator();
|
||||||
|
|
||||||
virtual const char* className() const { return "Tracker"; }
|
virtual const char* className() const { return "NodeTrackerManipulator"; }
|
||||||
|
|
||||||
void setTrackNode(osg::Node* node) { _trackNode = node; }
|
void setTrackNode(osg::Node* node) { _trackNode = node; }
|
||||||
osg::Node* getTrackNode() { return _trackNode.get(); }
|
osg::Node* getTrackNode() { return _trackNode.get(); }
|
||||||
@ -87,7 +87,7 @@ class OSGGA_EXPORT TrackerManipulator : public MatrixManipulator
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~TrackerManipulator();
|
virtual ~NodeTrackerManipulator();
|
||||||
|
|
||||||
/** Reset the internal GUIEvent stack.*/
|
/** Reset the internal GUIEvent stack.*/
|
||||||
void flushMouseEventStack();
|
void flushMouseEventStack();
|
@ -14,7 +14,7 @@ CXXFILES = \
|
|||||||
SetSceneViewVisitor.cpp\
|
SetSceneViewVisitor.cpp\
|
||||||
StateSetManipulator.cpp\
|
StateSetManipulator.cpp\
|
||||||
TerrainManipulator.cpp\
|
TerrainManipulator.cpp\
|
||||||
TrackerManipulator.cpp\
|
NodeTrackerManipulator.cpp\
|
||||||
TrackballManipulator.cpp\
|
TrackballManipulator.cpp\
|
||||||
Version.cpp\
|
Version.cpp\
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <osgGA/TrackerManipulator>
|
#include <osgGA/NodeTrackerManipulator>
|
||||||
#include <osg/Quat>
|
#include <osg/Quat>
|
||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
#include <osg/Transform>
|
#include <osg/Transform>
|
||||||
@ -28,7 +28,7 @@ public:
|
|||||||
NodePathList _nodePaths;
|
NodePathList _nodePaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
TrackerManipulator::TrackerManipulator()
|
NodeTrackerManipulator::NodeTrackerManipulator()
|
||||||
{
|
{
|
||||||
_rotationMode =ELEVATION_AZIM;
|
_rotationMode =ELEVATION_AZIM;
|
||||||
_distance = 1.0;
|
_distance = 1.0;
|
||||||
@ -38,19 +38,19 @@ TrackerManipulator::TrackerManipulator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TrackerManipulator::~TrackerManipulator()
|
NodeTrackerManipulator::~NodeTrackerManipulator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackerManipulator::setRotationMode(RotationMode mode)
|
void NodeTrackerManipulator::setRotationMode(RotationMode mode)
|
||||||
{
|
{
|
||||||
_rotationMode = mode;
|
_rotationMode = mode;
|
||||||
|
|
||||||
// need to correct rotation.
|
// need to correct rotation.
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerManipulator::setNode(osg::Node* node)
|
void NodeTrackerManipulator::setNode(osg::Node* node)
|
||||||
{
|
{
|
||||||
_node = node;
|
_node = node;
|
||||||
|
|
||||||
@ -68,19 +68,19 @@ void TrackerManipulator::setNode(osg::Node* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const osg::Node* TrackerManipulator::getNode() const
|
const osg::Node* NodeTrackerManipulator::getNode() const
|
||||||
{
|
{
|
||||||
return _node.get();
|
return _node.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
osg::Node* TrackerManipulator::getNode()
|
osg::Node* NodeTrackerManipulator::getNode()
|
||||||
{
|
{
|
||||||
return _node.get();
|
return _node.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackerManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us)
|
void NodeTrackerManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us)
|
||||||
{
|
{
|
||||||
if (getAutoComputeHomePosition()) computeHomePosition();
|
if (getAutoComputeHomePosition()) computeHomePosition();
|
||||||
|
|
||||||
@ -89,20 +89,20 @@ void TrackerManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackerManipulator::init(const GUIEventAdapter& ,GUIActionAdapter& )
|
void NodeTrackerManipulator::init(const GUIEventAdapter& ,GUIActionAdapter& )
|
||||||
{
|
{
|
||||||
flushMouseEventStack();
|
flushMouseEventStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackerManipulator::getUsage(osg::ApplicationUsage& usage) const
|
void NodeTrackerManipulator::getUsage(osg::ApplicationUsage& usage) const
|
||||||
{
|
{
|
||||||
usage.addKeyboardMouseBinding("Trackball: Space","Reset the viewing position to home");
|
usage.addKeyboardMouseBinding("Trackball: Space","Reset the viewing position to home");
|
||||||
usage.addKeyboardMouseBinding("Trackball: +","When in stereo, increase the fusion distance");
|
usage.addKeyboardMouseBinding("Trackball: +","When in stereo, increase the fusion distance");
|
||||||
usage.addKeyboardMouseBinding("Trackball: -","When in stereo, reduse the fusion distance");
|
usage.addKeyboardMouseBinding("Trackball: -","When in stereo, reduse the fusion distance");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackerManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
bool NodeTrackerManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||||
{
|
{
|
||||||
switch(ea.getEventType())
|
switch(ea.getEventType())
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ bool TrackerManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TrackerManipulator::isMouseMoving()
|
bool NodeTrackerManipulator::isMouseMoving()
|
||||||
{
|
{
|
||||||
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
||||||
|
|
||||||
@ -203,20 +203,20 @@ bool TrackerManipulator::isMouseMoving()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackerManipulator::flushMouseEventStack()
|
void NodeTrackerManipulator::flushMouseEventStack()
|
||||||
{
|
{
|
||||||
_ga_t1 = NULL;
|
_ga_t1 = NULL;
|
||||||
_ga_t0 = NULL;
|
_ga_t0 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackerManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
void NodeTrackerManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
||||||
{
|
{
|
||||||
_ga_t1 = _ga_t0;
|
_ga_t1 = _ga_t0;
|
||||||
_ga_t0 = &ea;
|
_ga_t0 = &ea;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerManipulator::setByMatrix(const osg::Matrixd& matrix)
|
void NodeTrackerManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
|
|
||||||
osg::Vec3 lookVector(- matrix(2,0),-matrix(2,1),-matrix(2,2));
|
osg::Vec3 lookVector(- matrix(2,0),-matrix(2,1),-matrix(2,2));
|
||||||
@ -314,13 +314,13 @@ void TrackerManipulator::setByMatrix(const osg::Matrixd& matrix)
|
|||||||
clampOrientation();
|
clampOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec3d TrackerManipulator::computeCenter() const
|
osg::Vec3d NodeTrackerManipulator::computeCenter() const
|
||||||
{
|
{
|
||||||
if (_trackNode.valid())
|
if (_trackNode.valid())
|
||||||
{
|
{
|
||||||
CollectParentPaths cpp;
|
CollectParentPaths cpp;
|
||||||
|
|
||||||
TrackerManipulator* non_const_this = const_cast<TrackerManipulator*>(this);
|
NodeTrackerManipulator* non_const_this = const_cast<NodeTrackerManipulator*>(this);
|
||||||
|
|
||||||
non_const_this->_trackNode->accept(cpp);
|
non_const_this->_trackNode->accept(cpp);
|
||||||
|
|
||||||
@ -336,17 +336,17 @@ osg::Vec3d TrackerManipulator::computeCenter() const
|
|||||||
return osg::Vec3d(0.0,0.0,0.0);
|
return osg::Vec3d(0.0,0.0,0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrixd TrackerManipulator::getMatrix() const
|
osg::Matrixd NodeTrackerManipulator::getMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrixd::translate(0.0,0.0,_distance)*osg::Matrixd::rotate(_rotation)*osg::Matrix::translate(computeCenter());
|
return osg::Matrixd::translate(0.0,0.0,_distance)*osg::Matrixd::rotate(_rotation)*osg::Matrix::translate(computeCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrixd TrackerManipulator::getInverseMatrix() const
|
osg::Matrixd NodeTrackerManipulator::getInverseMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(-computeCenter())*osg::Matrixd::rotate(_rotation.inverse())*osg::Matrixd::translate(0.0,0.0,-_distance);
|
return osg::Matrix::translate(-computeCenter())*osg::Matrixd::rotate(_rotation.inverse())*osg::Matrixd::translate(0.0,0.0,-_distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerManipulator::computePosition(const osg::Vec3d& eye,const osg::Vec3d& center,const osg::Vec3d& up)
|
void NodeTrackerManipulator::computePosition(const osg::Vec3d& eye,const osg::Vec3d& center,const osg::Vec3d& up)
|
||||||
{
|
{
|
||||||
if (!_node) return;
|
if (!_node) return;
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ void TrackerManipulator::computePosition(const osg::Vec3d& eye,const osg::Vec3d&
|
|||||||
clampOrientation();
|
clampOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackerManipulator::calcMovement()
|
bool NodeTrackerManipulator::calcMovement()
|
||||||
{
|
{
|
||||||
// return if less then two events have been added.
|
// return if less then two events have been added.
|
||||||
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
||||||
@ -569,7 +569,7 @@ bool TrackerManipulator::calcMovement()
|
|||||||
if (!hitFound)
|
if (!hitFound)
|
||||||
{
|
{
|
||||||
// ??
|
// ??
|
||||||
osg::notify(INFO)<<"TrackerManipulator unable to intersect with Tracker."<<std::endl;
|
osg::notify(INFO)<<"NodeTrackerManipulator unable to intersect with Tracker."<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
coordinateFrame = getCoordinateFrame(_center);
|
coordinateFrame = getCoordinateFrame(_center);
|
||||||
@ -619,7 +619,7 @@ bool TrackerManipulator::calcMovement()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerManipulator::clampOrientation()
|
void NodeTrackerManipulator::clampOrientation()
|
||||||
{
|
{
|
||||||
if (_rotationMode==ELEVATION_AZIM)
|
if (_rotationMode==ELEVATION_AZIM)
|
||||||
{
|
{
|
||||||
@ -679,7 +679,7 @@ const float TRACKBALLSIZE = 0.8f;
|
|||||||
* It is assumed that the arguments to this routine are in the range
|
* It is assumed that the arguments to this routine are in the range
|
||||||
* (-1.0 ... 1.0)
|
* (-1.0 ... 1.0)
|
||||||
*/
|
*/
|
||||||
void TrackerManipulator::trackball(osg::Vec3& axis,double & angle, double p1x, double p1y, double p2x, double p2y)
|
void NodeTrackerManipulator::trackball(osg::Vec3& axis,double & angle, double p1x, double p1y, double p2x, double p2y)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* First, figure out z-coordinates for projection of P1 and P2 to
|
* First, figure out z-coordinates for projection of P1 and P2 to
|
||||||
@ -728,7 +728,7 @@ axis = p2^p1;
|
|||||||
* Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
|
* Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
|
||||||
* if we are away from the center of the sphere.
|
* if we are away from the center of the sphere.
|
||||||
*/
|
*/
|
||||||
double TrackerManipulator::tb_project_to_sphere(double r, double x, double y)
|
double NodeTrackerManipulator::tb_project_to_sphere(double r, double x, double y)
|
||||||
{
|
{
|
||||||
float d, t, z;
|
float d, t, z;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user