From 7d69f8e193e4a0a6d49f30cebf00f49b69f112fd Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 29 Sep 2003 13:14:34 +0000 Subject: [PATCH] Added getPerspective() method to Matrix* and SceneView --- examples/osgunittests/osgunittests.cpp | 60 ++++++++++++++++---------- include/osg/Matrixd | 16 +++++-- include/osg/Matrixf | 19 +++++--- include/osgUtil/SceneView | 17 ++++++-- src/osg/Matrix_implementation.cpp | 42 ++++++++++++++---- src/osgUtil/SceneView.cpp | 27 ++++++++---- 6 files changed, 128 insertions(+), 53 deletions(-) diff --git a/examples/osgunittests/osgunittests.cpp b/examples/osgunittests/osgunittests.cpp index 834613eac..d7ad5886d 100644 --- a/examples/osgunittests/osgunittests.cpp +++ b/examples/osgunittests/osgunittests.cpp @@ -10,19 +10,15 @@ void testFrustum(double left,double right,double bottom,double top,double zNear, osg::Matrix f; f.makeFrustum(left,right,bottom,top,zNear,zFar); + double c_left=0; + double c_right=0; + double c_top=0; + double c_bottom=0; + double c_zNear=0; + double c_zFar=0; - double c_zNear = f(3,2) / (f(2,2)-1.0f); - double c_zFar = f(3,2) / (1.0f+f(2,2)); - double c_left = c_zNear * (f(2,0)-1.0f) / f(0,0); - double c_right = c_zNear * (1.0f+f(2,0)) / f(0,0); - - double c_top = c_zNear * (1+f(2,1)) / f(1,1); - double c_bottom = c_zNear * (f(2,1)-1.0f) / f(1,1); - - f.getFrustum(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar); - - std::cout << "testFrustum"<getOrtho(left, right, - bottom, top, - zNear, zFar); + return _projectionMatrix->getOrtho(left, right, + bottom, top, + zNear, zFar); } + return false; } -void SceneView::getProjectionMatrixAsFrustum(double& left, double& right, +bool SceneView::getProjectionMatrixAsFrustum(double& left, double& right, double& bottom, double& top, double& zNear, double& zFar) { if (_projectionMatrix.valid()) { - _projectionMatrix->getFrustum(left, right, - bottom, top, - zNear, zFar); + return _projectionMatrix->getFrustum(left, right, + bottom, top, + zNear, zFar); } + return false; } +bool SceneView::getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio, + double& zNear, double& zFar) +{ + if (_projectionMatrix.valid()) + { + return _projectionMatrix->getPerspective(fovy, aspectRatio, zNear, zFar); + } + return false; +} void SceneView::setViewMatrix(const osg::Matrix& matrix) {