Removed remaining dependancies on osg::Camera.

This commit is contained in:
Robert Osfield
2003-05-19 15:15:17 +00:00
parent 4151312dc5
commit 940ce67133
31 changed files with 506 additions and 616 deletions

View File

@@ -154,12 +154,5 @@ void AnimationPathManipulator::handleFrame( double time )
_numOfFramesSinceStartOfTimedPeriod = 0;
}
osg::Matrix matrix;
cp.getMatrix( matrix );
if (_camera.valid())
{
_camera->home();
_camera->transformLookAt(matrix);
}
cp.getMatrix( _matrix );
}

View File

@@ -1,37 +0,0 @@
#include <osg/GL>
#include <osg/Matrix>
#include <osgGA/CameraManipulator>
using namespace osg;
using namespace osgGA;
CameraManipulator::CameraManipulator(): _camera(NULL)
{
}
CameraManipulator::~CameraManipulator()
{
}
void CameraManipulator::setCamera(Camera *camera)
{
_camera=camera;
}
const Camera *CameraManipulator::getCamera() const
{
return _camera.get();
}
Camera *CameraManipulator::getCamera()
{
return _camera.get();
}
bool CameraManipulator::handle(const GUIEventAdapter&,GUIActionAdapter&)
{
return false;
}

View File

