X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fcamera.cc;h=b3ad0779d6b79f3ea9a00a0235b6743c80e5fc79;hb=0d3454cbd5e803b8dea601110d403cd5563df9be;hp=0f7773e75be449e2b73226b1306a2034a507176c;hpb=63d7f3b0e70ab5e3d530c579b1881967c96b0b92;p=demo diff --git a/src/camera.cc b/src/camera.cc index 0f7773e..b3ad077 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -20,7 +20,7 @@ OrbitCamera::OrbitCamera() OrbitCamera::~OrbitCamera() {} -void OrbitCamera::set_orbit_params(float phi, float theta, float distance) +void OrbitCamera::set_orbit_params(float theta, float phi, float distance) { this->phi = phi; this->theta = theta; @@ -30,6 +30,7 @@ void OrbitCamera::set_orbit_params(float phi, float theta, 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)); @@ -50,9 +51,16 @@ Mat4 calc_projection_matrix(float fov_deg, float aspect, float n, float f) Mat4 pmat = Mat4( tmp/aspect, 0, 0, 0, 0, tmp, 0, 0, - 0, 0, (f + n) / range, -1, + 0, 0, (f + n) / range, -1, 0, 0, 2 * n * f / range, 0 ); return pmat; +} + +void OrbitCamera::set_position(float x, float y, float z) +{ + position.x = x; + position.y = y; + position.z = z; } \ No newline at end of file