Game Development Reference
In-Depth Information
{
int loc = GLES20.glGetUniformLocation(m_ShaderProgram,variable);
GLES20.glUniformMatrix4fv (loc, count, transpose, value, offset);
}
The Camera
The camera that provides our view into the 3D world is represented by the Camera class and was
previously illustrated in Figure 4-10 .
The camera's position and raw orientation are held in the variable m_Orientation , which is an object
of the Orientation class. The final camera position is held in m_Eye . The final look at the point where
the camera is pointing at is held in m_Center . The final up vector that denotes the top of the camera
is held in m_Up (see Listing 4-18).
Listing 4-18. Camera Orientation
// Camera Location and Orientation
private Vector3 m_Eye = new Vector3(0,0,0);
private Vector3 m_Center= new Vector3(0,0,0);
private Vector3 m_Up = new Vector3(0,0,0);
private Orientation m_Orientation = null;
The viewing frustrum data for the camera is defined by six clipping planes, indicated in Listing 4-19.
Listing 4-19. Viewing Frustrum Variables
// Viewing Frustrum
private float m_Projleft = 0;
private float m_Projright = 0;
private float m_Projbottom = 0;
private float m_Projtop = 0;
private float m_Projnear = 0;
private float m_Projfar = 0;
The key variables for this Camera class are the matrices that hold the camera's projection matrix and
the camera's view matrix. These are 4-by-4 matrices of type float, allocated as a one-dimensional
array of 16 elements (4 times 4 elements in the matrix;. see Listing 4-20). Remember: These are two
of the key matrices that you need to transform an object's vertex, so that it can be displayed on
the screen.
Listing 4-20. The Camera's Matrices
private float[] m_ProjectionMatrix = new float[16];
private float[] m_ViewMatrix = new float[16];
 
Search WWH ::




Custom Search