Dumping 3d geometry data of a running Direct3D or OpenGL application

CodeTwice picture CodeTwice · Jan 4, 2012 · Viewed 11.4k times · Source

For a hobby project of mine involving a 3d printer I would like to capture 3d models from various computer games. The games are running on Windows and are usually using DirectX9 but there is also one which can be configured to use OpenGL.

Is there any tool / software which allows me to grab an entire scene from a running application and dump it into a file that can be converted into some popular 3d format like OBJ?

What I need is the geometry only; points, edges, polygons. I do not need textures or shader data. Is this possible at all?

Answer

datenwolf picture datenwolf · Jan 4, 2012

Is there any tool / software which allows me to grab an entire scene from a running application and dump it into a file that can be converted into some popular 3d format like OBJ?

Yes, and no. It is perfectly possible to intercept the data sent to OpenGL or Direct3D. The problem is, that neither OpenGL nor Direct3D are scene graphs. They're drawing APIs, so what you end up, are bunches of drawing commands.

And those bunches are not necessarily per object or whole objects. For example drawing the character in modern games happens in multiple passes and chunks (facial animation requires much more complex shaders than the rest of the body).

Technically you can assume vertex arrays or vertex buffer objects to contain at least whole objects, so dumping objects based on glDrawElements or glDrawArrays calls and the used vertex array pointers or VBO offsets is reasonable.

Immediate mode is a showstopper though: You don't have the slightest bit of information, what's rendered when. Technically you could try some heuristics using the timing and order of the calls. But that's futile.

Is there any tool / software which allows me to grab an entire scene from a running application and dump it into a file that can be converted into some popular 3d format like OBJ?

At my local hackerspace a very rudimentary OpenGL interceptor was written for just that task. And we ran in all the problems I mentioned.