#include "camera.hpp" void Camera::init(float vfov, const v3f& f, const v3f& p) { fov = vfov; forward = f; position = p; near = 0.1f; far = 1000.0f; asp = 1.0f; } void Camera::init_shadow( const v3f& dir, const v3f& mic, const v3f& mac ) { v3f up(0.0f, 1.0f, 0.0f); AABB aabb = { mic, mac }; init(0.0f, dir, v3f(0.0f)); view = m4f::lookat( dir, v3f(0.0f), up ); aabb = m4f::transform(view, aabb); proj = m4f::orth( aabb.min.x, aabb.max.x, aabb.max.y, aabb.min.y, aabb.min.z, aabb.max.z ); } void Camera::update() { v3f up(0.0f, 1.0f, 0.0f); view = m4f::lookat(position, position + forward, up); proj = m4f::pers(fov, asp, near, far); } const m4f& Camera::get_view() const { return view; } const m4f& Camera::get_proj() const { return proj; }