Game Development Reference
In-Depth Information
Thisproducestheforward v ,up u andright r vectorsforthecamera spaceintermsofworld
space. We can then calculate the translation factors.
The view matrix can then be represented by:
This view matrix now contains all the elements necessary to transform vertices from world
space into camera space.
matrix lefthanded::LookAt(const vector3& eyePosition, const vector3& targetPosition, const vector3& up)
{
vector3 vz = vector3::Normalize(targetPosition - eyePosition);
vector3 vx = vector3::Normalize(vector3::Cross(up, vz));
vector3 vy = vector3::Cross(vz, vx);
matrix result = matrix::Identity;
result(0,0) = vx.x();
result(0,1) = vx.y();
result(0,2) = vx.z();
result(1,0) = vy.x();
result(1,1) = vy.y();
result(1,2) = vy.z();
result(2,0) = vz.x();
result(2,1) = vz.y();
result(2,2) = vz.z();
result(3,0) = -vector3::Dot(vx, eyePosition);
result(3,1) = -vector3::Dot(vy, eyePosition);
result(3,2) = -vector3::Dot(vz, eyePosition);
return result;
}
Search WWH ::




Custom Search