Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing Models Into A OpenGL Project

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.

like image 836
bobber205 Avatar asked Jan 07 '10 02:01

bobber205


2 Answers

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

like image 73
Tarydon Avatar answered Oct 04 '22 22:10

Tarydon


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

like image 36
Marcin Seredynski Avatar answered Oct 04 '22 23:10

Marcin Seredynski