wrap/gl camera and shot const correctness
This commit is contained in:
parent
cfe0511f35
commit
f1530c585b
|
|
@ -139,35 +139,35 @@ static void SetGLIsometricProj(float x1, float x2, float y1, float y2, float z1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get OpenGL-like frustum from a vcg camera (intrinsics)
|
/// get OpenGL-like frustum from a vcg camera (intrinsics)
|
||||||
static void GetFrustum(vcg::Camera<S> & intrinsics, S & sx,S & dx,S & bt,S & tp,S & f)
|
static void GetFrustum(const vcg::Camera<S> & intrinsics, S & sx,S & dx,S & bt,S & tp,S & f)
|
||||||
{
|
{
|
||||||
intrinsics.GetFrustum(sx,dx,bt,tp,f);
|
intrinsics.GetFrustum(sx,dx,bt,tp,f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// set the OpenGL PROJECTION matrix to match the camera (intrinsics). requires near and far plane
|
/// set the OpenGL PROJECTION matrix to match the camera (intrinsics). requires near and far plane
|
||||||
static void TransformGL(vcg::Camera<S> & camera, S nearDist, S farDist )
|
static void TransformGL(const vcg::Camera<S> & camera, S nearDist, S farDist )
|
||||||
{
|
{
|
||||||
S sx,dx,bt,tp,nr;
|
S sx,dx,bt,tp,nr;
|
||||||
camera.GetFrustum(sx,dx,bt,tp,nr);
|
camera.GetFrustum(sx,dx,bt,tp,nr);
|
||||||
|
|
||||||
if(camera.cameraType == CameraType::PERSPECTIVE) {
|
if(camera.cameraType == CameraType::PERSPECTIVE) {
|
||||||
S ratio = nearDist/nr;
|
S ratio = nearDist/nr;
|
||||||
sx *= ratio;
|
sx *= ratio;
|
||||||
dx *= ratio;
|
dx *= ratio;
|
||||||
bt *= ratio;
|
bt *= ratio;
|
||||||
tp *= ratio;
|
tp *= ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(glGetError()==0);
|
assert(glGetError()==0);
|
||||||
|
|
||||||
switch(camera.cameraType)
|
switch(camera.cameraType)
|
||||||
{
|
{
|
||||||
case CameraType::PERSPECTIVE: glFrustum(sx,dx,bt,tp,nearDist,farDist); break;
|
case CameraType::PERSPECTIVE: glFrustum(sx,dx,bt,tp,nearDist,farDist); break;
|
||||||
case CameraType::ORTHO: glOrtho(sx,dx,bt,tp,nearDist,farDist); break;
|
case CameraType::ORTHO: glOrtho(sx,dx,bt,tp,nearDist,farDist); break;
|
||||||
case CameraType::ISOMETRIC: SetGLIsometricProj(sx,dx,bt,tp,nearDist,farDist); break;
|
case CameraType::ISOMETRIC: SetGLIsometricProj(sx,dx,bt,tp,nearDist,farDist); break;
|
||||||
case CameraType::CAVALIERI: SetGLCavalieriProj(sx,dx,bt,tp,nearDist,farDist); break;
|
case CameraType::CAVALIERI: SetGLCavalieriProj(sx,dx,bt,tp,nearDist,farDist); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(glGetError()==0);
|
assert(glGetError()==0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,13 +95,13 @@ struct GlShot {
|
||||||
typedef GlCamera<typename ShotType::CameraType> GlCameraType;
|
typedef GlCamera<typename ShotType::CameraType> GlCameraType;
|
||||||
|
|
||||||
/// returns the OpenGL 4x4 MODELVIEW matrix that describes the shot position and orientation (extrinsics)
|
/// returns the OpenGL 4x4 MODELVIEW matrix that describes the shot position and orientation (extrinsics)
|
||||||
static void MatrixGL(ShotType & shot,vcg::Matrix44<ScalarType> & m)
|
static void MatrixGL(const ShotType & shot,vcg::Matrix44<ScalarType> & m)
|
||||||
{
|
{
|
||||||
m = shot.GetWorldToExtrinsicsMatrix();
|
m = shot.GetWorldToExtrinsicsMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// set the OpenGL MODELVIEW matrix to match the shot (extrinsics)
|
/// set the OpenGL MODELVIEW matrix to match the shot (extrinsics)
|
||||||
static void TransformGL(vcg::Shot<ScalarType> & shot)
|
static void TransformGL(const vcg::Shot<ScalarType> & shot)
|
||||||
{
|
{
|
||||||
vcg::Matrix44<ScalarType> m;
|
vcg::Matrix44<ScalarType> m;
|
||||||
MatrixGL(shot,m);
|
MatrixGL(shot,m);
|
||||||
|
|
@ -109,7 +109,7 @@ static void TransformGL(vcg::Shot<ScalarType> & shot)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// set the OpenGL PROJECTION and MODELVIEW matrix to match camera+shot. requires near and far plane
|
/// set the OpenGL PROJECTION and MODELVIEW matrix to match camera+shot. requires near and far plane
|
||||||
static void SetView(vcg::Shot<ScalarType> & shot, ScalarType nearDist, ScalarType farDist)
|
static void SetView(const vcg::Shot<ScalarType> & shot, ScalarType nearDist, ScalarType farDist)
|
||||||
{
|
{
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|
@ -170,7 +170,7 @@ static ScalarType GetFarPlane(vcg::Shot<ScalarType> & shot, vcg::Box3<ScalarType
|
||||||
|
|
||||||
|
|
||||||
/// given a shot and the mesh bounding box, return near and far plane (exact)
|
/// given a shot and the mesh bounding box, return near and far plane (exact)
|
||||||
static void GetNearFarPlanes(vcg::Shot<ScalarType> & shot, vcg::Box3<ScalarType> bbox, ScalarType &nr, ScalarType &fr)
|
static void GetNearFarPlanes(const vcg::Shot<ScalarType> & shot, vcg::Box3<ScalarType> bbox, ScalarType &nr, ScalarType &fr)
|
||||||
{
|
{
|
||||||
vcg::Point3<ScalarType> zaxis = shot.Axis(2);
|
vcg::Point3<ScalarType> zaxis = shot.Axis(2);
|
||||||
ScalarType offset = zaxis * shot.GetViewPoint();
|
ScalarType offset = zaxis * shot.GetViewPoint();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue