iDevGames Forums
models to openGL overview or introduction... - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: models to openGL overview or introduction... (/thread-4656.html)



models to openGL overview or introduction... - WhatMeWorry - Jan 1, 2006 02:36 PM

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.


Code:
GLuint GenStanfordBunnyWireList()
{
unsigned int i;

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

    glBegin (GL_LINES);
      for(i=0;i<(sizeof(face_indicies)/sizeof(face_indicies[0]));i++)
       {
           glVertex3fv(&vertices[face_indicies[i][0]][0]);
           glVertex3fv(&vertices[face_indicies[i][1]][0]);
           glVertex3fv(&vertices[face_indicies[i][2]][0]);
           glVertex3fv(&vertices[face_indicies[i][0]][0]);
       }
    glEnd ();

   glEndList();
   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!


models to openGL overview or introduction... - OneSadCookie - Jan 1, 2006 03:57 PM

*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.


models to openGL overview or introduction... - seven - Jan 1, 2006 06:08 PM

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.


models to openGL overview or introduction... - WhatMeWorry - Jan 2, 2006 10:48 AM

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.