Removed remaining dependancies on osg::Camera.
This commit is contained in:
@@ -12,7 +12,6 @@ CXXFILES =\
|
||||
BoundingBox.cpp\
|
||||
BoundingSphere.cpp\
|
||||
BlendFunc.cpp\
|
||||
Camera.cpp\
|
||||
ClipNode.cpp\
|
||||
ClipPlane.cpp\
|
||||
ColorMask.cpp\
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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\
|
||||
|
||||
22
src/osgGA/MatrixManipulator.cpp
Normal file
22
src/osgGA/MatrixManipulator.cpp
Normal 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;
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -131,7 +131,7 @@ void OsgCameraGroup::_init()
|
||||
_background_color.set( 0.2f, 0.2f, 0.4f, 1.0f );
|
||||
_LODScale = 1.0f;
|
||||
|
||||
_fusionDistanceMode = osgUtil::SceneView::USE_CAMERA_FUSION_DISTANCE;
|
||||
_fusionDistanceMode = osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE;
|
||||
_fusionDistanceValue = 1.0f;
|
||||
|
||||
_initialized = false;
|
||||
|
||||
@@ -235,9 +235,6 @@ void Viewer::setUpViewer(unsigned int options)
|
||||
_updateVisitor = new osgUtil::UpdateVisitor;
|
||||
_updateVisitor->setFrameStamp(_frameStamp.get());
|
||||
|
||||
// create a camera to use with the manipulators.
|
||||
_old_style_osg_camera = new osg::Camera;
|
||||
|
||||
if (options&TRACKBALL_MANIPULATOR) addCameraManipulator(new osgGA::TrackballManipulator);
|
||||
if (options&FLIGHT_MANIPULATOR) addCameraManipulator(new osgGA::FlightManipulator);
|
||||
if (options&DRIVE_MANIPULATOR) addCameraManipulator(new osgGA::DriveManipulator);
|
||||
@@ -256,19 +253,19 @@ void Viewer::setUpViewer(unsigned int options)
|
||||
|
||||
}
|
||||
|
||||
unsigned int Viewer::addCameraManipulator(osgGA::CameraManipulator* cm)
|
||||
unsigned int Viewer::addCameraManipulator(osgGA::MatrixManipulator* cm)
|
||||
{
|
||||
if (!cm) return 0xfffff;
|
||||
|
||||
// create a key switch manipulator if one doesn't already exist.
|
||||
if (!_keyswitchManipulator)
|
||||
{
|
||||
_keyswitchManipulator = new osgGA::KeySwitchCameraManipulator;
|
||||
_keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
||||
_eventHandlerList.push_back(_keyswitchManipulator.get());
|
||||
}
|
||||
|
||||
unsigned int num = _keyswitchManipulator->getNumCameraManipualtors();
|
||||
_keyswitchManipulator->addNumberedCameraManipulator(cm);
|
||||
unsigned int num = _keyswitchManipulator->getNumMatrixManipualtors();
|
||||
_keyswitchManipulator->addNumberedMatrixManipulator(cm);
|
||||
|
||||
return num;
|
||||
}
|
||||
@@ -282,17 +279,13 @@ void Viewer::setViewByMatrix( const Producer::Matrix & pm)
|
||||
{
|
||||
CameraGroup::setViewByMatrix(pm);
|
||||
|
||||
if (_keyswitchManipulator.valid() && _old_style_osg_camera.valid())
|
||||
if (_keyswitchManipulator.valid())
|
||||
{
|
||||
// now convert Producer matrix to an osg::Matrix so we can update
|
||||
// the internal camera...
|
||||
|
||||
osg::Matrix matrix(pm.ptr());
|
||||
|
||||
_old_style_osg_camera->home();
|
||||
_old_style_osg_camera->transformLookAt(matrix);
|
||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = _kbmcb->createEventAdapter();
|
||||
_keyswitchManipulator->init(*init_event,*this);
|
||||
_keyswitchManipulator->setByInverseMatrix(matrix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,12 +307,11 @@ bool Viewer::realize()
|
||||
// any work on them.
|
||||
OsgCameraGroup::sync();
|
||||
|
||||
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentCameraManipulator())
|
||||
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentMatrixManipulator())
|
||||
{
|
||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = _kbmcb->createEventAdapter();
|
||||
init_event->adaptFrame(0.0);
|
||||
|
||||
_keyswitchManipulator->setCamera(_old_style_osg_camera.get());
|
||||
_keyswitchManipulator->setNode(getSceneDecorator());
|
||||
_keyswitchManipulator->home(*init_event,*this);
|
||||
}
|
||||
@@ -329,7 +321,6 @@ bool Viewer::realize()
|
||||
for(SceneHandlerList::iterator p=_shvec.begin(); p!=_shvec.end(); p++ )
|
||||
{
|
||||
(*p)->getState()->setAbortRenderingPtr(&_done);
|
||||
(*p)->setCamera(_old_style_osg_camera.get());
|
||||
}
|
||||
|
||||
return _realized;
|
||||
@@ -371,9 +362,18 @@ void Viewer::update()
|
||||
}
|
||||
|
||||
// update the main producer camera
|
||||
if (_old_style_osg_camera.valid())
|
||||
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentMatrixManipulator())
|
||||
{
|
||||
CameraGroup::setViewByMatrix(Producer::Matrix(_old_style_osg_camera->getModelViewMatrix().ptr()));
|
||||
osgGA::MatrixManipulator* mm = _keyswitchManipulator->getCurrentMatrixManipulator();
|
||||
osg::Matrix matrix = mm->getInverseMatrix();
|
||||
CameraGroup::setViewByMatrix(Producer::Matrix(matrix.ptr()));
|
||||
|
||||
for(SceneHandlerList::iterator p=_shvec.begin(); p!=_shvec.end(); p++ )
|
||||
{
|
||||
(*p)->setFusionDistance(mm->getFusionDistanceMode(),mm->getFusionDistanceValue());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ bool Viewer::computeIntersections(float x,float y,osgUtil::IntersectVisitor::Hit
|
||||
|
||||
void Viewer::selectCameraManipulator(unsigned int no)
|
||||
{
|
||||
if (_keyswitchManipulator.valid()) _keyswitchManipulator->selectCameraManipulator(no);
|
||||
if (_keyswitchManipulator.valid()) _keyswitchManipulator->selectMatrixManipulator(no);
|
||||
}
|
||||
|
||||
void Viewer::requestWarpPointer(float x,float y)
|
||||
|
||||
@@ -829,6 +829,16 @@ bool ViewerEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActio
|
||||
|
||||
return true;
|
||||
}
|
||||
case '+' :
|
||||
{
|
||||
//_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()*1.25f);
|
||||
return true;
|
||||
}
|
||||
case '-' :
|
||||
{
|
||||
//_camera->setFusionDistanceRatio(_camera->getFusionDistanceRatio()/1.25f);
|
||||
return true;
|
||||
}
|
||||
|
||||
case osgGA::GUIEventAdapter::KEY_Help :
|
||||
case 'h' :
|
||||
@@ -880,12 +890,12 @@ bool ViewerEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActio
|
||||
osgGA::AnimationPathManipulator* apm = 0;
|
||||
unsigned int apmNo = 0;
|
||||
|
||||
osgGA::KeySwitchCameraManipulator* kscm = viewer->getKeySwitchCameraManipulator();
|
||||
osgGA::KeySwitchMatrixManipulator* kscm = viewer->getKeySwitchMatrixManipulator();
|
||||
if (kscm)
|
||||
{
|
||||
for(apmNo=0;apmNo<kscm->getNumCameraManipualtors() && apm==0;++apmNo)
|
||||
for(apmNo=0;apmNo<kscm->getNumMatrixManipualtors() && apm==0;++apmNo)
|
||||
{
|
||||
apm = dynamic_cast<osgGA::AnimationPathManipulator*>(kscm->getCameraManipulator(apmNo));
|
||||
apm = dynamic_cast<osgGA::AnimationPathManipulator*>(kscm->getMatrixManipulator(apmNo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,4 +940,6 @@ void ViewerEventHandler::getUsage(osg::ApplicationUsage& usage) const
|
||||
usage.addKeyboardMouseBinding("v","Toggle block and vsync");
|
||||
usage.addKeyboardMouseBinding("z","Start recording camera path.");
|
||||
usage.addKeyboardMouseBinding("Z","If recording camera path stop recording camera path, save to \"saved_animation.path\"\nThen start viewing from being on animation path");
|
||||
// usage.addKeyboardMouseBinding("+","When in stereo, increase the fusion distance");
|
||||
// usage.addKeyboardMouseBinding("-","When in stereo, reduse the fusion distance");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
_LODScale = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 3.0f;
|
||||
|
||||
_fusionDistanceMode = USE_CAMERA_FUSION_DISTANCE;
|
||||
_fusionDistanceMode = PROPORTIONAL_TO_SCREEN_DISTANCE;
|
||||
_fusionDistanceValue = 1.0f;
|
||||
|
||||
_lightingMode=HEADLIGHT;
|
||||
@@ -76,8 +76,6 @@ void SceneView::setDefaults()
|
||||
|
||||
_state = new State;
|
||||
|
||||
_camera = new Camera(_displaySettings.get());
|
||||
|
||||
_rendergraph = new RenderGraph;
|
||||
_renderStage = new RenderStage;
|
||||
|
||||
@@ -209,40 +207,7 @@ void SceneView::cull()
|
||||
|
||||
osg::ref_ptr<osg::RefMatrix> projection = _projectionMatrix.get();
|
||||
osg::ref_ptr<osg::RefMatrix> modelview = _modelviewMatrix.get();
|
||||
|
||||
if (_camera.valid())
|
||||
{
|
||||
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
{
|
||||
switch(_displaySettings->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::HORIZONTAL_SPLIT):
|
||||
_camera->adjustAspectRatio(0.5*_viewport->aspectRatio());
|
||||
break;
|
||||
case(osg::DisplaySettings::VERTICAL_SPLIT):
|
||||
_camera->adjustAspectRatio(2*_viewport->aspectRatio());
|
||||
break;
|
||||
default:
|
||||
_camera->adjustAspectRatio(_viewport->aspectRatio());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_camera->adjustAspectRatio(_viewport->aspectRatio());
|
||||
}
|
||||
|
||||
if (_displaySettings.valid())
|
||||
_camera->setScreenDistance(_displaySettings->getScreenDistance());
|
||||
|
||||
if (!projection) projection = new osg::RefMatrix(_camera->getProjectionMatrix());
|
||||
if (!modelview) modelview = new osg::RefMatrix(_camera->getModelViewMatrix());
|
||||
|
||||
//cout <<"fovx="<<_camera->calc_fovx()<<endl;
|
||||
|
||||
}
|
||||
|
||||
if (!projection) projection = new osg::RefMatrix();
|
||||
if (!modelview) modelview = new osg::RefMatrix();
|
||||
|
||||
@@ -268,12 +233,6 @@ void SceneView::cull()
|
||||
float fusionDistance = _displaySettings->getScreenDistance();
|
||||
switch(_fusionDistanceMode)
|
||||
{
|
||||
case(USE_CAMERA_FUSION_DISTANCE):
|
||||
if (_camera.valid())
|
||||
{
|
||||
fusionDistance = _camera->getFusionDistance();
|
||||
}
|
||||
break;
|
||||
case(USE_FUSION_DISTANCE_VALUE):
|
||||
fusionDistance = _fusionDistanceValue;
|
||||
break;
|
||||
@@ -305,11 +264,6 @@ void SceneView::cull()
|
||||
_cullVisitor->setTraversalMask(_cullMaskLeft);
|
||||
cullStage(projectionLeft.get(),modelviewLeft.get(),_cullVisitor.get(),_rendergraph.get(),_renderStage.get());
|
||||
|
||||
if (_camera.valid() && _computeNearFar != CullVisitor::DO_NOT_COMPUTE_NEAR_FAR)
|
||||
{
|
||||
// clamp the camera to the near/far computed in cull traversal.
|
||||
_camera->setNearFar(_cullVisitor->getCalculatedNearPlane(),_cullVisitor->getCalculatedFarPlane());
|
||||
}
|
||||
}
|
||||
else if (_displaySettings->getStereoMode()==osg::DisplaySettings::RIGHT_EYE)
|
||||
{
|
||||
@@ -330,11 +284,6 @@ void SceneView::cull()
|
||||
cullStage(projectionRight.get(),modelviewRight.get(),_cullVisitor.get(),_rendergraph.get(),_renderStage.get());
|
||||
|
||||
|
||||
if (_camera.valid() && _computeNearFar != CullVisitor::DO_NOT_COMPUTE_NEAR_FAR)
|
||||
{
|
||||
// clamp the camera to the near/far computed in cull traversal.
|
||||
_camera->setNearFar(_cullVisitor->getCalculatedNearPlane(),_cullVisitor->getCalculatedFarPlane());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -381,14 +330,7 @@ void SceneView::cull()
|
||||
|
||||
_cullVisitorRight->setTraversalMask(_cullMaskRight);
|
||||
cullStage(projectionRight.get(),modelviewRight.get(),_cullVisitorRight.get(),_rendergraphRight.get(),_renderStageRight.get());
|
||||
|
||||
|
||||
if (_camera.valid() && _computeNearFar != CullVisitor::DO_NOT_COMPUTE_NEAR_FAR)
|
||||
{
|
||||
// clamp the camera to the near/far computed in cull traversal.
|
||||
_camera->setNearFar(_cullVisitorRight->getCalculatedNearPlane(),_cullVisitorRight->getCalculatedFarPlane());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -398,11 +340,6 @@ void SceneView::cull()
|
||||
_cullVisitor->setTraversalMask(_cullMask);
|
||||
cullStage(projection.get(),modelview.get(),_cullVisitor.get(),_rendergraph.get(),_renderStage.get());
|
||||
|
||||
if (_camera.valid() && _computeNearFar != CullVisitor::DO_NOT_COMPUTE_NEAR_FAR)
|
||||
{
|
||||
// clamp the camera to the near/far computed in cull traversal.
|
||||
_camera->setNearFar(_cullVisitor->getCalculatedNearPlane(),_cullVisitor->getCalculatedFarPlane());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -708,7 +645,7 @@ void SceneView::draw()
|
||||
break;
|
||||
default:
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Warning: stereo camera mode not implemented yet."<< std::endl;
|
||||
osg::notify(osg::NOTICE)<<"Warning: stereo mode not implemented yet."<< std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -786,13 +723,9 @@ const osg::Matrix SceneView::computeMVPW() const
|
||||
|
||||
if (_modelviewMatrix.valid())
|
||||
matrix = (*_modelviewMatrix);
|
||||
else if (_camera.valid())
|
||||
matrix = _camera->getModelViewMatrix();
|
||||
|
||||
if (_projectionMatrix.valid())
|
||||
matrix.postMult(*_projectionMatrix);
|
||||
else if (_camera.valid())
|
||||
matrix.postMult(_camera->getProjectionMatrix());
|
||||
|
||||
if (_viewport.valid())
|
||||
matrix.postMult(_viewport->computeWindowMatrix());
|
||||
|
||||
Reference in New Issue
Block a user