]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/camera.cpp
Store simpler states by value in PipelineState
[libs/gl.git] / source / render / camera.cpp
index 9b8b0c778d0c5fc68f784efaee4c74b886801ddb..3ace92b9ecb7166de54fa20b33f07c943997dae1 100644 (file)
@@ -7,22 +7,29 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-Camera::Camera():
-       fov(Geometry::Angle<float>::from_turns(0.125)),
-       height(0),
-       aspect(4.0/3.0),
-       clip_near(0.1),
-       clip_far(10),
-       frustum_x(0),
-       frustum_y(0),
-       position(0, 0, 0),
-       look_dir(0, 0, -1),
-       up_dir(0, 1, 0)
+Camera::Camera()
 {
        update_projection_matrix();
        update_object_matrix();
 }
 
+void Camera::copy_parameters(const Camera &source)
+{
+       fov = source.fov;
+       height = source.height;
+       aspect = source.aspect;
+       clip_near = source.clip_near;
+       clip_far = source.clip_far;
+       frustum_x = source.frustum_x;
+       frustum_y = source.frustum_y;
+       rotate = source.rotate;
+       position = source.position;
+       look_dir = source.look_dir;
+       up_dir = source.up_dir;
+       update_projection_matrix();
+       update_object_matrix();
+}
+
 void Camera::set_field_of_view(const Geometry::Angle<float> &f)
 {
        fov = f;
@@ -133,6 +140,7 @@ void Camera::update_projection_matrix()
        proj_matrix = Matrix::rotation(rotate, Vector3(0, 0, 1))*proj_matrix;
 
        shdata.uniform("clip_eye_matrix", proj_matrix);
+       shdata.uniform("eye_clip_matrix", invert(proj_matrix));
 }
 
 void Camera::update_object_matrix()
@@ -146,6 +154,7 @@ void Camera::update_object_matrix()
        matrix = Matrix::from_columns(columns);
        view_matrix = invert(matrix);
 
+       shdata.uniform("world_eye_matrix", matrix);
        shdata.uniform("eye_world_matrix", view_matrix);
 }