diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 5a6899467c..303fa136c1 100755 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -11,16 +11,18 @@ //------------------------ Camera::Camera() { - mode = CAMERA_MODE_THIRD_PERSON; - fieldOfView = 60.0; // default - yaw = 0.0; - pitch = 0.0; - roll = 0.0; - up = 0.0; - distance = 0.0; - targetPosition = glm::vec3( 0.0, 0.0, 0.0 ); - position = glm::vec3( 0.0, 0.0, 0.0 ); - orientation.setToIdentity(); + _mode = CAMERA_MODE_THIRD_PERSON; + _fieldOfView = 60.0; // default + _nearClip = 0.1; // default + _farClip = 50.0; // default + _yaw = 0.0; + _pitch = 0.0; + _roll = 0.0; + _up = 0.0; + _distance = 0.0; + _targetPosition = glm::vec3( 0.0, 0.0, 0.0 ); + _position = glm::vec3( 0.0, 0.0, 0.0 ); + _orientation.setToIdentity(); } @@ -28,21 +30,21 @@ Camera::Camera() //------------------------ void Camera::update() { - double radian = ( yaw / 180.0 ) * PIE; + float radian = ( _yaw / 180.0 ) * PIE; //these need to be checked to make sure they correspond to the cordinate system. - double x = distance * -sin( radian ); - double z = distance * cos( radian ); - double y = up; + float x = _distance * -sin( radian ); + float z = _distance * cos( radian ); + float y = _up; - position = targetPosition + glm::vec3( x, y, z ); + _position = _targetPosition + glm::vec3( x, y, z ); //------------------------------------------------------------------------ //geterate the ortho-normals for the orientation based on the Euler angles //------------------------------------------------------------------------ - orientation.setToIdentity(); - orientation.yaw ( yaw ); - orientation.pitch ( pitch ); - orientation.roll ( roll ); + _orientation.setToIdentity(); + _orientation.yaw ( _yaw ); + _orientation.pitch ( _pitch ); + _orientation.roll ( _roll ); } diff --git a/interface/src/Camera.h b/interface/src/Camera.h index 1c8c3335b5..bd4e9d0ecb 100755 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -13,50 +13,63 @@ enum CameraMode { - CAMERA_MODE_NULL = -1, - CAMERA_MODE_FIRST_PERSON, - CAMERA_MODE_THIRD_PERSON, - CAMERA_MODE_MY_OWN_FACE, - NUM_CAMERA_MODES + CAMERA_MODE_NULL = -1, + CAMERA_MODE_FIRST_PERSON, + CAMERA_MODE_THIRD_PERSON, + CAMERA_MODE_MY_OWN_FACE, + NUM_CAMERA_MODES }; class Camera { public: - Camera(); - - void update(); - - void setMode ( CameraMode m ) { mode = m; } - void setYaw ( float y ) { yaw = y; } - void setPitch ( float p ) { pitch = p; } - void setRoll ( float r ) { roll = r; } - void setUp ( float u ) { up = u; } - void setDistance ( float d ) { distance = d; } - void setTargetPosition ( glm::vec3 t ) { targetPosition = t; }; - void setPosition ( glm::vec3 p ) { position = p; }; - void setOrientation ( Orientation o ) { orientation.set(o); } + Camera(); - float getYaw () { return yaw; } - float getPitch () { return pitch; } - float getRoll () { return roll; } - glm::vec3 getPosition () { return position; } - Orientation getOrientation () { return orientation; } - CameraMode getMode () { return mode; } + void update(); + + void setMode ( CameraMode m ) { _mode = m; } + void setYaw ( float y ) { _yaw = y; } + void setPitch ( float p ) { _pitch = p; } + void setRoll ( float r ) { _roll = r; } + void setUp ( float u ) { _up = u; } + void setDistance ( float d ) { _distance = d; } + void setTargetPosition ( glm::vec3 t ) { _targetPosition = t; }; + void setPosition ( glm::vec3 p ) { _position = p; }; + void setOrientation ( Orientation o ) { _orientation.set(o); } + void setFieldOfView ( float f ) { _fieldOfView = f; } + void setAspectRatio ( float a ) { _aspectRatio = a; } + void setNearClip ( float n ) { _nearClip = n; } + void setFarClip ( float f ) { _farClip = f; } + + float getYaw () { return _yaw; } + float getPitch () { return _pitch; } + float getRoll () { return _roll; } + glm::vec3 getPosition () { return _position; } + Orientation getOrientation () { return _orientation; } + CameraMode getMode () { return _mode; } + float getFieldOfView () { return _fieldOfView; } + float getAspectRatio () { return _aspectRatio; } + float getNearClip () { return _nearClip; } + float getFarClip () { return _farClip; } private: - CameraMode mode; - glm::vec3 position; - glm::vec3 targetPosition; - float fieldOfView; - float yaw; - float pitch; - float roll; - float up; - float distance; - Orientation orientation; + CameraMode _mode; + glm::vec3 _position; + glm::vec3 _targetPosition; + float _yaw; + float _pitch; + float _roll; + float _up; + float _distance; + Orientation _orientation; + + // Lens attributes + float _fieldOfView; // in degrees + float _aspectRatio; // width/height + float _nearClip; // in world units? - XXXBHG - we need to think about this! + float _farClip; // in world units? }; #endif