3 #include <gmath/gmath.h>
10 OrbitCamera::OrbitCamera()
12 phi = theta = distance = 0;
15 OrbitCamera::~OrbitCamera() {}
17 void OrbitCamera::set_orbit_params(float theta, float phi, float distance)
21 this->distance = distance;
24 Mat4 OrbitCamera::get_view_matrix() const
27 view_matrix.translation(-position);
28 view_matrix.rotate_y(theta * (float)M_PI / 180);
29 view_matrix.rotate_x(phi * (float)M_PI / 180);
30 view_matrix.translate(Vec3(0, 0, -distance));
35 Mat4 calc_projection_matrix(float fov_deg, float aspect, float n, float f)
37 float fov = fov_deg / 180 * M_PI;
40 tmp = 1 / tan(fov / 2.0);
42 /* near - far clipping planes */
48 0, 0, (f + n) / range, -1,
49 0, 0, 2 * n * f / range, 0
55 void OrbitCamera::set_position(float x, float y, float z)