OpenGL wrapper to extract geometry data

I’ve seen lots of nice models in games/demos that I wouldn’t mind using myself, in my own spare time projects.
The Ogre & Dawn models, for instance, are very nice, but the nmb file format they’re stored in looks a little heavy.
I was thinking about writing an opengl wrapper (based on gltrace) to extract the vertex/primitive data as they’re being drawn, and dumping it all into an easily parsable ascii file. It wouldn’t be much more effort to extract the texture data too.
Before I do this, I thought it might be worthwhile checking to see if anyone has done something similar before?

Thanks for the feed back - much appreciated.
Nobody’s done such a wrapper then.

i haven’t done this for opengl, but basically you want to install an api hook so you can get the data as it’s submitted to opengl… i had to do some global service stuff with the hook api, but i think in this case you’re better off hacking the dll entry points of interest to go through your code first…

i guess i should say i assume this is under win32

For the textures only, i’d already like such a tool :slight_smile:

However i’m not too sure about the geometry. How will you determine which commands correspond to starting the model definition or ending it ? What if it renders in multiple passes ? How to filter out uninteresting stuff, like billboards or GUI ? And what if the geometry is sorted by material, and you’ve got no clear “model start” / “model end” ? And i’m not even talking about animations :slight_smile: Or did i not understand your idea ?

Basically i’m not really sure to see how you will solve the technical issues…

Y.

I remember a tool called “DLL Detective” which could intercept the textures. I can’t seem to find a working URL for it anymore, but I’m sure I could find it on my hard drive somewhere if you’re interested.

– Tom

I think someone’s done this before, it was on the front page about a year ago. On their web page they had some geometry captures from quake3.

In my opinnion the idea’s a bit lame, though, and you couldn’t use the models in anything official for copyright reasons anyways. Not that you should care about my opinnion…

-Ilkka

Your definition of lame is obviously (hopefully) different to mine, justhanging.
You’re right, I’m not interested in opinion of worth on this one, just ideas.
mattc, I’d do it using the glTrace source code as a base - it’s an opengl wrapper. Platform independent. Open Source.

Ysaneya, you’ve got a point about the sorting by material issue, but that is just a manual filtering task.
Basically, wouldn’t I just need to insert into the glDrawElements stub a check to see if a duplicate glDrawElements has been called before? (same elements pointer, same primitive type etc.)
Textures would simply be an fwrite in the glTexImage call stub.
Animation? I’m just after the vertex/texcoord/tris, not going as far as animation - not going to be simulating vertex programs on the CPU either!

It should only take a few hours to program and test, I would have thought - but should prove useful to everyone at some point.

You could use/hack the mesa opengl implementation as long as what you’re targetting at do not use any special extension. Well you could even implement some dummy empty function to simulate the presence of the missing feature.

Sorry, that was quite a badly argumented opinnion. Consider it a failed attempt to shut up when I should.

The thing is, that the two possible uses for such a program I can come up with are reverse engineering someone elses code and stealing other people’s art, both of which I consider lame because they’re unethical and uncreative.

But I guess I overreacted a bit, using the models for your spare time projects isn’t going to hurt anyone and I can see the kind of a technical interest you might have to the project. Go on, and try not to get upset because of my comments.

-Ilkka

I have “extended” gltrace. It writes textures to a special folder.

I was interested in them nmb files myself.

For each render call (glDrawRangeElements or something), you have to write to a file and then you visually inspect in some other software. Write them as 3ds for example and go into 3DMax.

Nothing wrong with getting a better idea of what other software do.

Well at least most licence agreements state that you’re not allowed to reverse engineer the program. But of course for learning purposes it’s mostly ok.

-Ilkka