diff options
Diffstat (limited to 'camera.cpp')
-rw-r--r-- | camera.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -9,6 +9,30 @@ void Camera::init(float vfov, const v3f& f, const v3f& p) { 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); |