no clue :) just to push it
[demo] / src / camera.cc
index 73980b8..7de5501 100644 (file)
@@ -3,16 +3,10 @@
 #include <gmath/gmath.h>
 
 #include "camera.h"
-#include "state_manager.h"
 
 Camera::Camera() {}
 Camera::~Camera() {}
 
-void Camera::use() const
-{
-       state_manager.set_state("st_view_matrix", get_view_matrix());
-}
-
 OrbitCamera::OrbitCamera()
 {
        phi = theta = distance = 0;
@@ -30,6 +24,7 @@ void OrbitCamera::set_orbit_params(float theta, float phi, float distance)
 Mat4 OrbitCamera::get_view_matrix() const
 {
        Mat4 view_matrix;
+       view_matrix.translation(-position);
        view_matrix.rotate_y(theta * (float)M_PI / 180);
        view_matrix.rotate_x(phi * (float)M_PI / 180);
        view_matrix.translate(Vec3(0, 0, -distance));
@@ -55,4 +50,11 @@ Mat4 calc_projection_matrix(float fov_deg, float aspect, float n, float f)
                    );
 
        return pmat;
-}
\ No newline at end of file
+}
+
+void OrbitCamera::set_position(float x, float y, float z)
+{
+       position.x = x;
+       position.y = y;
+       position.z = z;
+}