.BLEND FILE (5.2+)

OBJ Parser (and Lists)


Parsing means to process text, and OBJ… well we know what .obj files are. So making an OBJ parser must mean making an algorithm that can reconstruct the mesh.

So, why am I talking about OBJ parsing if there is already an existing Import OBJ Node?

There is one big upshot. A basic, no, a fundamental human need - so far unquenched. And that is Suzanne. Well really a Suzanne node. No OBJ Import. Just the raw data stored in a node:

And when I say raw data, I mean the actual vertex, face, and UV lists. Unlike the import OBJ node, there is no filepath needed. All the data is stored in a single string node. No extra files required.

This applies to any OBJ. The Utah Teapot, the Stanford Bunny & Dragon, anything…

But let me wind back. What is an OBJ file? Well, for our purposes it’s just a conveniently formatted text file with everything we need:

  1. A vertex list (3D position vectors)
  2. A UV list (2D vectors)
  3. A face list (triplets/quadruplets of vertex + UV indices)

It looks something like this (but of course much longer):

o Suzanne
v 0.437500 -0.765625 0.164062
v -0.437500 -0.765625 0.164062
v 0.500000 -0.687500 0.093750
...
vt 0.505196 0.077083
vt 0.494804 0.077083
vt 0.500000 0.075473
...
f 139/186 197/187 195/183
f 196/184 198/188 139/186
f 138/189 71/190 197/187
...

It’s our job to reassemble the mesh. And in theory it’s quite simple, just:

  1. Choose a face
  2. Fetch its vertex indices
  3. Fetch the corresponding vertex positions
  4. Construct a tri/quad from these positions
  5. Fetch its uv indices
  6. Fetch the corresponding UV vectors
  7. Assign these to corresponding face corners
  8. Repeat for all faces

This is a great introduction to wrangling lists in Blender 5.2+. A new data structure we’ll be using extensively. Learn it!

When you’re done with the main tutorial - I included a bonus exclusive tutorial for handling the UVs (below):

Without further ado, let’s get list-y.