32 #ifndef StereoCamera_INCLUDE_ONCE 33 #define StereoCamera_INCLUDE_ONCE 97 mLeftCamera->setViewport( mMonoCamera->viewport() );
98 mRightCamera->setViewport( mMonoCamera->viewport() );
100 float aspect_ratio = (float)mMonoCamera->viewport()->width()/mMonoCamera->viewport()->height();
101 float near_clip = mMonoCamera->nearPlane();
102 float far_clip = mMonoCamera->farPlane();
104 float wd2 = near_clip *
tan(radians);
105 float ndfl = near_clip / mConvergence;
106 float top, bottom, left, right;
110 left = - aspect_ratio * wd2 - mEyeSeparation/2 * ndfl;
111 right = aspect_ratio * wd2 - mEyeSeparation/2 * ndfl;
112 mLeftCamera->setProjectionFrustum(left, right, bottom, top, near_clip, far_clip);
113 mLeftCamera->setViewMatrix(
mat4::getTranslation(-mEyeSeparation/2, 0, 0)*mMonoCamera->viewMatrix() );
115 left = - aspect_ratio * wd2 + mEyeSeparation/2 * ndfl;
116 right = aspect_ratio * wd2 + mEyeSeparation/2 * ndfl;
117 mRightCamera->setProjectionFrustum(left, right, bottom, top, near_clip, far_clip);
118 mRightCamera->setViewMatrix(
mat4::getTranslation(+mEyeSeparation/2, 0, 0)*mMonoCamera->viewMatrix() );
126 float mEyeSeparation;
Camera * monoCamera()
The Camera used to drive the left and right cameras.
Camera * leftCamera()
The Camera representing the left eye.
void setRightCamera(Camera *camera)
The Camera representing the right eye.
const Camera * leftCamera() const
The Camera representing the left eye.
void setEyeSeparation(float eye_separation)
The distance between the center of the two eyes.
void setConvergence(float convergence)
Distance of the convergence plane from the camera.
void setMonoCamera(Camera *camera)
The Camera used to drive the left and right cameras.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Visualization Library main namespace.
Utility class to setup a pair of left/right cameras for stereo rendering.
The base class for all the reference counted objects.
float eyeSeparation() const
The distance between the center of the two eyes.
const float fDEG_TO_RAD
Constant to convert degree into radian using float precision.
const Camera * monoCamera() const
The Camera used to drive the left and right cameras.
static Matrix4 & getTranslation(Matrix4 &out, const Vector3< float > &v)
void updateLeftRightCameras()
Updates the left and right cameras based on the mono camera view matrix and viewport.
Camera * rigthCamera()
The Camera representing the right eye.
const Camera * rightCamera() const
The Camera representing the right eye.
The ref<> class is used to reference-count an Object.
float convergence() const
Distance of the convergence plane from the camera.
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
void setLeftCamera(Camera *camera)
The Camera representing the left eye.