PDA

View Full Version : OpenGL wrapper to extract geometry data



knackered
05-27-2003, 07:07 AM
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?

knackered
05-27-2003, 11:23 PM
Thanks for the feed back - much appreciated.
Nobody's done such a wrapper then.

mattc
05-27-2003, 11:30 PM
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 http://192.48.159.181/discussion_boards/ubb/wink.gif

Ysaneya
05-27-2003, 11:56 PM
For the textures only, i'd already like such a tool :)

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 :) Or did i not understand your idea ?

Basically i'm not really sure to see how you will solve the technical issues..

Y.

Tom Nuydens
05-28-2003, 12:07 AM
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

JustHanging
05-28-2003, 12:13 AM
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

knackered
05-28-2003, 12:35 AM
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. http://192.48.159.181/discussion_boards/ubb/smile.gif
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! http://192.48.159.181/discussion_boards/ubb/smile.gif

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

tfpsly
05-28-2003, 12:53 AM
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.

JustHanging
05-28-2003, 01:33 AM
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

V-man
05-28-2003, 05:41 AM
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.

JustHanging
05-28-2003, 06:33 AM
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