Jump to content

  • Log In with Google      Sign In   
  • Create Account

Loading a model into OpenGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 huymoi7   Members   -  Reputation: 122

Like
0Likes
Like

Posted 19 March 2013 - 11:38 PM

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



Sponsor:

#2 Racoonacoon   Members   -  Reputation: 443

Like
4Likes
Like

Posted 20 March 2013 - 03:24 AM

I recommend looking into Assimp.



#3 hikarihe   Members   -  Reputation: 243

Like
0Likes
Like

Posted 20 March 2013 - 07:22 AM

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



#4 KaiserJohan   Members   -  Reputation: 1153

Like
1Likes
Like

Posted 20 March 2013 - 07:44 AM

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. 



#5 Lightness1024   Members   -  Reputation: 736

Like
-4Likes
Like

Posted 20 March 2013 - 09:08 AM

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.



#6 NightCreature83   Crossbones+   -  Reputation: 2823

Like
2Likes
Like

Posted 20 March 2013 - 09:25 AM

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, Mad Max

#7 EddieV223   Members   -  Reputation: 1406

Like
2Likes
Like

Posted 20 March 2013 - 11:57 AM

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.1 Download http://www.sfml-dev.org/download.php

SFML2.1 Tutorials http://www.sfml-dev.org/tutorials/2.1/

 

// 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

 


#8 jellyfishchris   Members   -  Reputation: 300

Like
0Likes
Like

Posted 20 March 2013 - 06:51 PM

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)



#9 NightCreature83   Crossbones+   -  Reputation: 2823

Like
0Likes
Like

Posted 21 March 2013 - 02:32 AM

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, Mad Max




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS