LookAt comments

This commit is contained in:
Eryn Wells 2014-08-03 18:51:49 -07:00
parent 0df6244b8b
commit bcf93bb4ce
2 changed files with 14 additions and 0 deletions

View file

@ -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);

View file

@ -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,