|
Opening OBJ files
|
Previous Top Next |
The object file data structure (OBJ) is described as follows. The headers recognized are as follows
v stands for vertex
f stands for object
c stands for color at a facet
s stands for string at a facet (to be reserved for future)
In this context, facet will define a generic object, not necessarily a plane surface such as a triangle.
Vertex: v indicator followed by 3 floating point numbers
v x y z
Facet: f indicator followed by a series of vertex numbers
f v1 v2 v3 ...
Color: c indicator followed by a LONG RGB color reference
Solaira supports mixed geometry, that is, facets that are not just triangles. For example f 34 means create a single point using vertex 34, where as f 7 9 means create a line segment using vertex 7 to vertex 9 (vertices 7 and 9 define this line). Quads are defined using 4 vertices. Facets with vertex numbers greater 4 creates a polygon in Opengl. The polygon is drawn convex so if it is concave, the geometry will not look as intended.
The following is an object which demonstrates all variations of facet f components:
v 0 0 0
v 1 0 0
v 1 1 1
v 0 1 1
f 1 2 3 4
c 1000
v 0.25 0.25 0
v 0.75 0.25 0
v 0.5 0.75 -0.25
f 5 6 7
c 8000
f 3 7
c 100
f 4 7
c 200
v 0.5 0.5 2.1
f 8
c 15000
The geometry looks as follows:
In this example, a triangle is created using the 3 sequential vertices
f 5 6 7
where the single point object is defined using 1 vertex:
f 8
Note that the object file can be mixed, that is, we can add vertex, facet and color information anywhere in the file. However, the vertex information must be sequential, so if you were to add another vertex to this file, its internal handle would be 9 for the ninth sequential vertex:
v 0.5 -0.5 2.1
f 8 9
The new model now contains a line, defined by vertex 8 to 9: