views:

225

answers:

4

I am taking an OpenGL course and we have the option to create models to use in our assignments with a 3D modeling application, like Maya or Blender.

I am not looking forward to typing in coordinates manually so I was curious what resources I should be looking into for writing OpenGL code and importing models. (Textures are coming later). I am also concerned by the scale I'm importing at but maybe that's silly to worry about at this point.

Thanks for any resource suggestions. OpenGL has so much out there I get overwhelmed sometimes when Googling for what I need.

EDIT: This is what I ended up using. http://www.spacesimulator.net/tut4_3dsloader.html I downloaded the "Windows" version and with a few path changes to the includes, got up and running. It doesn't handle OBJ files but rather 3DS. Cheetah 3D exports to this type as well.

+1  A: 

I'd say that the Obj format is a good balance for readability and functionality if you want to parse it yourself.

http://en.wikipedia.org/wiki/Obj

The easiest way would to be to find a library to do it for you but the possibilities would be limited to your chosen language.

You shouldn't be worrying about scale. OpenGL's matrices can easily rescale vertices.

Brian McKenna
+3  A: 

Blender can save files in .obj format, and a simple google search turns up several libraries for loading this into OpenGL. Here is one.

Tarydon
+2  A: 

I'd suggest not worrying about the scale of the objects for right now.

Now, the thing you're going to have to do is settle on a format for the 3D file. There are MANY options when exporting from a 3D program like Maya or Blender.

Might I recommend attempting a simple COLLADA importer. Specification information is here: http://www.khronos.org/files/collada_spec_1_4.pdf

Another spec I've been using lately would also probably be suitable for this is OBJ.

The specification for OBJ is located here: http://local.wasp.uwa.edu.au/~pbourke/dataformats/obj/

Also, there are several free sample 3D OBJ files located here. This will allow you to see the format of the files and really see how easy they can be to parse.

Keep in mind, OBJ can not support animation, and it is rather inefficient for rendering large scenes.

Crowe T. Robot
Animation is not a concern. I have Cheetad3D and I just checked and saw that it can do obj files which is awesome.
bobber205
+1  A: 

One of the simplest formats that can be used to export meshes is Wavefront OBJ (please search for it on Wikipedia as I'm only allowed to post one link at the moment). It's basically a text file that shouldn't be too hard to parse.

Or actually, if you're allowed to use GLUT, you could try and use its loader (as answered in OpenGL FAQ 24.040)

Don't worry about the object scale at the moment, you can always scale your object later. Just make sure you export it with local coordinates, not global (e.g. [0,0,0] should be the center of the object, not the world you're modelling).

Marcin Seredynski
GLUT is required (or at least heavily recommended) for the course so awesome link!
bobber205
I am using FreeGLUT. Am I out of luck without changing the GLUT I am using? :(
bobber205