Game Development Reference
In-Depth Information
Understanding and loading the Wavefront
(OBJ) format
Open the exported .obj file in your favorite text editor. The following is the code of
an .obj file; the inline comments are added to give you a better understanding.
We will only explain the section of the file format relevant to this chapter. We will
cover texture data in Chapter 4 , Applying Textures .
The following code snippet is taken from a .obj file of a monkey model exported
from Blender:
# Blender v2.64 (sub 0) OBJ File: ''
# www.blender.org
# Material File name
mtllib Monkey.mtl
# The object name exported.
o Monkey
#These are vertex information of the above object
v 0.585466 0.897006 0.581131
v -0.289534 0.897006 0.581131
Texture coordinates, in (u, v, [w]) format, vary between 0 and 1. The w coordinate is
optional. We will cover this later in Chapter 4 , Applying Textures .
The following code snippet from the .obj file lists the vertex normal and the vertex
texture data:
vt 0.500 1 [0]
...
# Vertex normals information
vn 0.707 0.000 0.707
vn 0.707 0.000 0.707
...
# Start mapping from the material file; Default None if no material
applied
usemtl [Material name]
# Smoothing is on or off (For Shaders)
s off
#Indices of a surface in our case triangle
f 47 1 3
# We checked to "triangulate" while exporting, hence we have triads in
faces
...
f 47 3 45
# Vertex/Texture Mapping
 
Search WWH ::




Custom Search