@@ -55,7 +55,7 @@ osg::Node* DriveManipulator::getNode()
void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
if(_node.get() && _camera.get())
if(_node.get())
{
const osg::BoundingSphere& boundingSphere=_node->getBound();
@@ -68,7 +68,7 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
// check to see if any obstruction in front.
osgUtil::IntersectVisitor iv;
bool cameraSet = false;
bool positionSet = false;
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
segDown->set(ep,bp);
@@ -89,22 +89,19 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
if (np.z()>0.0f) uv = np;
else uv = -np;
float lookDistance = _modelScale*0.1f;
ep = ip;
ep.z() += _height;
osg::Vec3 lv = uv^osg::Vec3(1.0f,0.0f,0.0f);
osg::Vec3 cp = ep+lv*lookDistance;
_camera->setLookAt(ep,cp,uv);
computePosition(ep,lv,uv);
cameraSet = true;
positionSet = true;
}
}
if (!cameraSet)
if (!positionSet)
{
bp = ep;
bp.z() += _modelScale;
@@ -128,29 +125,23 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
if (np.z()>0.0f) uv = np;
else uv = -np;
float lookDistance = _modelScale*0.1f;
ep = ip;
ep.z() += _height;
osg::Vec3 lv = uv^osg::Vec3(1.0f,0.0f,0.0f);
osg::Vec3 cp = ep+lv*lookDistance;
computePosition(ep,lv,uv);
_camera->setLookAt(ep,cp,uv);
cameraSet = true;
positionSet = true;
}
}
}
if (!cameraSet)
if (!positionSet)
{
// eye
_camera->setLookAt(boundingSphere._center+osg::Vec3( 0.0,-2.0f * boundingSphere._radius,0.0f),
// look
boundingSphere._center,
// up
computePosition(
boundingSphere._center+osg::Vec3( 0.0,-2.0f * boundingSphere._radius,0.0f),
osg::Vec3(0.0f,1.0f,0.0f),
osg::Vec3(0.0f,0.0f,1.0f));
}
@@ -163,8 +154,6 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2.0f,(ea.getYmin()+ea.getYmax())/2.0f);
flushMouseEventStack();
computeLocalDataFromCamera();
}
void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
@@ -175,15 +164,18 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
_velocity = 0.0f;
osg::Vec3 ep = _camera->getEyePoint();
osg::Vec3 sv = _camera->getSideVector();
osg::Vec3 ep = _eye;
Matrix rotation_matrix;
_rotation.get(rotation_matrix);
osg::Vec3 sv = osg::Vec3(1.0f,0.0f,0.0f) * rotation_matrix;
osg::Vec3 bp = ep;
bp.z() -= _modelScale;
// check to see if any obstruction in front.
osgUtil::IntersectVisitor iv;
bool cameraSet = false;
bool positionSet = false;
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
segDown->set(ep,bp);
@@ -204,22 +196,18 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
if (np.z()>0.0f) uv = np;
else uv = -np;
float lookDistance = _modelScale*0.1f;
ep = ip+uv*_height;
osg::Vec3 lv = uv^sv;
osg::Vec3 lp = ep+lv*lookDistance;
_camera->setLookAt(ep,lp,uv);
_camera->ensureOrthogonalUpVector();
computePosition(ep,lv,uv);
cameraSet = true;
positionSet = true;
}
}
if (!cameraSet)
if (!positionSet)
{
bp = ep;
bp.z() += _modelScale;
@@ -243,16 +231,12 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
if (np.z()>0.0f) uv = np;
else uv = -np;
float lookDistance = _modelScale*0.1f;
ep = ip+uv*_height;
osg::Vec3 lv = uv^sv;
osg::Vec3 lp = ep+lv*lookDistance;
_camera->setLookAt(ep,lp,uv);
_camera->ensureOrthogonalUpVector();
computePosition(ep,lv,uv);
cameraSet = true;
positionSet = true;
}
@@ -263,15 +247,11 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2.0f,(ea.getYmin()+ea.getYmax())/2.0f);
}
computeLocalDataFromCamera();
}
bool DriveManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
if(!_camera.get()) return false;
switch(ea.getEventType())
{
case(GUIEventAdapter::PUSH):
@@ -330,16 +310,6 @@ bool DriveManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
_speedMode = USE_MOUSE_BUTTONS_FOR_SPEED;
return true;
}
else if (ea.getKey()=='+')
{
_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()*1.25f);
return true;
}
else if (ea.getKey()=='-')
{
_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()/1.25f);
return true;
}
return false;
}
@@ -365,8 +335,6 @@ bool DriveManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
void DriveManipulator::getUsage(osg::ApplicationUsage& usage) const
{
usage.addKeyboardMouseBinding("Drive: Space","Reset the viewing position to home");
usage.addKeyboardMouseBinding("Drive: +","When in stereo, increase the fusion distance");
usage.addKeyboardMouseBinding("Drive: -","When in stereo, reduse the fusion distance");
usage.addKeyboardMouseBinding("Drive: q","Use mouse y for controlling speed");
usage.addKeyboardMouseBinding("Drive: a","Use mouse middle,right mouse buttons for speed");
}
@@ -385,40 +353,23 @@ void DriveManipulator::addMouseEvent(const GUIEventAdapter& ea)
_ga_t0 = &ea;
}
void DriveManipulator::computeLocalDataFromCamera()
void DriveManipulator::setByMatrix(const osg::Matrix& matrix)
{
// maths from gluLookAt/osg::Matrix::makeLookAt
osg::Vec3 f(_camera->getCenterPoint()-_camera->getEyePoint());
f.normalize();
osg::Vec3 s(f^_camera->getUpVector());
s.normalize();
osg::Vec3 u(s^f);
u.normalize();
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
s[1], u[1], -f[1], 0.0f,
s[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
_eye = _camera->getEyePoint();
_distance = _camera->getLookDistance();
_rotation.set(rotation_matrix);
_rotation = _rotation.inverse();
_eye = matrix.getTrans();
_rotation.set(matrix);
}
void DriveManipulator::computeCameraFromLocalData()
osg::Matrix DriveManipulator::getMatrix() const
{
osg::Matrix new_rotation;
new_rotation.makeRotate(_rotation);
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * new_rotation;
osg::Vec3 center = (osg::Vec3(0.0f,0.0f,-_distance) * new_rotation) + _eye;
_camera->setLookAt(_eye,center,up);
return osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_eye);
}
void DriveManipulator::computeCameraFromLocalData(const osg::Vec3& lv,const osg::Vec3& up)
osg::Matrix DriveManipulator::getInverseMatrix() const
{
return osg::Matrix::translate(-_eye)*osg::Matrix::rotate(_rotation.inverse());
}
void DriveManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
{
osg::Vec3 f(lv);
f.normalize();
@@ -432,17 +383,14 @@ void DriveManipulator::computeCameraFromLocalData(const osg::Vec3& lv,const osg:
s[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
_eye = eye;
_rotation.set(rotation_matrix);
_rotation = _rotation.inverse();
computeCameraFromLocalData();
}
bool DriveManipulator::calcMovement()
{
_camera->setFusionDistanceMode(osg::Camera::PROPORTIONAL_TO_SCREEN_DISTANCE);
// return if less then two events have been added.
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
@@ -564,7 +512,7 @@ bool DriveManipulator::calcMovement()
_eye = ip+up*_height;
lv = up^sv;
computeCameraFromLocalData(lv,up);
computePosition(_eye,lv,up);
return true;
@@ -601,7 +549,7 @@ bool DriveManipulator::calcMovement()
_eye = ip+up*_height;
lv = up^sv;
computeCameraFromLocalData(lv,up);
computePosition(_eye,lv,up);
return true;
}
@@ -616,7 +564,5 @@ bool DriveManipulator::calcMovement()
}
computeCameraFromLocalData();
return true;
}

