Game Development Reference
In-Depth Information
#The ambient color of the material is declared using Ka. Color in RGB
where value is between 0 and 1.
Ka 0.000000 0.000000 0.000000
#The diffuse color is declared using Kd.
Kd 0.640000 0.640000 0.640000
#The specular color is declared using Ks.
Ks 0.500000 0.500000 0.500000
#Ni optical_density #Specifies the optical density for the surface.
This is also known as index of refraction.
Ni 1.000000
d 1.000000
illum 2
The illum data element in the .mtl file helps us understand the illumination model
that needs to be applied when using this material. It can be a number from 0 to 10.
The illumination models are summarized as follows:
Value
Description
0
Color on and ambient off
1
Color on and ambient on
2
Highlight on
3
Reflection on and ray trace on
4
Transparency: glass on; reflection: ray trace on
5
Reflection: fresnel on and ray trace on
6
Transparency: refraction on; reflection: fresnel off and ray trace on
7
Transparency: refraction on; reflection: fresnel on and ray trace on
8
Reflection on and ray trace off
9
Transparency: glass on; reflection: ray trace off
10
Casts shadows onto invisible surfaces
Converting the OBJ file to the JSON file format
The JSON file format does not have any particular specification in WebGL. We store
our object data in JSON because it is the easiest way to parse in JavaScript. Although
we can write our own script to create a JSON file from the OBJ file, we would prefer
to use an existing script to do the same:
Install Python 3.x from https://www.python.org/downloads/ . (Macintosh
generally has Python installed.)
Download the script convert_obj_three.py from https://github.com/
mrdoob/three.js/blob/master/utils/converters/obj/convert_obj_
three.py . (The script is already attached with the chapter code files.)
Search WWH ::




Custom Search