• Advertisement
Sign in to follow this  

Loading a model into OpenGL

This topic is 1766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to take a model from 3DS MAX and load it into an OpenGL project.

 

How can this be done?

 

I just can't find much resources for it but it seems like such a vital part of video games programming. Surely people don't make all their models in the OpenGL code.

 

The only thing I've found is lib3ds, which I can only find one tutorial for.

 

I also found this decade old tutorial on NeHe

 

http://nehe.gamedev.net/tutorial/model_loading/16004/

 

Surely there is a more recent way of doing this?

 

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

or you can do it yourself if you want

 

find how the vertices and normals and texture coordinates are stored in the file produced when you export the model and use that data to maybe store it in a class or array or any data structure in your code and then use this structure to draw your model when you call glVertex / glNormal / glTexCoord

 

if you decide to do it I'll do what I can to help you through it

 

have fun ^_^

Share this post


Link to post
Share on other sites

I recommend looking into Assimp.

 

I second this. You can also use Assimp to build your own engine-specific binary 3d model fileformat outside of the engine through some CLI tool you create, and use this in your engine.

 

If you do this, I can recommend boost::synchronization for file read/write. It is very easy to read/write data structures from/to files with it. 

Share this post


Link to post
Share on other sites

It is easy to load a model yourself, but then you have to animate it. that is far from easy, even from a full time professional. Skinning, animation blending, animation tree edition, skeleton retargeting.. it is all very common stuff but yet multi year project.

I don't recommend trying it, just go for Unity.

Using OpenGL directly to do a game is kind of a thing of the past.

Share this post


Link to post
Share on other sites

It is easy to load a model yourself, but then you have to animate it. that is far from easy, even from a full time professional. Skinning, animation blending, animation tree edition, skeleton retargeting.. it is all very common stuff but yet multi year project.

I don't recommend trying it, just go for Unity.

Using OpenGL directly to do a game is kind of a thing of the past.

I don't agree with you that it is a thing of the past it just depends where your interest level is and what you want to create. If you are in the habit of writing an engine and then a game you will hate unity as it is doing everything for you already, on the other hand if you just wish to make a game Unity is a great tool that can help you speed up that process.

 

Most games have their own format they read in and have specialised exporters for the modeling packages to build into that format or have an asset pipeline that compiles the asset into something the game/engine understands. The reasons behind having your own format is that most of the time the modeling packages store data in such a way that all operations are possible but it isn't fast to load this file. A game only cares about displaying the vertex information and maybe deforming this based on the animation system, however this data has to load extremely fast (TCR/TRC on the consoles say something like "you should be done loading within 60 seconds or so at maximum").

 

Modeling package data formats generally store their data as seperate arrays and use index arrays to construct the actual vertex streams to display form that during runtime (read lots of processing), a game however wants a data layout from which you can just instantly grab the stream of vertices and indices and dump them into a vertex/index buffer without any/minimal processing over the data.

Share this post


Link to post
Share on other sites

Obj is a pretty easy to load format, good for beginners.  Blender can export to obj by default, I don't know about 3DS Max.  Also IQM seems to get good praise in the ##openGL irc channel.

Share this post


Link to post
Share on other sites

Obj is a pretty easy to load format, good for beginners.  Blender can export to obj by default, I don't know about 3DS Max.  Also IQM seems to get good praise in the ##openGL irc channel.

 Beat me to it. And yes Max does export to OBJ. For animation just load a bunch of obj files and play them in order. (Best way for a new person to opengl/model loading)

Share this post


Link to post
Share on other sites

Obj is a pretty easy to load format, good for beginners.  Blender can export to obj by default, I don't know about 3DS Max.  Also IQM seems to get good praise in the ##openGL irc channel.

 Beat me to it. And yes Max does export to OBJ. For animation just load a bunch of obj files and play them in order. (Best way for a new person to opengl/model loading)

Becareful with OBJ exporting and make sure it only exports triangular faces, I have seen the max exporter switch between squares and triangles in the same exported file, this is however a couple of years ago so things might have improved.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement