Skip to main content
gamedev.net
🔒 Locked

3d file format loader tutorial

Started by DarkBalls 5 replies 4k views
Original Post
DarkBalls
DarkBalls
Can anyone recommend a link that teaches how to load a 3ds and also md2 format for OpenGL? I want to understand everything behind it so I can include it on my own 3D engine. BTW, if you have any 3D book for opengl to recommend please include it here. Thanks, DarkBalls
RealMarkP
RealMarkP
Here is a link to MD2 File format specifications.
Here is a link to the 3DS file format spec.

I would highly recommend that you use a third party library to import models into your engine because not all file formats are exported properly and cannot be loaded without a plethora of error checking. The one I use is the Asset Import library. It works with more then a dozen file formats including 3ds and md2.
------------Anything prior to 9am should be illegal.
DarkBalls
DarkBalls
I think I don't need all the 3D file format. I heard that 3ds and md2 is good in games that's why I'll focus on those formats. But maybe I'll need that 3rd party library in the future so I'll bookmark it. Thank you very much RealMarkP.

By the way, I searched about md2 format and it says that its pretty old, md3 is new. Is it good for games? If not, what format is good? Do you know any tutorial for that?

And also, does 3ds max 2009 support md2 and md3? I"m planning to have a copy of that maybe tomorrow.

Thanks
DarkBalls
cignox1
cignox1
3ds can be good or bad depending upon what you need it for. It can be used to store scene informations (like camera and lights) and not only models data. This is good because other popular formats like lwo or (IIRC) obj don't. But 3ds is also a very old format, with many limits, for example it can store only one texture per channel, and a limited amount of vertices/polygons per object (up to 65k IIRC). But most apps import from/export to 3ds.
I've also started using Assimp because this way I can choose among many formats, without writing importers for each one. Once I wrote a simple importer for 3ds: it was interesting, but too much work for what is generally not the main goal of your app.
baw
baw
Quote:
Original post by DarkBalls
By the way, I searched about md2 format and it says that its pretty old, md3 is new. Is it good for games? If not, what format is good? Do you know any tutorial for that?

md2 was introduced in Quake 2, so it's over 11 years old. Since md3 was used for Quake 3 it's newer, but calling it "new" is a bit optimistic: it's becoming 10 this year. Your choice depends on what you want to achieve.

The good thing about md2 is that it's very easy to read and display, even for someone who's not (yet) an 3d wiz. It's doesn't use a skeleton animation as more recent formats, but stores all the vertex positions per frame. That, on the other hand, makes it impossible to change/modify/add new animations fast. It also keeps all vertex info as ints, resulting in "wobbly" animation.

A relatively recent format is the one used in the Doom 3 engine, md5. You can read up on it at http://tfc.duke.free.fr/coding/md5-specs-en.html, but it's rather advanced with quaternions and stuff.
Terrimus
Terrimus
I would recommend Focus on 3D Modes.

Good book about how to load MD2/MD3, OBJ, MS3D, 3DS, and how to animate and interpolate models.

Leafteaner
Leafteaner
Quote:
Original post by DarkBalls
I think I don't need all the 3D file format. I heard that 3ds and md2 is good in games that's why I'll focus on those formats. But maybe I'll need that 3rd party library in the future so I'll bookmark it. Thank you very much RealMarkP.


I second using ASSIMP, unless of course you are trying to learn the details about loading the particular file formats. ASSIMP loads all of the supported formats into a single framework, so you only have to code one loading path and it will work for lots of different file types.

But if you are going the route of learning the details, the book Terrimus linked to is pretty good.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.