Game Development Reference
In-Depth Information
Diffuse lighting
In order to use diffuse lighting our model data must provide a normal stream. A
diffuse light comprises of both a color and a direction in which the light is pointing.
The light's direction vector is combined with the normal vector for each vertex in the
model using the dot product operation.
The result of the dot product operation is multiplied by the global diffuse lighting
color and the current CIwMaterial diffuse color or the RGB value from the color
stream, if one has been provided. This will yield the final color value that is used
when rendering the polygon to the screen.
Specular lighting
As with diffuse lighting, specular lighting can only work if we have provided a
normal stream. It also needs a diffuse light to be specified as it relies on the direction
of the diffuse light.
This type of lighting allows us to make a model appear shinier by causing it to briefly
become brighter when it is facing the direction of the diffuse light.
We can specify both a global and a specular light color specific to CIwMaterial , and
additionally the material also provides a setting for the specular power . This value
allows us to narrow down the response of the specular lighting. A higher number
means that the vertex normal must be almost parallel to the lighting direction before
the specular lighting will take effect.
Using IwGx to render 3D graphics
Remember when we were looking at 2D graphics rendering in Chapter 2 , Resource
Management and 2D Graphics Rendering , I said we would be using IwGx because it
would make the transition to rendering 3D graphics that much easier. Now's the
time to see if my claim was true!
In this section, we shall look at how we can implement the 3D equivalent of the
"Hello World" program—a spinning cube.
Preparing IwGx for 3D rendering
As with 2D rendering, the very first thing we need to do is initialize the IwGx
API by calling IwGxInit , and of course we should call IwGxTerminate at the
end of our program.
 
Search WWH ::




Custom Search