obj file is a 3D model file format. A standard developed by Alias|Wavefront for the 3D modeling and animation software “Advanced Visualizer”, suitable for mutual guidance between 3D software models, and can also be read and written through Maya.
- Only supports model triangle surface data and material information, no animation support;
- The geometric information is provided by the .obj file, and the material information is defined by the .mtl file;
- The file represents a piece of data in line units, and the subsequent content can be judged according to the characters at the beginning of the line;
- The # character represents a comment line
Note:
For .obj and .mtl parsing and loading, please refer to:Loading .obj and .mtl in opengl es 2.0
OBJ format
# material file corresponding to obj
# mtllib testvt.mtl
# group name
g default
# o object name(Object name)
o testvt.obj
# vertices
v -0.5 -0.5 0.1
v -0.5 -0.5 -0.1
v 0 0.5 0.1
v 0 0.5 -0.1
v 0.5 -0.5 0.1
v 0.5 -0.5 -0.1
# texture coordinates
vt 0 1
vt 1 1
vt 0.5 0
# vertex normal
vn 0 0 1
vn 0 0 -1
# The material used by the current primitive
usemtl Default
# s Smooth shading across polygons is enabled by smoothing groups.
# Smooth shading can be disabled as well.
s off
># v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 (index starts at 1)
f 1/1/1 5/2/1 3/3/1
f 6/2 /2 2/1/2 4/3/2