Game Development Reference
In-Depth Information
Understanding object materials
A material is a description of the surface of a 3D object. The properties detail a
material's diffuse reflection, ambient reflection, and specular highlight characteristics.
The diffuse and ambient properties of the material describe how a material reflects
the ambient and diffuse lights in a scene. As most scenes contain much more diffuse
light than ambient light, diffuse reflection plays the largest part in determining the
color of a primitive. Diffuse and ambient reflections work together to determine the
perceived color of an object and are usually identical values. For example, to render
Mr. Green, you create a material that reflects only the green component of the diffuse
and ambient lights. When placed in a scene with a white light, Mr. Green appears to
be green. However, in a room that has only blue light, Mr. Green would appear to be
black because its material does not reflect the blue light.
Specular reflection creates highlights on objects making them appear shiny. It is
defined by two properties that describe the specular highlight color as well as the
material's overall shininess. You establish the color of the specular highlights by
setting the specular property to the desired RGBA color—the most common colors
are white or light gray. The values you set in the power property control how sharp
the specular effects are.
Rendering 3D objects
To put our earlier knowledge to use, first we need to learn how to render 3D objects.
We will first create a 3D object, a cube or any geometry, in Blender, a free and open
source 3D creation software ( http://www.blender.org/ ).
We will then export this 3D model as a Wavefront object file. The Wavefront .obj
format will then be parsed via a Python script and will be converted and saved as a
JSON file. We use the JSON format as it can be easily parsed by JavaScript. We can
parse an OBJ file in JavaScript as well but it would be time-consuming and slow.
Exporting a 3D object from Blender
The following are the steps we need to perform to export an object from Blender:
1.
Open Blender and go to Add | Mesh | Cube , as shown in the
following screenshot:
 
Search WWH ::




Custom Search