Game Development Reference
In-Depth Information
Listing 4-24. Calculate Camera LookAt Vector
void CalculateLookAtVector()
{
m_Center.Set(m_Orientation.GetForwardWorldCoords().x,
m_Orientation.GetForwardWorldCoords().y,
m_Orientation.GetForwardWorldCoords().z);
m_Center.Multiply(5);
m_Center = Vector3.Add(m_Orientation.GetPosition(), m_Center);
}
The CalculateUpVector() function sets the Camera's Up vector in world coordinates (see Listing 4-25).
Listing 4-25. Calculating the Camera Up Vector
void CalculateUpVector()
{
m_Up.Set(m_Orientation.GetUpWorldCoords().x,
m_Orientation.GetUpWorldCoords().y,
m_Orientation.GetUpWorldCoords().z);
}
The way you convert the camera's Up vector local coordinates into world coordinates is the same as
with the Forward vector in Listing 4-24 that we covered in the previous example. To see this visually,
let's take a look at Figure 4-15 and Figure 4-16 .
Local up Axis = (0,1,0)
World Coordinates Local Up Axis = (0,1,0)
Figure 4-15. Camera local y axis before rotation
 
Search WWH ::




Custom Search