Loading a model into OpenGL

Started by
7 comments, last by NightCreature83 11 years, 1 month ago

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

Advertisement

I recommend looking into Assimp.

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 ^_^

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.

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.

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.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

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.

If this post or signature was helpful and/or constructive please give rep.

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

// Easy to learn 2D Game Library c++

SFML2.2 Download http://www.sfml-dev.org/download.php

SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/

// Excellent 2d physics library Box2D

http://box2d.org/about/

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

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)

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.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

This topic is closed to new replies.

Advertisement