Skip to content

Adding .OBJ Objects with UV Maps

Coela Can't! edited this page Aug 20, 2021 · 3 revisions

Wavefront .OBJ files

Object .OBJ files can be manually created but must be a triangulated mesh, not a polygonal mesh. Triangles that share vertices should be properly linked within the object file to save on memory space as the memory is shared between triangles.

Here is an example of a single right-triangle:

v -50.000000 -50.000000 0.000000
v -50.000000 50.000000 0.000000
v 50.000000 -50.000000 0.000000
f 3 2 1

Here is an example of a single right-triangle with a UV Map:

v -50.000000 -50.000000 0.000000
v -50.000000 50.000000 0.000000
v 50.000000 -50.000000 0.000000
vt 0.000 0.000
vt 0.000 1.000
vt 1.000 1.000
f 3 2 1

Creating a ProtoTracer Object3D

To create a ProtoTracer Object3D from an ASCII .OBJ file, open the ProtoTracerOBJConverter project. Modify the top few lines to fit your input file, your UV mapped material if in use, the output C++ file name, and the class name:

fileName = "Example Files\Bee\Bee.obj"
textureName = "Example Files\Bee\Bee.png"
outputCPPName = "Output\Bee.h"
name = "Bee"

Run the python file to create the C++ output header. This file can now be included and directly used similarly to the example in the Creating an Animation example.