View File

@@ -44,14 +44,14 @@ osg::Node* FlightManipulator::getNode()
void FlightManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
if(_node.get() && _camera.get())
if(_node.get())
{
const osg::BoundingSphere& boundingSphere=_node->getBound();
_camera->setLookAt(
computePosition(
boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f),
boundingSphere._center,
osg::Vec3(0.0f,1.0f,0.0f),
osg::Vec3(0.0f,0.0f,1.0f));
_velocity = 0.0f;
@@ -60,8 +60,6 @@ void FlightManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2.0f,(ea.getYmin()+ea.getYmax())/2.0f);
computeLocalDataFromCamera();
flushMouseEventStack();
}
@@ -81,15 +79,11 @@ void FlightManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2.0f,(ea.getYmin()+ea.getYmax())/2.0f);
}
computeLocalDataFromCamera();
}
bool FlightManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
if(!_camera.get()) return false;
switch(ea.getEventType())
{
case(GUIEventAdapter::PUSH):
@@ -138,16 +132,6 @@ bool FlightManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
us.requestContinuousUpdate(false);
return true;
}
else if (ea.getKey()=='+')
{
_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()*1.25f);
return true;
}
else if (ea.getKey()=='-')
{
_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()/1.25f);
return true;
}
else if (ea.getKey()=='q')
{
_yawMode = YAW_AUTOMATICALLY_WHEN_BANKED;
@@ -178,8 +162,6 @@ bool FlightManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
void FlightManipulator::getUsage(osg::ApplicationUsage& usage) const
{
usage.addKeyboardMouseBinding("Flight: Space","Reset the viewing position to home");
usage.addKeyboardMouseBinding("Flight: +","When in stereo, increase the fusion distance");
usage.addKeyboardMouseBinding("Flight: -","When in stereo, reduse the fusion distance");
usage.addKeyboardMouseBinding("Flight: q","Automatically yaw when banked (default)");
usage.addKeyboardMouseBinding("Flight: a","No yaw when banked");
}
@@ -198,43 +180,46 @@ void FlightManipulator::addMouseEvent(const GUIEventAdapter& ea)
}
void FlightManipulator::computeLocalDataFromCamera()
void FlightManipulator::setByMatrix(const osg::Matrix& matrix)
{
// maths from gluLookAt/osg::Matrix::makeLookAt
osg::Vec3 f(_camera->getCenterPoint()-_camera->getEyePoint());
_eye = matrix.getTrans();
_rotation.set(matrix);
_distance = 1.0f;
}
osg::Matrix FlightManipulator::getMatrix() const
{
return osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_eye);
}
osg::Matrix FlightManipulator::getInverseMatrix() const
{
return osg::Matrix::translate(-_eye)*osg::Matrix::rotate(_rotation.inverse());
}
void FlightManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
{
osg::Vec3 f(lv);
f.normalize();
osg::Vec3 s(f^_camera->getUpVector());
osg::Vec3 s(f^up);
s.normalize();
osg::Vec3 u(s^f);
u.normalize();
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
s[1], u[1], -f[1], 0.0f,
s[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
_eye = _camera->getEyePoint();
_distance = _camera->getLookDistance();
_eye = eye;
_distance = lv.length();
_rotation.set(rotation_matrix);
_rotation = _rotation.inverse();
}
void FlightManipulator::computeCameraFromLocalData()
{
osg::Matrix new_rotation;
new_rotation.makeRotate(_rotation);
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * new_rotation;
osg::Vec3 center = (osg::Vec3(0.0f,0.0f,-_distance) * new_rotation) + _eye;
_camera->setLookAt(_eye,center,up);
}
bool FlightManipulator::calcMovement()
{
_camera->setFusionDistanceMode(osg::Camera::PROPORTIONAL_TO_SCREEN_DISTANCE);
// return if less then two events have been added.
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
@@ -311,7 +296,5 @@ bool FlightManipulator::calcMovement()
_eye += lv;
_rotation = _rotation*delta_rotate;
computeCameraFromLocalData();
return true;
}

View File

@@ -4,12 +4,12 @@ include $(TOPDIR)/Make/makedefs
CXXFILES = \
AnimationPathManipulator.cpp\
CameraManipulator.cpp\
MatrixManipulator.cpp\
DriveManipulator.cpp\
FlightManipulator.cpp\
GUIEventHandler.cpp\
GUIEventHandlerVisitor.cpp\
KeySwitchCameraManipulator.cpp\
KeySwitchMatrixManipulator.cpp\
SetSceneViewVisitor.cpp\
StateSetManipulator.cpp\
TrackballManipulator.cpp\

View File

@@ -0,0 +1,22 @@
#include <osg/GL>
#include <osg/Matrix>
#include <osgGA/MatrixManipulator>
using namespace osg;
using namespace osgGA;
MatrixManipulator::MatrixManipulator()
{
}
MatrixManipulator::~MatrixManipulator()
{
}
bool MatrixManipulator::handle(const GUIEventAdapter&,GUIActionAdapter&)
{
return false;
}

View File

@@ -1,11 +1,14 @@
#include <osgGA/SetSceneViewVisitor>
#include <osgGA/CameraManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/MatrixManipulator>
void osgGA::SetSceneViewVisitor::visit(osgGA::CameraManipulator& cm)
void osgGA::SetSceneViewVisitor::visit(osgGA::MatrixManipulator& cm)
{
cm.setNode(_sceneView->getSceneData());
cm.setCamera(_sceneView->getCamera());
if (_sceneView->getModelViewMatrix())
{
cm.setByInverseMatrix(*(_sceneView->getModelViewMatrix()));
}
cm.init(*getGUIEventAdapter(),*getGUIActionAdapter());
cm.home(*getGUIEventAdapter(),*getGUIActionAdapter());
}

View File

@@ -1,4 +1,5 @@
#include <osgGA/TrackballManipulator>
#include <osg/Quat>
#include <osg/Notify>
using namespace osg;
@@ -45,17 +46,15 @@ osg::Node* TrackballManipulator::getNode()
/*ea*/
void TrackballManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us)
{
if(_node.get() && _camera.get())
if(_node.get())
{
const osg::BoundingSphere& boundingSphere=_node->getBound();
_camera->setView(boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f),
computePosition(boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f),
boundingSphere._center,
osg::Vec3(0.0f,0.0f,1.0f));
computeLocalDataFromCamera();
us.requestRedraw();
}
@@ -65,8 +64,6 @@ void TrackballManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us)
void TrackballManipulator::init(const GUIEventAdapter& ,GUIActionAdapter& )
{
flushMouseEventStack();
computeLocalDataFromCamera();
}
@@ -79,8 +76,6 @@ void TrackballManipulator::getUsage(osg::ApplicationUsage& usage) const
bool TrackballManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
{
if(!_camera.get()) return false;
switch(ea.getEventType())
{
case(GUIEventAdapter::PUSH):
@@ -151,26 +146,9 @@ bool TrackballManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us
us.requestRedraw();
us.requestContinuousUpdate(false);
return true;
} else if (ea.getKey()=='+')
{
_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()*1.25f);
return true;
}
else if (ea.getKey()=='-')
{
_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()/1.25f);
return true;
}
// this is quick hack to test out othographic projection.
// else if (ea.getKey()=='O')
// {
// float dist = _camera->getLookDistance();
// _camera->setOrtho(-dist,dist,-dist,dist,-dist,dist);
// return true;
// }
return false;
case(GUIEventAdapter::FRAME):
_camera->setFusionDistanceMode(osg::Camera::PROPORTIONAL_TO_LOOK_DISTANCE);
if (_thrown)
{
if (calcMovement()) us.requestRedraw();
@@ -211,39 +189,48 @@ void TrackballManipulator::addMouseEvent(const GUIEventAdapter& ea)
_ga_t0 = &ea;
}
void TrackballManipulator::computeLocalDataFromCamera()
void TrackballManipulator::setByMatrix(const osg::Matrix& matrix)
{
// maths from gluLookAt/osg::Matrix::makeLookAt
osg::Vec3 f(_camera->getCenterPoint()-_camera->getEyePoint());
_center = osg::Vec3(0.0f,0.0f,-_distance)*matrix;//matrix.getTrans();
_rotation.set(matrix);
osg::Matrix rotation_matrix;
_rotation.get(rotation_matrix);
// _center -= osg::Vec3(0.0f,0.0f,_distance)*rotation_matrix;
}
osg::Matrix TrackballManipulator::getMatrix() const
{
return osg::Matrix::translate(0.0f,0.0f,_distance)*osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_center);
}
osg::Matrix TrackballManipulator::getInverseMatrix() const
{
return osg::Matrix::translate(-_center)*osg::Matrix::rotate(_rotation.inverse())*osg::Matrix::translate(0.0f,0.0f,-_distance);
}
void TrackballManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up)
{
osg::Vec3 lv(center-eye);
osg::Vec3 f(lv);
f.normalize();
osg::Vec3 s(f^_camera->getUpVector());
osg::Vec3 s(f^up);
s.normalize();
osg::Vec3 u(s^f);
u.normalize();
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
s[1], u[1], -f[1], 0.0f,
s[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
_center = _camera->getCenterPoint();
_distance = _camera->getLookDistance();
_center = center;
_distance = lv.length();
_rotation.set(rotation_matrix);
_rotation = _rotation.inverse();
}
void TrackballManipulator::computeCameraFromLocalData()
{
osg::Matrix new_rotation;
new_rotation.makeRotate(_rotation);
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * new_rotation;
osg::Vec3 eye = (osg::Vec3(0.0f,0.0f,_distance) * new_rotation) + _center;
_camera->setLookAt(eye,_center,up);
}
@@ -260,7 +247,6 @@ bool TrackballManipulator::calcMovement()
// return if there is no movement.
if (dx==0 && dy==0) return false;
float focalLength = (_camera->getCenterPoint()-_camera->getEyePoint()).length();
unsigned int buttonMask = _ga_t1->getButtonMask();
if (buttonMask==GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
@@ -284,8 +270,6 @@ bool TrackballManipulator::calcMovement()
_rotation = _rotation*new_rotate;
computeCameraFromLocalData();
return true;
}
@@ -295,16 +279,15 @@ bool TrackballManipulator::calcMovement()
// pan model.
float scale = -0.5f*focalLength;
float scale = -0.5f*_distance;
osg::Vec3 uv = _camera->getUpVector();
osg::Vec3 sv = _camera->getSideVector();
osg::Vec3 dv = uv*(dy*scale)+sv*(dx*scale);
osg::Matrix rotation_matrix;
_rotation.get(rotation_matrix);
_center += dv;
osg::Vec3 dv(dx*scale,dy*scale,0.0f);
_center += dv*rotation_matrix;
computeCameraFromLocalData();
return true;
}
@@ -313,15 +296,13 @@ bool TrackballManipulator::calcMovement()
// zoom model.
float fd = focalLength;
float fd = _distance;
float scale = 1.0f+dy;
if (fd*scale>_modelScale*_minimumZoomScale)
{
_distance *= scale;
computeCameraFromLocalData();
}
else
{
@@ -329,12 +310,14 @@ bool TrackballManipulator::calcMovement()
// notify(DEBUG_INFO) << "Pushing forward"<<std::endl;
// push the camera forward.
float scale = -fd;
osg::Vec3 dv = _camera->getLookVector()*(dy*scale);
osg::Matrix rotation_matrix;
_rotation.get(rotation_matrix);
osg::Vec3 dv = (osg::Vec3(0.0f,0.0f,-1.0f)*rotation_matrix)*(dy*scale);
_center += dv;
computeCameraFromLocalData();
}
return true;
@@ -373,9 +356,13 @@ void TrackballManipulator::trackball(osg::Vec3& axis,float& angle, float p1x, fl
* deformed sphere
*/
osg::Vec3 uv = _camera->getUpVector();
osg::Vec3 sv = _camera->getSideVector();
osg::Vec3 lv = _camera->getLookVector();
osg::Matrix rotation_matrix;
_rotation.get(rotation_matrix);
osg::Vec3 uv = osg::Vec3(0.0f,1.0f,0.0f)*rotation_matrix;
osg::Vec3 sv = osg::Vec3(1.0f,0.0f,0.0f)*rotation_matrix;
osg::Vec3 lv = osg::Vec3(0.0f,0.0f,-1.0f)*rotation_matrix;
osg::Vec3 p1 = sv*p1x+uv*p1y-lv*tb_project_to_sphere(TRACKBALLSIZE,p1x,p1y);
osg::Vec3 p2 = sv*p2x+uv*p2y-lv*tb_project_to_sphere(TRACKBALLSIZE,p2x,p2y);