Change the setViewAsLookAt method to use Vec3d rather than Vec3 for better precision
This commit is contained in:
parent
2db68f98a8
commit
f7c33bb2e8
@ -207,17 +207,20 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
|||||||
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
|
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
|
||||||
inline void setViewMatrix(const osg::Matrixd& matrix) { _viewMatrix.set(matrix); dirtyBound();}
|
inline void setViewMatrix(const osg::Matrixd& matrix) { _viewMatrix.set(matrix); dirtyBound();}
|
||||||
|
|
||||||
/** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */
|
|
||||||
void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up);
|
|
||||||
|
|
||||||
/** Get the view matrix. */
|
/** Get the view matrix. */
|
||||||
osg::Matrixd& getViewMatrix() { return _viewMatrix; }
|
osg::Matrixd& getViewMatrix() { return _viewMatrix; }
|
||||||
|
|
||||||
/** Get the const view matrix. */
|
/** Get the const view matrix. */
|
||||||
const osg::Matrixd& getViewMatrix() const { return _viewMatrix; }
|
const osg::Matrixd& getViewMatrix() const { return _viewMatrix; }
|
||||||
|
|
||||||
|
/** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */
|
||||||
|
void setViewMatrixAsLookAt(const osg::Vec3d& eye,const osg::Vec3d& center,const osg::Vec3d& up);
|
||||||
|
|
||||||
/** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
|
/** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
|
||||||
void getViewMatrixAsLookAt(osg::Vec3& eye,osg::Vec3& center,osg::Vec3& up,float lookDistance=1.0f);
|
void getViewMatrixAsLookAt(osg::Vec3d& eye,osg::Vec3d& center,osg::Vec3d& up,double lookDistance=1.0);
|
||||||
|
|
||||||
|
/** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
|
||||||
|
void getViewMatrixAsLookAt(osg::Vec3f& eye,osg::Vec3f& center,osg::Vec3f& up,float lookDistance=1.0f);
|
||||||
|
|
||||||
/** Get the inverse view matrix.*/
|
/** Get the inverse view matrix.*/
|
||||||
Matrixd getInverseViewMatrix() const;
|
Matrixd getInverseViewMatrix() const;
|
||||||
|
@ -231,12 +231,17 @@ bool Camera::getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
|
|||||||
return _projectionMatrix.getPerspective(fovy, aspectRatio, zNear, zFar);
|
return _projectionMatrix.getPerspective(fovy, aspectRatio, zNear, zFar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::setViewMatrixAsLookAt(const Vec3& eye,const Vec3& center,const Vec3& up)
|
void Camera::setViewMatrixAsLookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up)
|
||||||
{
|
{
|
||||||
setViewMatrix(osg::Matrixd::lookAt(eye,center,up));
|
setViewMatrix(osg::Matrixd::lookAt(eye,center,up));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::getViewMatrixAsLookAt(Vec3& eye,Vec3& center,Vec3& up,float lookDistance)
|
void Camera::getViewMatrixAsLookAt(Vec3d& eye,Vec3d& center,Vec3d& up,double lookDistance)
|
||||||
|
{
|
||||||
|
_viewMatrix.getLookAt(eye,center,up,lookDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::getViewMatrixAsLookAt(Vec3f& eye,Vec3f& center,Vec3f& up,float lookDistance)
|
||||||
{
|
{
|
||||||
_viewMatrix.getLookAt(eye,center,up,lookDistance);
|
_viewMatrix.getLookAt(eye,center,up,lookDistance);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
#include <osg/State>
|
#include <osg/State>
|
||||||
#include <osg/Stats>
|
#include <osg/Stats>
|
||||||
#include <osg/Texture>
|
#include <osg/Texture>
|
||||||
#include <osg/Vec3>
|
#include <osg/Vec3d>
|
||||||
|
#include <osg/Vec3f>
|
||||||
#include <osg/Vec4>
|
#include <osg/Vec4>
|
||||||
#include <osg/View>
|
#include <osg/View>
|
||||||
#include <osg/Viewport>
|
#include <osg/Viewport>
|
||||||
@ -328,11 +329,6 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera)
|
|||||||
__void__setViewMatrix__C5_osg_Matrixd_R1,
|
__void__setViewMatrix__C5_osg_Matrixd_R1,
|
||||||
"Set the view matrix. ",
|
"Set the view matrix. ",
|
||||||
"Can be thought of as setting the position of the world relative to the camera in camera coordinates. ");
|
"Can be thought of as setting the position of the world relative to the camera in camera coordinates. ");
|
||||||
I_Method3(void, setViewMatrixAsLookAt, IN, const osg::Vec3 &, eye, IN, const osg::Vec3 &, center, IN, const osg::Vec3 &, up,
|
|
||||||
Properties::NON_VIRTUAL,
|
|
||||||
__void__setViewMatrixAsLookAt__C5_osg_Vec3_R1__C5_osg_Vec3_R1__C5_osg_Vec3_R1,
|
|
||||||
"Set to the position and orientation of view matrix, using the same convention as gluLookAt. ",
|
|
||||||
"");
|
|
||||||
I_Method0(osg::Matrixd &, getViewMatrix,
|
I_Method0(osg::Matrixd &, getViewMatrix,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__osg_Matrixd_R1__getViewMatrix,
|
__osg_Matrixd_R1__getViewMatrix,
|
||||||
@ -343,9 +339,19 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera)
|
|||||||
__C5_osg_Matrixd_R1__getViewMatrix,
|
__C5_osg_Matrixd_R1__getViewMatrix,
|
||||||
"Get the const view matrix. ",
|
"Get the const view matrix. ",
|
||||||
"");
|
"");
|
||||||
I_MethodWithDefaults4(void, getViewMatrixAsLookAt, IN, osg::Vec3 &, eye, , IN, osg::Vec3 &, center, , IN, osg::Vec3 &, up, , IN, float, lookDistance, 1.0f,
|
I_Method3(void, setViewMatrixAsLookAt, IN, const osg::Vec3d &, eye, IN, const osg::Vec3d &, center, IN, const osg::Vec3d &, up,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__void__getViewMatrixAsLookAt__osg_Vec3_R1__osg_Vec3_R1__osg_Vec3_R1__float,
|
__void__setViewMatrixAsLookAt__C5_osg_Vec3d_R1__C5_osg_Vec3d_R1__C5_osg_Vec3d_R1,
|
||||||
|
"Set to the position and orientation of view matrix, using the same convention as gluLookAt. ",
|
||||||
|
"");
|
||||||
|
I_MethodWithDefaults4(void, getViewMatrixAsLookAt, IN, osg::Vec3d &, eye, , IN, osg::Vec3d &, center, , IN, osg::Vec3d &, up, , IN, double, lookDistance, 1.0,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__void__getViewMatrixAsLookAt__osg_Vec3d_R1__osg_Vec3d_R1__osg_Vec3d_R1__double,
|
||||||
|
"Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. ",
|
||||||
|
"");
|
||||||
|
I_MethodWithDefaults4(void, getViewMatrixAsLookAt, IN, osg::Vec3f &, eye, , IN, osg::Vec3f &, center, , IN, osg::Vec3f &, up, , IN, float, lookDistance, 1.0f,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__void__getViewMatrixAsLookAt__osg_Vec3f_R1__osg_Vec3f_R1__osg_Vec3f_R1__float,
|
||||||
"Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. ",
|
"Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. ",
|
||||||
"");
|
"");
|
||||||
I_Method0(osg::Matrixd, getInverseViewMatrix,
|
I_Method0(osg::Matrixd, getInverseViewMatrix,
|
||||||
|
Loading…
Reference in New Issue
Block a user