Extracting 3D Models using raw2obj.py Part 1

22-05-2020 - 1 minute, 4 seconds -


Over the years of work in reverse engineering 3D game object formats, I have created a small script that is a sort of a Swiss Army knife for converting objects in CSV, html and binary form to Wavefront OBJ. This is a short introduction on how to use this script to extract an object from Renderdoc.

Extracting model

Here is an example of a frame capture in Renderdoc.
An interesting object at EID 7269 was drawn using the DrawIndexed API. It can be exported by right clicking in the vertex shader input (VS Input) section of the mesh viewer and selecting "Export to CSV." In this instance, I am only interested in the vertex positions, so only the vertex index (IDX) and POSITION0.x, POSITION0.y, and POSITION0.z columns are important. The script's default column arrangement assumes this format. Similarly, the topology of the object is a triangle list, which is the default assumed by the script. All that is needed to convert the CSV into a OBJ is to execute the script with the CSV output type specified. The script prints to the standard output, so a redirect (>) is used to divert standard out to a file.

python3 raw2obj.py --input-type csv --type positions ship.csv > out.obj

Here is the OBJ imported into Blender: