Game Development Reference
In-Depth Information
Change the color of the background to black by changing the statement
GLES20. glClearColor (1.0f, 1.0f, 1.0f, 1.0f);
to
GLES20. glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
It is located in the onDrawFrame() function as well. Figure 2-3 shows what you should see now.
Figure 2-3. Light positioned in front of and above cube
Next, let's change the light position so that it is to the right side of the droid. We are looking down
the negative z axis, and the positive x axis is pointing to the right, and the negative x axis is pointing
left, and the positive y axis is up. The droid is located at the origin, which is location (0,0,0). Change
the light position in SetupLights() to the following:
Vector3 LightPosition = new Vector3(125,0,0);
This will move the light to the right of the droid. Run the program (see Figure 2-4 ). You can clearly
see that the left arm is darkened, since most of the light is falling on the right side of the cube.
 
Search WWH ::




Custom Search