Game Development Reference
In-Depth Information
switch(tValue) {
case"REPEAT":
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T,
gl.REPEAT);
break;
case"CLAMP_TO_EDGE":
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T,
gl.CLAMP_TO_EDGE);
break;
case"MIRRORED_REPEAT":
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T,
gl.MIRRORED_REPEAT);
break;
}
gl.bindTexture(gl.TEXTURE_2D, null);
drawScene();
}
Exporting models from Blender
The most exciting part is here. In this section, we will export objects with textures
from Blender. However, first we need to understand the structure of the newly
exported object and the material file. Let's go through the exported cube with
textures. Open the
Box.obj
file present in the
model
directory in your favorite text
editor. The content of the file is as follows:
# Blender v2.67 (sub 0) OBJ File: ''
# www.blender.org
mtllib Box.mtl
o Box
v -0.738564 -0.738564 0.738564
v 0.738564 -0.738564 0.738564
v 0.738564 0.738564 0.738564
v -0.738564 0.738564 0.738564
v 0.738564 0.738564 -0.738564
v -0.738564 0.738564 -0.738564
v 0.738564 -0.738564 -0.738564
v -0.738564 -0.738564 -0.738564
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.625000 0.500000
vt 0.375000 0.500000
vt 0.375000 0.750000
vt 0.625000 1.000000