Commit 0c93d51c authored by Robert Menzel's avatar Robert Menzel

worked on camera, parallel shift mode should work (untested)

parent 6d8697b6
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#ifndef ACGL_SCENE_CAMERA_HH
#define ACGL_SCENE_CAMERA_HH
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
/*
* A generic camera class.
*/
#include <ACGL/ACGL.hh>
#include <ACGL/Math/Math.hh>
namespace ACGL{
namespace Scene{
class Camera
{
public:
Camera(void)
: mRight (),
mUp (),
mForward (),
mWidth (800),
mHeight (600),
mFOV (75.0f),
mNear (0.1f),
mFar (10000.0f),
mPitch (0.0f),
mYaw (0.0f),
mRoll (0.0f),
mPosition (3.0f, 2.0f, 3.0f),
mTarget (0.0f, 0.0f, 0.0f)
{
updateLocalCoordinateSystemByTarget();
updateOrientationByLocalCoordinateSystem();
}
Camera(
int_t _width,
int_t _height,
float _fov,
float _near,
float _far,
const glm::vec3& _position,
const glm::vec3& _target)
: mRight (),
mUp (),
mForward (),
mWidth (_width),
mHeight (_height),
mFOV (_fov),
mNear (_near),
mFar (_far),
mPitch (0.0f),
mYaw (0.0f),
mRoll (0.0f),
mPosition (_position),
mTarget (_target)
{
updateLocalCoordinateSystemByTarget();
updateOrientationByLocalCoordinateSystem();
}
Camera(const Camera& other)
: mRight (other.mRight),
mUp (other.mUp),
mForward (other.mForward),
mWidth (other.mWidth),
mHeight (other.mHeight),
mFOV (other.mFOV),
mNear (other.mNear),
mFar (other.mFar),
mPitch (other.mPitch),
mYaw (other.mYaw),
mRoll (other.mRoll),
mPosition (other.mPosition),
mTarget (other.mTarget)
{
}
~Camera(void) {}
inline float getAspectRatio (void) const { return (float)mWidth / (float)mHeight; }
inline const glm::vec3& getUpDirection (void) const { return mUp; }
inline const glm::vec3& getRightDirection (void) const { return mRight; }
inline const glm::vec3& getForwardDirection (void) const { return mForward; }
inline int_t getWidth (void) const { return mWidth; }
inline int_t getHeight (void) const { return mHeight; }
inline float getFOV (void) const { return mFOV; }
inline float getNear (void) const { return mNear; }
inline float getFar (void) const { return mFar; }
inline float getPitch (void) const { return mPitch; }
inline float getYaw (void) const { return mYaw; }
inline float getRoll (void) const { return mRoll; }
inline const glm::vec3& getPosition (void) const { return mPosition; }
inline const glm::vec3& getTarget (void) const { return mTarget; }
inline void setWidth (int_t _width) { mWidth = _width; }
inline void setHeight (int_t _height) { mHeight = _height; }
inline void setFOV (float _fov) { mFOV = _fov; }
inline void setNear (float _near) { mNear = _near; }
inline void setFar (float _far) { mFar = _far; }
inline void setPosition(const glm::vec3& _position, bool _moveTarget = true)
{
if(_moveTarget)
mTarget += _position - mPosition;
mPosition = _position;
if(!_moveTarget)
updateLocalCoordinateSystemByTarget(mUp);
}
inline void setPosition(const glm::vec3& _position, const glm::vec3& _up, bool _moveTarget = true)
{
if(_moveTarget)
mTarget += _position - mPosition;
mPosition = _position;
updateLocalCoordinateSystemByTarget(_up);
}
inline void setTarget(const glm::vec3& _target, bool _movePosition = true)
{
if(_movePosition)
mPosition += _target - mTarget;
mTarget = _target;
if(!_movePosition)
updateLocalCoordinateSystemByTarget(mUp);
}
inline void setPitch(float _pitch)
{
mPitch = _pitch;
updateLocalCoordinateSystemByOrientation();
mTarget = mPosition + glm::length(mTarget - mPosition) * mForward;
}
inline void setYaw(float _yaw)
{
mYaw = _yaw;
updateLocalCoordinateSystemByOrientation();
mTarget = mPosition + glm::length(mTarget - mPosition) * mForward;
}
inline void setRoll(float _roll)
{
mRoll = _roll;
}
inline void setPitchAroundTarget(float pitch)
{
mPitch = pitch;
updateLocalCoordinateSystemByOrientation();
mPosition = mTarget - glm::length(mTarget - mPosition) * mForward;
}
inline void setYawAroundTarget(float yaw)
{
mYaw = yaw;
updateLocalCoordinateSystemByOrientation();
mPosition = mTarget - glm::length(mTarget - mPosition) * mForward;
}
inline void setOrientation(float _pitch, float _yaw, float _roll)
{
mPitch = _pitch;
mYaw = _yaw;
mRoll = _roll;
updateLocalCoordinateSystemByOrientation();
}
glm::mat4 getProjectionMatrix() const;
glm::mat4 getViewMatrix() const;
glm::mat4 getInverseViewMatrix() const;
private:
void updateLocalCoordinateSystemByTarget(const glm::vec3& _up = glm::vec3(0.0f, 1.0f, 0.0f));
void updateLocalCoordinateSystemByOrientation(void);
void updateOrientationByLocalCoordinateSystem(void);
glm::vec3 mRight;
glm::vec3 mUp;
glm::vec3 mForward;
int_t mWidth;
int_t mHeight;
float mFOV;
float mNear;
float mFar;
float mPitch;
float mYaw;
float mRoll;
glm::vec3 mPosition;
glm::vec3 mTarget;
};
} // Scene
} // ACGL
#endif
#endif // ACGL_SCENE_CAMERA_HH
......@@ -49,6 +49,11 @@ namespace Scene{
class GenericCamera
{
public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Helping enums:
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
enum ProjectionMode
{
ISOMETRIC_PROJECTION = 0,
......@@ -69,56 +74,67 @@ class GenericCamera
EYE_RIGHT
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Constructor / Destructor / save&store
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Constructor of a camera.
*/
* Default Constructor of a camera.
*/
GenericCamera();
/**
* Destructor of a camera.
*/
* Constructs a camera from a string which holds all camera parameters. Note that this sets the viewport which
* might not fix the currect screen!
*/
GenericCamera( const std::string &_state );
/**
* Destructor of a camera.
*/
~GenericCamera() {}
/**
* Set the position of the camera.
* @param _position New position of the camera.
*/
void setPosition( const glm::vec3 &_position ) { mPosition = _position; }
glm::vec3 getPosition() const { return mPosition; }
/// Will change the look at distance!
/// Will change the rotation!
/// Uses stored up-vector as reference
void setTarget( const glm::vec3 &_target ) { setTarget(_target, getUpDirection()); }
/// Will change the look at distance!
/// Will change the rotation!
/// Uses given up-vector as reference
void setTarget( const glm::vec3 &_target, const glm::vec3 &_up );
/// Gets the reconstructed target
glm::vec3 getTarget() const { return mPosition + getForwardDirection() * getLookAtDistance(); }
/// Writes all internal state to one string
std::string storeStateToString() const;
/// Sets all internal state from a string
void setStateFromString( const std::string &_state );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Set / Get basic camera properties:
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Set the distance between the eyes (only needed for stereo rendering).
* @param _eyeDistance Eye distance in meter(!)
* @param _eyeDistance Inter pupil distance in meter(!) (distance between the centers of the eyes)
*/
void setEyeDistance( float _eyeDistance ) { mEyeDistance = _eyeDistance; }
float getEyeDistance() const { return mEyeDistance; }
/**
* Set the projection mode of the camera.
* Set the projection mode of the camera.
* @param _projection New projection mode of the camera.
*/
void setProjectionMode( ProjectionMode _projection ) { mProjectionMode = _projection; }
ProjectionMode getProjectionMode() const { return mProjectionMode; }
/**
* Set the stereo mode of the camera.
* Set the stereo mode of the camera. In mode MONO the set eye will get ignored (see below).
* @param _stereoMode New stereo mode of the camera.
*/
void setStereoMode( StereoMode _stereoMode ) { mStereoMode = _stereoMode; }
StereoMode getStereoMode() const { return mStereoMode; }
/// Sets the currently active eye
/**
* Sets the currently active eye. In stereo mode MONO this setting is ignored.
* In the stereo modes (PARALLEL_SHIFT, OFF_AXIS, TOE_IN) it is used to
* define the default eye that is assumed for the generic get*Matrix() functions.
* (Matrices for specific eyes can still get queried directly without setting the
* eye explicitly before each call).
*/
void setEye( Eye _eye ) { mCurrentEye = _eye; }
Eye getEye() const { return mCurrentEye; }
......@@ -164,41 +180,49 @@ class GenericCamera
/// Gets the far clip distance
float getFarClippingPlane() const { return mFarClippingPlane; }
/**
* Set the distance of the camera to the object we're looking at.
* Will change the target!
* @param _distance New focal distance of the camera.
*/
void setLookAtDistance( float _distance );
/// Gets the look-at distance
float getLookAtDistance() const { return mLookAtDistance; }
/// Gets size of the viewport
glm::uvec2 getViewportSize() const { return mViewportSize; }
/// Gets width of the viewport
unsigned int getViewportWidth() const { return mViewportSize.x; }
/// Gets height of the viewport
unsigned int getViewportHeight() const { return mViewportSize.y; }
/// Sets size of the viewport. NOTE: DOES NOT CHANGE THE ASPECT RATIO! Use resize() if you want to change that as well!
void setViewportSize( glm::uvec2 _size ) { mViewportSize = _size; }
/// Sets size of the viewport. NOTE: DOES NOT CHANGE THE ASPECT RATIO! Use resize() if you want to change that as well!
void setViewportSize( unsigned int _width, unsigned int _height ) { setViewportSize(glm::uvec2(_width, _height)); }
/// Moves the camera by a given vector (in eyespace)
void move( const glm::vec3 &_vector );
void moveRight( float _distance ) { move( glm::vec3(_distance,0,0) ); }
void moveBack( float _distance ) { move( glm::vec3(0,0,_distance) ); }
void moveUp( float _distance ) { move( glm::vec3(0,_distance,0) ); }
void moveLeft( float _distance ) { move( glm::vec3(-_distance,0,0) ); }
void moveForward( float _distance ) { move( glm::vec3(0,0,-_distance) ); }
void moveDown( float _distance ) { move( glm::vec3(0,-_distance,0) ); }
/// Sets new viewport size and calculates new aspect ratio
void resize(int _newWidth, int _newHeight) { setViewportSize(_newWidth, _newHeight); setAspectRatio(_newWidth / (float)_newHeight); }
/**
* Look around with a mouse, works like a FPS camera:
* No roll possible.
* Up/down is limited to 90 degree.
* This method assumes there is no roll in the current camera rotation, if
* there is a roll component, it will get destroyed -> don't mix this
* way to stear with other, more flexible methods!
* @param _deltaX How much the mouse moved on the viewport (0..1, 1 = full viewport width)
* @param _deltaY How much the mouse moved on the viewport (0..1, 1 = full viewport height)
*/
void FPSstyleLookAround( float _deltaX, float _deltaY );
/// The focal length is coupled to the sensor size in real cameras. As this camera does not model a
/// sensor size in mm, the focal length is given in pixels and is in relation to the viewports resolution.
/// This model is also used by bundler.
/// Note that this gives only useful results if the viewports aspect ratio is the same as the
/// projections aspect ratio!
float getFocalLenghtInPixel() const;
/// Sets the focal length in pixel relative to the viewport dimension. This will change the FoV.
/// See getFocalLenghtInPixel() for more information.
void setFocalLengthInPixel( float _focalLengthInPixel );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Set / Get the matrices:
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//
// Generic rotation and translation matrices: In mono rendering these represent the camera.
// In stereo rendering these represent the virtual camera position between the two cameras
// actually used.
//
/// Gets the orthonormal rotation matrix (mat3)
const glm::mat3 &getRotationMatrix3() const { return mRotationMatrix; }
/// Gets the inverse orthonormal rotation matrix (mat3)
glm::mat3 getInverseRotationMatrix3() const { return glm::transpose(mRotationMatrix); }
/// Gets the orthonormal rotation matrix (mat3)
/// Gets the orthonormal rotation matrix as a mat4
glm::mat4 getRotationMatrix4() const { return glm::mat4(mRotationMatrix); }
/// Sets the rotation matrix (mat3)
......@@ -211,102 +235,127 @@ class GenericCamera
/// Gets the translation matrix of this camera
glm::mat4 getTranslationMatrix4() const;
/// Get the unit up direction
glm::vec3 getUpDirection () const;
/// Get the unit right direction
glm::vec3 getRightDirection () const;
/// Get the unit forward direction
glm::vec3 getForwardDirection() const;
/// Gets the currently active projection matrix (depends on stereo mode and current eye)
glm::mat4 getProjectionMatrix() const;
///////////////////////////////////////////////////////////////////////////////////////////
//
// Generic view and projection matrices. These obey the set stereo/eye settings.
// (When in doubt, use these!)
//
/**
* Compute a camera projection matrix for stereo rendering.
* In stereo mode, the Cameras position is the point in the middle between the two eyes.
* So we just need one additional info to calculate two matrices:
* @param stereoCamMode How to calculate the cameras (toe-in, off-axis).
*/
glm::mat4 getMonoProjectionMatrix() const;
/*
glm::mat4 getStereoProjectionMatrix( bool _leftEye, StereoMode _stereoMode = OFF_AXIS );
glm::mat4 getLeftStereoProjectionMatrix() { return getStereoProjectionMatrix(true, mStereoMode); }
glm::mat4 getRightStereoProjectionMatrix() { return getStereoProjectionMatrix(false, mStereoMode); }
glm::mat4 getLeftParallelShiftStereoProjectionMatrix() { return getStereoProjectionMatrix(true, PARALLEL_SHIFT); }
glm::mat4 getRightParallelShiftStereoProjectionMatrix() { return getStereoProjectionMatrix(false, PARALLEL_SHIFT); }
glm::mat4 getLeftOffAxisStereoProjectionMatrix() { return getStereoProjectionMatrix(true, OFF_AXIS); }
glm::mat4 getRightOffAxisStereoProjectionMatrix() { return getStereoProjectionMatrix(false, OFF_AXIS); }
glm::mat4 getLeftToeInStereoProjectionMatrix() { return getStereoProjectionMatrix(true, TOE_IN); }
glm::mat4 getRightToeInStereoProjectionMatrix() { return getStereoProjectionMatrix(false, TOE_IN); }
*/
// mono:
/// Gets the currently active view matrix (depends on stereo mode and current eye)
glm::mat4 getViewMatrix() const;
/// Gets the currently active view matrix (depends on stereo mode and current eye)
glm::mat4 getInverseViewMatrix() const;
/// Gets the currently active projection matrix (depends on stereo mode and current eye)
glm::mat4 getProjectionMatrix() const;
///////////////////////////////////////////////////////////////////////////////////////////
//
// Explicit view and projection matrices. These DON'T obey the set stereo/eye settings.
//
/// Gets the view matrix for non-stereo rendering EVEN IF A STEREO MODE IS SET!
glm::mat4 getMonoViewMatrix() const;
glm::mat4 getMonoInverseViewMatrix() const;
/**
* Compute a camera view matrix for stereo rendering.
* In stereo mode, the view matrix is the mono view matrix but also the shift
* by half the eye distance to the left/right and a small rotation inwards in
* case of toe in mode.
* @param stereoCamMode How to calculate the cameras (toe-in, off-axis).
*
* These methods get the stereo matrix independent of the set mode for this camera.
*/
glm::mat4 getMonoViewMatrix() const;
glm::mat4 getMonoInverseViewMatrix() const;
/*
glm::mat4 getStereoViewMatrix( bool _leftEye, StereoMode _stereoMode = OFF_AXIS );
glm::mat4 getLeftStereoViewMatrix() { return getStereoViewMatrix(true, mStereoMode); }
glm::mat4 getRightStereoViewMatrix() { return getStereoViewMatrix(false, mStereoMode); }
glm::mat4 getLeftParallelShiftStereoViewMatrix() { return getStereoViewMatrix(true, PARALLEL_SHIFT); }
glm::mat4 getRightParallelShiftStereoViewMatrix() { return getStereoViewMatrix(false, PARALLEL_SHIFT); }
glm::mat4 getLeftOffAxisStereoViewMatrix() { return getStereoViewMatrix(true, OFF_AXIS); }
glm::mat4 getRightOffAxisStereoViewMatrix() { return getStereoViewMatrix(false, OFF_AXIS); }
glm::mat4 getLeftToeInStereoViewMatrix() { return getStereoViewMatrix(true, TOE_IN); }
glm::mat4 getRightToeInStereoViewMatrix() { return getStereoViewMatrix(false, TOE_IN); }
*/
glm::mat4 getStereoViewMatrix( bool _leftEye, StereoMode _stereoMode = OFF_AXIS ) const;
glm::mat4 getLeftStereoViewMatrix() const { return getStereoViewMatrix(true, mStereoMode); }
glm::mat4 getRightStereoViewMatrix()const { return getStereoViewMatrix(false, mStereoMode); }
glm::mat4 getLeftParallelShiftStereoViewMatrix() const { return getStereoViewMatrix(true, PARALLEL_SHIFT); }
glm::mat4 getRightParallelShiftStereoViewMatrix()const { return getStereoViewMatrix(false, PARALLEL_SHIFT); }
glm::mat4 getLeftOffAxisStereoViewMatrix() const { return getStereoViewMatrix(true, OFF_AXIS); }
glm::mat4 getRightOffAxisStereoViewMatrix() const { return getStereoViewMatrix(false, OFF_AXIS); }
glm::mat4 getLeftToeInStereoViewMatrix() const { return getStereoViewMatrix(true, TOE_IN); }
glm::mat4 getRightToeInStereoViewMatrix() const { return getStereoViewMatrix(false, TOE_IN); }
/// Gets the projection matrix for non-stereo rendering EVEN IF A STEREO MODE IS SET!
glm::mat4 getMonoProjectionMatrix() const;
/// Gets size of the viewport
glm::uvec2 getViewportSize() const { return mViewportSize; }
/// Gets width of the viewport
unsigned int getViewportWidth() const { return mViewportSize.x; }
/// Gets height of the viewport
unsigned int getViewportHeight() const { return mViewportSize.y; }
/// Sets size of the viewport
void setViewportSize( glm::uvec2 _size ) { mViewportSize = _size; }
/// Sets size of the viewport
void setViewportSize( unsigned int _width, unsigned int _height ) { setViewportSize(glm::uvec2(_width, _height)); }
/**
* Compute a camera projection matrix for stereo rendering.
* In stereo mode, the Cameras position is the point in the middle between the two eyes.
* So we just need one additional info to calculate two matrices:
*/
glm::mat4 getStereoProjectionMatrix( bool _leftEye, StereoMode _stereoMode = OFF_AXIS ) const;
glm::mat4 getLeftStereoProjectionMatrix() const { return getStereoProjectionMatrix(true, mStereoMode); }
glm::mat4 getRightStereoProjectionMatrix() const { return getStereoProjectionMatrix(false, mStereoMode); }
glm::mat4 getLeftParallelShiftStereoProjectionMatrix() const { return getStereoProjectionMatrix(true, PARALLEL_SHIFT); }
glm::mat4 getRightParallelShiftStereoProjectionMatrix()const { return getStereoProjectionMatrix(false, PARALLEL_SHIFT); }
glm::mat4 getLeftOffAxisStereoProjectionMatrix() const { return getStereoProjectionMatrix(true, OFF_AXIS); }
glm::mat4 getRightOffAxisStereoProjectionMatrix() const { return getStereoProjectionMatrix(false, OFF_AXIS); }
glm::mat4 getLeftToeInStereoProjectionMatrix() const { return getStereoProjectionMatrix(true, TOE_IN); }
glm::mat4 getRightToeInStereoProjectionMatrix() const { return getStereoProjectionMatrix(false, TOE_IN); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Set / Get properties that move the camera around (or rotate etc.)
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Sets new viewport size and calculates new aspect ratio
void resize(int _newWidth, int _newHeight) { setViewportSize(_newWidth, _newHeight); setAspectRatio(_newWidth / (float)_newHeight); }
/**
* Set the position of the camera.
* @param _position New position of the camera.
*/
void setPosition( const glm::vec3 &_position ) { mPosition = _position; }
glm::vec3 getPosition() const { return mPosition; }
/// Moves the camera by a given vector (in eyespace)
void move( const glm::vec3 &_vector );
void moveRight( float _distance ) { move( glm::vec3(_distance,0,0) ); }
void moveBack( float _distance ) { move( glm::vec3(0,0,_distance) ); }
void moveUp( float _distance ) { move( glm::vec3(0,_distance,0) ); }
void moveLeft( float _distance ) { move( glm::vec3(-_distance,0,0) ); }
void moveForward( float _distance ) { move( glm::vec3(0,0,-_distance) ); }
void moveDown( float _distance ) { move( glm::vec3(0,-_distance,0) ); }
/// Writes all internal state to one string
std::string storeStateToString() const;
/**
* Set the distance of the camera to the object we're looking at.
* Will change the target!
* @param _distance New focal distance of the camera.
*/
void setLookAtDistance( float _distance );
/// Gets the look-at distance
float getLookAtDistance() const { return mLookAtDistance; }
/// Sets all internal state from a string
void setStateFromString( const std::string &_state );
/// Will change the look at distance!
/// Will change the rotation!
/// Uses stored up-vector as reference
void setTarget( const glm::vec3 &_target ) { setTarget(_target, getUpDirection()); }
/// The focal length is coupled to the sensor size in real cameras. As this camera does not model a
/// sensor size in mm, the focal length is given in pixels and is in relation to the viewports resolution.
/// This model is also used by bundler.
/// Note that this gives only useful results if the viewports aspect ratio is the same as the
/// projections aspect ratio!
float getFocalLenghtInPixel() const;
/// Will change the look at distance!
/// Will change the rotation!
/// Uses given up-vector as reference
void setTarget( const glm::vec3 &_target, const glm::vec3 &_up );
/// Sets the focal length in pixel relative to the viewport dimension. This will change the FoV.
/// See getFocalLenghtInPixel() for more information.
void setFocalLengthInPixel( float _focalLengthInPixel );
/// Gets the reconstructed target
glm::vec3 getTarget() const { return mPosition + getForwardDirection() * getLookAtDistance(); }
/// The focal length is coupled to the sensor size in real cameras. As this camera does not model a
/// sensor size in mm (yet), a 135 (35mm) film size is assumed (framesize of 36*24mm).
/// The assumed sensor size might change in case other formats get supported later on but
/// 24mm height should be the default.
float getFocalLenghtInMM() const;
/// Get the unit up direction
glm::vec3 getUpDirection () const;
/// Get the unit right direction
glm::vec3 getRightDirection () const;
/// Get the unit forward direction
glm::vec3 getForwardDirection() const;
/// Sets the focal length in mm assuming a 135 film. This will change the FoV.
/// See getFocalLenghtInMM() for more information.
void setFocalLengthInMM( float _focalLengthInMM );
/**
* Look around with a mouse, works like a FPS camera:
* No roll possible.
* Up/down is limited to 90 degree.
* This method assumes there is no roll in the current camera rotation, if
* there is a roll component, it will get destroyed -> don't mix this
* way to stear with other, more flexible methods!
* @param _deltaX How much the mouse moved on the viewport (0..1, 1 = full viewport width)
* @param _deltaY How much the mouse moved on the viewport (0..1, 1 = full viewport height)
*/
void FPSstyleLookAround( float _deltaX, float _deltaY );
private:
/// the Matrix with the camera position/orientation.
......@@ -328,6 +377,7 @@ class GenericCamera
/// Current camera position
glm::vec3 mPosition;
/// Current camera rotation
glm::mat3 mRotationMatrix;
/// Current camera projection mode
......
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#include <ACGL/Scene/Camera.hh>
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
using namespace ACGL;
using namespace ACGL::Scene;
glm::mat4 Camera::getProjectionMatrix(void) const
{
// returns a projection matrix as gluPerspective would do
return glm::perspective( mFOV, getAspectRatio(), mNear, mFar );
}
glm::mat4 Camera::getViewMatrix(void) const
{
glm::mat4 mView;
mView[0][0] = mRight.x;
mView[0][1] = mUp.x;
mView[0][2] = -mForward.x;
mView[1][0] = mRight.y;
mView[1][1] = mUp.y;
mView[1][2] = -mForward.y;
mView[2][0] = mRight.z;
mView[2][1] = mUp.z;