Changed the SceneView::setModelViewMatrix() methods across to being setViewMatrix().
The old RefMatrix methods for setModelViewMatrix() and setProjectMatrix() have been removed to keep the API as minimal as possible.
This commit is contained in:
parent
77c0366cb2
commit
deb26621c9
@ -128,17 +128,23 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
const osg::State* getState() const { return _state.get(); }
|
||||
|
||||
|
||||
/** set a projection matrix. Note, this will override a camera's projection matrix if it is not NULL.*/
|
||||
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
|
||||
void setProjectionMatrix(const osg::Matrix& matrix) { _projectionMatrix = new osg::RefMatrix(matrix); }
|
||||
void setProjectionMatrix(osg::RefMatrix* matrix) { _projectionMatrix = matrix; }
|
||||
osg::RefMatrix* getProjectionMatrix() { return _projectionMatrix.get(); }
|
||||
const osg::RefMatrix* getProjectionMatrix() const { return _projectionMatrix.get(); }
|
||||
|
||||
/** set a modelview matrix. Note, this will override a camera's modelview matrix if it is not NULL.*/
|
||||
void setModelViewMatrix(const osg::Matrix& matrix) { _modelviewMatrix = new osg::RefMatrix(matrix); }
|
||||
void setModelViewMatrix(osg::RefMatrix* matrix) { _modelviewMatrix = matrix; }
|
||||
osg::RefMatrix* getModelViewMatrix() { return _modelviewMatrix.get(); }
|
||||
const osg::RefMatrix* getModelViewMatrix() const { return _modelviewMatrix.get(); }
|
||||
/** Get the projection matrix.*/
|
||||
osg::Matrix& getProjectionMatrix() { return *_projectionMatrix; }
|
||||
|
||||
/** Get the const projection matrix.*/
|
||||
const osg::Matrix& getProjectionMatrix() const { return *_projectionMatrix; }
|
||||
|
||||
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
|
||||
void setViewMatrix(const osg::Matrix& matrix) { _viewMatrix = new osg::RefMatrix(matrix); }
|
||||
|
||||
/** Get the view matrix. */
|
||||
osg::Matrix& getViewMatrix() { return *_viewMatrix; }
|
||||
|
||||
/** Get the const view matrix. */
|
||||
const osg::Matrix& getViewMatrix() const { return *_viewMatrix; }
|
||||
|
||||
|
||||
void setInitVisitor(osg::NodeVisitor* av) { _initVisitor = av; }
|
||||
@ -297,7 +303,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
osg::ref_ptr<osg::StateSet> _localStateSet;
|
||||
osg::ref_ptr<osg::Light> _light;
|
||||
osg::ref_ptr<osg::RefMatrix> _projectionMatrix;
|
||||
osg::ref_ptr<osg::RefMatrix> _modelviewMatrix;
|
||||
osg::ref_ptr<osg::RefMatrix> _viewMatrix;
|
||||
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
|
||||
osg::ref_ptr<osg::State> _state;
|
||||
|
||||
|
@ -5,10 +5,7 @@
|
||||
void osgGA::SetSceneViewVisitor::visit(osgGA::MatrixManipulator& cm)
|
||||
{
|
||||
cm.setNode(_sceneView->getSceneData());
|
||||
if (_sceneView->getModelViewMatrix())
|
||||
{
|
||||
cm.setByInverseMatrix(*(_sceneView->getModelViewMatrix()));
|
||||
}
|
||||
cm.setByInverseMatrix(_sceneView->getViewMatrix());
|
||||
cm.init(*getGUIEventAdapter(),*getGUIActionAdapter());
|
||||
cm.home(*getGUIEventAdapter(),*getGUIActionAdapter());
|
||||
}
|
||||
|
@ -20,8 +20,6 @@ using namespace osgProducer;
|
||||
OsgSceneHandler::OsgSceneHandler( osg::DisplaySettings *ds) :
|
||||
_sceneView(new osgUtil::SceneView(ds))
|
||||
{
|
||||
_sceneView->setProjectionMatrix( new osg::RefMatrix );
|
||||
_sceneView->setModelViewMatrix( new osg::RefMatrix );
|
||||
}
|
||||
|
||||
void OsgSceneHandler::init()
|
||||
@ -46,8 +44,8 @@ void OsgSceneHandler::clearImplementation(Producer::Camera& /*camera*/)
|
||||
void OsgSceneHandler::cullImplementation(Producer::Camera &cam)
|
||||
{
|
||||
|
||||
_sceneView->getProjectionMatrix()->set(cam.getProjectionMatrix());
|
||||
_sceneView->getModelViewMatrix()->set(cam.getPositionAndAttitudeMatrix());
|
||||
_sceneView->getProjectionMatrix().set(cam.getProjectionMatrix());
|
||||
_sceneView->getViewMatrix().set(cam.getPositionAndAttitudeMatrix());
|
||||
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
|
@ -516,10 +516,10 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil
|
||||
osgProducer::OsgSceneHandler* sh = dynamic_cast<osgProducer::OsgSceneHandler*>(camera->getSceneHandler());
|
||||
osgUtil::SceneView* sv = sh?sh->getSceneView():0;
|
||||
osg::Matrix vum;
|
||||
if (sv!=0 && sv->getModelViewMatrix()!=0 && sv->getProjectionMatrix()!=0)
|
||||
if (sv!=0)
|
||||
{
|
||||
vum.set((*(sv->getModelViewMatrix())) *
|
||||
(*(sv->getProjectionMatrix())));
|
||||
vum.set(sv->getViewMatrix() *
|
||||
sv->getProjectionMatrix());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,9 +70,9 @@ void SceneView::setDefaults()
|
||||
_projectionMatrix = new RefMatrix();
|
||||
_projectionMatrix->makePerspective(50.0f,1.4f,1.0f,10000.0f);
|
||||
}
|
||||
if (!_modelviewMatrix)
|
||||
if (!_viewMatrix)
|
||||
{
|
||||
_modelviewMatrix = new RefMatrix();
|
||||
_viewMatrix = new RefMatrix();
|
||||
}
|
||||
|
||||
_globalStateSet = new osg::StateSet;
|
||||
@ -216,7 +216,7 @@ void SceneView::cull()
|
||||
|
||||
|
||||
osg::ref_ptr<osg::RefMatrix> projection = _projectionMatrix.get();
|
||||
osg::ref_ptr<osg::RefMatrix> modelview = _modelviewMatrix.get();
|
||||
osg::ref_ptr<osg::RefMatrix> modelview = _viewMatrix.get();
|
||||
|
||||
if (!projection) projection = new osg::RefMatrix();
|
||||
if (!modelview) modelview = new osg::RefMatrix();
|
||||
@ -761,8 +761,8 @@ const osg::Matrix SceneView::computeMVPW() const
|
||||
{
|
||||
osg::Matrix matrix;
|
||||
|
||||
if (_modelviewMatrix.valid())
|
||||
matrix = (*_modelviewMatrix);
|
||||
if (_viewMatrix.valid())
|
||||
matrix = (*_viewMatrix);
|
||||
|
||||
if (_projectionMatrix.valid())
|
||||
matrix.postMult(*_projectionMatrix);
|
||||
|
Loading…
Reference in New Issue
Block a user