diff --git a/src/Camera.cpp b/src/Camera.cpp index 66fb04e60..6cebf1ff3 100644 --- a/src/Camera.cpp +++ b/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)); diff --git a/src/Camera.h b/src/Camera.h index 51f01df4b..ea44a34f6 100644 --- a/src/Camera.h +++ b/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;