From bcf93bb4ce331c1cc2a85f9444d6d90323f8433c Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 3 Aug 2014 18:51:49 -0700 Subject: [PATCH] LookAt comments --- src/camera.cc | 9 +++++++++ src/camera.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/camera.cc b/src/camera.cc index 31cb36c..d064f16 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -97,6 +97,10 @@ Camera::SetUp(const Vector3& up) void Camera::LookAt(const Vector3& pt) { + /* + * Precalulate these in order to preserve the aspect ratio and orientation + * of the camera across the LookAt operation. + */ const Double directionLength = mDirection.length(); const Double rightLength = mRight.length(); const Double upLength = mUp.length(); @@ -106,6 +110,11 @@ Camera::LookAt(const Vector3& pt) mDirection = (pt - mOrigin).normalize(); /* TODO: Check for zero length direction vector. */ + /* + * TODO: This is always the Y vector. POV-Ray has a sky vector, which + * specifies the vector along which LookAt pans and tilts the camera. It + * might be worth looking into, at some point. + */ mRight = Vector3::Y.cross(mDirection).normalize(); mUp = mDirection.cross(mRight); diff --git a/src/camera.h b/src/camera.h index a18e461..8008be6 100644 --- a/src/camera.h +++ b/src/camera.h @@ -35,6 +35,11 @@ struct Camera const Vector3& GetUp() const; void SetUp(const Vector3& up); + /** + * Pan and tilt the camera towards the given point. + * + * @param [in] pt The point at which to face the camera + */ void LookAt(const Vector3& pt); virtual Ray compute_primary_ray(const int x, const int width,