Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 544
CodeTwice Avatar asked Jan 04 '12 02:01

CodeTwice


2 Answers

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.

like image 174
datenwolf Avatar answered Oct 28 '22 04:10

datenwolf


glintercept and/or apitrace.

like image 39
genpfault Avatar answered Oct 28 '22 02:10

genpfault