Previous | Next --- Slide 20 of 36
Back to Lecture Thumbnails
cche

When talking about the data structure of the mesh here, is it similar to what is used in an obj file? In an obj file, it also defines vertices, faces, facenormal etc. Are these the similar concept with obj or this is a data structure in code.

motoole2

@cche Very similar. Here's the content of an example .obj file for a cube mesh generated with Blender:

# Blender v2.78 (sub 0) OBJ File: ''
# www.blender.org
mtllib obj.mtl
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1//1 2//1 3//1 4//1
f 5//2 8//2 7//2 6//2
f 1//3 5//3 6//3 2//3
f 2//4 6//4 7//4 3//4
f 3//5 7//5 8//5 4//5
f 5//6 1//6 4//6 8//6

More details on the OBJ file format can be found here. In short though, v 1 1 1 defines a vertex at point (1,1,1), and f 1 2 3 4 represents a quad/face with the indices of four vertices. In this particular example, the file also encodes vertex normal information as well.