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

3

7

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?

Obedient answered 4/1, 2012 at 2:21 Comment(0)
J
4

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.

Jaquelin answered 4/1, 2012 at 9:5 Comment(2)
I do not necessarily need the data on a per-object basis, having a dump of the entire scene would be enough. But as far as I understand, the only way to do is to reconstruct the scene from historical glDrawArrays? Can I at least assume that only the current OpenGL matters?Obedient
The problem is, that what you see on screen is not necessarily a coherent triangle soup (a triangle soup is just a collection of triangles sharing the same space). For example the background may use the same dimensions like the regular scene, just that it's rendered first, then the depth buffer cleared. And what I totally forgot is, that the tesselation, geometry and vertex shaders may completely alter the outcome. And if you're facing a OpenGL-3 core program you don't know what attribute is what. You'll need to tailor your dumper to the program in question to be able to extract things.Jaquelin
R
1

glintercept and/or apitrace.

Rearm answered 4/1, 2012 at 6:44 Comment(0)
G
1

Direct3D 9 API Interceptor It captures textures and vertex. And handles shaders.

Gorrian answered 10/7, 2012 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.