models to openGL overview or introduction...

Posts: 321
Joined: 2004.10
Post: #1
I'm having trouble understanding the interface between
3d-modeling/2d-CAD programs and the data they produce;
and then openGL reading in that data and using it.

I believe there is no "standard interface" which is probably
why I'm having problems nailing this down.

I keep coming across examples (Stanford Bunny for instance)
where openGL reads in a bunch (alot of!) vertices, normals, etc.
But I never see how this data is created in the first place.

In my fantasy, I wish that there was an openGL file format
(say .OGL) which could be created from modeling programs
and which openGL could simply read in. But since this
aint gonna happen can somebody explain typically how
this is done?

For simplicity sake, lets say I just want to create a 2D model
and export it to some format say F. Then openGL takes this
file in F format and reads it in and creates a wireframe object.

So all I need is a bunch of vertices right? Like for this code
snippet taken from the Bunny example.

GLuint GenStanfordBunnyWireList()
unsigned int i;

GLint lid=glGenLists(1);
   glNewList(lid, GL_COMPILE);

    glBegin (GL_LINES);
    glEnd ();

   return lid;

So can somebody recommend a tool/program and a file format?
Hopefully one that is fairly simple and is shareware or freeware.

Or is what I'm asking too specific or oversimplified. For instance,
I've been studying vector/CAD/3Dmodeling formats like crazy
(OBJ, DWG, SWF, EMP, PCX, WMF, HPGL, IEGS, etc.) and it seems like
for openGL one is going to have to edit this data; or maybe have
a specific openGL input library that will make openGL happy.

Hope this makes sense. Happy 2006 and Thanks!
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
*you* write the code to read the model file as produced by the 3D app and turn that into data that *you* send to OpenGL. OpenGL doesn't help you at all.

In the code you've quoted above, the data is coming from the "vertices" and "indices" arrays. Somewhere else in the program is some code that fills in those arrays by reading the 3D model file. That's the important code.

If you're just getting started, the OBJ format is probably the easiest to understand and use, and is widely supported by 3D modelers.
Quote this message in a reply
Posts: 40
Joined: 2004.12
Post: #3
As far as tools to create your models, use Wings3D and the newly updated Blender 2.40

Both have scripts to export to .obj, which as OSC stated is simple enough to parse and read in. Check out this page.

Quote this message in a reply
Posts: 321
Joined: 2004.10
Post: #4
After OSC post, I finally dived into Blender. Liked it, but it couldn't
import .ai files. Then tried Maya personal edition (free downloadd).
I could import .ai files. But damn, couldn't export .obj files (or
at least without buying the product). Finally tired Wings. Sweet.
Imports .ai and exports .obj files. At least I now have a good feel
for 3D programs which I didn't have previously.
Quote this message in a reply
Post Reply