Lots of comments about what LookAt is doing
This commit is contained in:
parent
c2a4372467
commit
5ac721d601
1 changed files with 11 additions and 0 deletions
|
@ -122,10 +122,17 @@ Camera::LookAt(const Vector3& pt)
|
||||||
const Double upLength = mUp.length();
|
const Double upLength = mUp.length();
|
||||||
const bool isLeftHanded = IsLeftHanded();
|
const bool isLeftHanded = IsLeftHanded();
|
||||||
|
|
||||||
|
/* Orient the camera towards the point. */
|
||||||
mDirection = (pt - mOrigin).normalize();
|
mDirection = (pt - mOrigin).normalize();
|
||||||
/* TODO: Check for zero length direction vector. */
|
/* TODO: Check for zero length direction vector. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Create a new right vector, normalized and perpendicular to the plane
|
||||||
|
* containing the Y unit vector and direction vector.
|
||||||
|
*
|
||||||
|
* The up vector is perpendicular to the plane containing the new right
|
||||||
|
* vector and the direction vector.
|
||||||
|
*
|
||||||
* TODO: This is always the Y vector. POV-Ray has a sky vector, which
|
* 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
|
* specifies the vector along which LookAt pans and tilts the camera. It
|
||||||
* might be worth looking into, at some point.
|
* might be worth looking into, at some point.
|
||||||
|
@ -133,6 +140,10 @@ Camera::LookAt(const Vector3& pt)
|
||||||
mRight = Vector3::Y.cross(mDirection).normalize();
|
mRight = Vector3::Y.cross(mDirection).normalize();
|
||||||
mUp = mDirection.cross(mRight);
|
mUp = mDirection.cross(mRight);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now, fix up the direction, right, and up vectors so that their magnitudes
|
||||||
|
* match what they were before the move.
|
||||||
|
*/
|
||||||
mDirection *= directionLength;
|
mDirection *= directionLength;
|
||||||
mRight *= isLeftHanded ? rightLength : -rightLength;
|
mRight *= isLeftHanded ? rightLength : -rightLength;
|
||||||
mUp *= upLength;
|
mUp *= upLength;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue