Browse Source

Getters for near and far camera clipping plane.

vectorfields
Vladimír Vondruš 15 years ago
parent
commit
8c004ef77d
  1. 6
      src/Camera.cpp
  2. 7
      src/Camera.h

6
src/Camera.cpp

@ -40,6 +40,9 @@ void Camera::setActive(Scene* _scene) {
}
void Camera::setOrthographic(GLfloat size, GLfloat near, GLfloat far) {
_near = near;
_far = far;
/* Scale the volume down so it fits in (-1, 1) in all directions */
GLfloat xyScale = 2/size;
GLfloat zScale = 2/(far-near);
@ -52,6 +55,9 @@ void Camera::setOrthographic(GLfloat size, GLfloat near, GLfloat far) {
}
void Camera::setPerspective(GLfloat fov, GLfloat near, GLfloat far) {
_near = near;
_far = far;
/* First move the volume on z in (-1, 1) range */
rawProjectionMatrix = Matrix4::translation(0, 0, 2*far*near/(far+near));

7
src/Camera.h

@ -84,6 +84,12 @@ class Camera: public Object {
*/
void setPerspective(GLfloat fov, GLfloat near, GLfloat far);
/** @brief Near clipping plane */
inline GLfloat near() const { return _near; }
/** @brief Far clipping plane */
inline GLfloat far() const { return _far; }
/**
* @brief Camera matrix
*
@ -129,6 +135,7 @@ class Camera: public Object {
Matrix4 rawProjectionMatrix;
Matrix4 _projectionMatrix;
Matrix4 _cameraMatrix;
GLfloat _near, _far;
Scene* _active;
int viewportWidth, viewportHeight;

Loading…
Cancel
Save