• Advertisement
Sign in to follow this  

3D Model Loader

This topic is 4249 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

Advertisement
hi,

i think most people are using 3dsmax *.3ds format.
if you're totally new, i'd recommend reading NeHe's tutorials which include loading Milkshape3D's model format *.ms3d

other model formats which come in mind:
- md2, md3 (quake model format)
- dotxsi (softimage's format, similar to 3ds)

hope this helps!
good luck,
- christoph -

Share this post


Link to post
Share on other sites
When I'm not using my own file formats, I use the XSI format for static models, and the Doom 3 MD5 format for skeletally-animated models.

The XSI format is very well supported by Softimage. It's got a library specifically written for it (the XSI File Tool Kit), and importers/exporters for the major DCC tools like 3ds max and Maya (Softimage|XSI supports it natively). It also supports animation, if you want to use it for that. All of the model development for Half-Life 2 was apparently done in Softimage|XSI, saved as XSI files, then run through various in-house software tools to output models in Valve's file formats.

You might also want to try Microsoft's X file format. It's designed for Direct3D, but you can use it with anything, really.

Share this post


Link to post
Share on other sites
There is this 3Dmodel extension converter called Deep 3dexploration, copnverts any extension i.e. .3ds->.obj, .3ds->.x anything really.....
I cant remember the website, i think its
Here.

Share this post


Link to post
Share on other sites
obj because is simple, I found very useful code for the obj loader here:

http://www.gamedev.net/community/forums/topic.asp?topic_id=312335

Bu!
Durmieu

Share this post


Link to post
Share on other sites
hey,
thanks a lot for your answers;)

i think i will test a .3ds loader...did somone of u made a .3ds loader? where can i find one? it should be platform independent, will be fine!

bye

Share this post


Link to post
Share on other sites
if you want a very good tutorial on .3ds loading, go to www.spacesimulator.net and check out his tutorials. they are pretty darn good.

and for a break down of everything that is in the .3ds file, check out:
http://pipin.tmd.ns.ac.yu/extra/fileformat/3d/3ds/3dsinfo.txt

Share this post


Link to post
Share on other sites
Quote:
Original post by Surfman19
hey,
thanks a lot for your answers;)

i think i will test a .3ds loader...did somone of u made a .3ds loader? where can i find one? it should be platform independent, will be fine!

bye


I wrote a basic 3ds loader that you can download here. It only implements basic functionalities, but if you want to look at the source, I'm sure it can help you with some details of the format.
The zip file also contains those 3ds format specification files I used to learn the 3ds structure (so you don't need to search them ;-).

EDIT: what do you want to do then, by the way? Be warned that 3ds is very limited, and that's why once I wrote the loader, I decided to write an exporter for lightwave to my custom file format. If you need something more advanced (multiple textures per channel or something like this), then go with something different.

Share this post


Link to post
Share on other sites
hey cignox1!

thank you very much;)
i just want to load a 3d model with textures into opengl!
does your loader also support animation?

i see you are from italy;) i hope they win tomorrow against germany!!! ;-)

bye

Share this post


Link to post
Share on other sites
Quote:
Original post by Surfman19
hey cignox1!

thank you very much;)
i just want to load a 3d model with textures into opengl!
does your loader also support animation?

No, not yet (and most probably it will never do). I'm not really sure about wich kind of animation does 3ds support (I belive only keyframes, not the best for charchters animation).
In the file there is also a small app that renders a textured model.
Anyway, IIRC there is at least a 3ds loading library that support animation. I don't remember the name, perhaps L3DS...
Quote:

i see you are from italy;)

Ja, aber die stadt wo ich lebe, Bozen, ist nicht mehr als 50 kilometern aus Oesterreich :-)
Quote:

i hope they win tomorrow against germany!!! ;-)
bye

I hope that, too.

Share this post


Link to post
Share on other sites
If you decide to go with 3DS then there is a loader available from SourceForge.net here.

License is LGPL however which might put some folks off.

Cheers,
dhm

Share this post


Link to post
Share on other sites
Deutschland wird Weltmeister!

And I could help you out with a md2-loader but without animation, too...
It's included in the downloads here

Share this post


Link to post
Share on other sites
hey,
i want to load the following model + texture with your code:

if(loader.OpenFile("jeep1.3ds") == false) exit(0);
.....
map = SDL_LoadBMP("jeep1.bmp"/*t.name.c_str()*/);



model + texture:
3dModel


but i get an error at:

for(int i = 0; i < numfaces[j]; ++i)
{
glNormal3f(n[f[c]*3], n[f[c]*3+1], n[f[c]*3+2]); <----




any idea?

bye

[Edited by - Surfman19 on July 3, 2006 7:56:46 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Surfman19
hey,
i want to load the following model + texture with your code:
*** Source Snippet Removed ***

model + texture:
3dModel


but i get an error at:
*** Source Snippet Removed ***


any idea?

bye


Do you mean a compiler error? What does it say actually? Whicj compiler do you use?
But be warned that the SDL example is not a generic mesh viewer. Its only pourpose is to show a way to include the library in a real app, and I wouldn't be surprised to discover that it doesn't work with other models/textures: it was written for that one, and requires that the texture is saved in tga format with alpha channel (IIRC).
You can try, of course, but try also giving a look to the short tutorial in the documentation.

Share this post


Link to post
Share on other sites
hey,
i get an runtime error at:

glNormal3f(n[f[c]*3], n[f[c]*3+1], n[f[c]*3+2]);



but your texture is a .bmp too...

i use visual studio 2005!

cu

Share this post


Link to post
Share on other sites
runtime error - are you sure? does the program crash at this point`?

Share this post


Link to post
Share on other sites
I'm currently testing the app with your model. As soon as I have some informations for you I will tell you. But remember that this small viewer is not a general pourpose mesh viewer.

EDIT: Ok, now it works. Those are the lines to change:
-Replace the name of the model to be opened (near line 160) with the name of your jeep.
-At the beginning of the file is defined the costant MAX_OBJECTS. Currently it is set to 5. Increase it to 7:
const int MAX_OBJECTS = 7;
-Near line 240 there is the following instruction:
glTexImage2D(GL_TEXTURE_2D, 0, 3, map->w, map->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, map->pixels);
Replace the GL_BGRA with GL_RGB
-At last, near line 60 I set the position and rotation of the model. Your model must be rotated and since it is bigger than the monster, let's put it farer from the camera.
Replace all that code with:

//Rotate the triangle
glTranslatef(0.0,-6,-20.0f);
glRotatef(angle,0.0,1, 0.0);
glRotatef(90,-1.0,0.0, 0.0);
angle += 0.2;



Now it should work.
By the way, You were right when you told me that also my texture were bitmaps. The fact is that initially I used tga, but tga stores the pixels in a different order than opengl does for texture, and I had to reorder them by hand. To keep the code as short and simple as possible I prefered to remove that code and use bmp instead (loosing that way the alpha channel).
I hope that all this works, let me know.

[Edited by - cignox1 on July 4, 2006 12:36:49 AM]

Share this post


Link to post
Share on other sites
hey,

thx, now its works fine;) why do you define a const int MAX_OBJECTS? my texture is a .bmp and it only works with GL_BGRA at the glTexImage2D!

bye

Share this post


Link to post
Share on other sites
Quote:
Original post by Surfman19
hey,

thx, now its works fine;) why do you define a const int MAX_OBJECTS? my texture is a .bmp and it only works with GL_BGRA at the glTexImage2D!

bye


I use MAX_OBJECTS to set the array length. It is a value I use often, so it is easier to set it once than reading the whole code and change every occurrence.

And about GL_BGRA vs. GL_RGB that's strange... I got a seg fault without it, but it could have been another point of the code. It seems that your .bmp is a 32 bit image (what is the pourpose of the .jpg, by the way?) so you're right: GL_BGRA should be the correct flag. But I would expect you to use 4 bytes in the texture creation function, not 3...
Well, the important thing is that it works. Understanding also 'how' and 'why' would be asking too much ;-)

Share this post


Link to post
Share on other sites
hey,
my .bmp is a 32 bit image!! first i thought i could use .jpg too;)

3ds is not right format for animation? where do you use your 3ds loader, in a game? how about Bone-Animation aka Skinning?

bye

Share this post


Link to post
Share on other sites
hi,
i want to made a 3d model with bone animation! does someone has some good tutorials or informations about?

bye

Share this post


Link to post
Share on other sites
Quote:
Original post by Surfman19
hey,
my .bmp is a 32 bit image!! first i thought i could use .jpg too;)

3ds is not right format for animation? where do you use your 3ds loader, in a game? how about Bone-Animation aka Skinning?

bye


I wrote the 3ds loader because I was bored by trianges and cubes. But pretty soon I was annoyed by some limitations of the format, so I'm writing a script for lightwave to export the models to a custom format.
I think that you may try COLLADA or X formats: they seem to be supported by most 3d apps and should support all the features you need (and many more).

EDIT: if you want to make creatures with animations, why not giving a look to MD2/MD3 (quake formats)? They appear to be widely used for this task, though I'm not sure how they model the charachters because I don't think 3ds, lw, maya and others provide a md2 exporter (but perhaps blender or milkshape do).

Share this post


Link to post
Share on other sites
Quote:
Original post by Surfman19
hi,
i want to made a 3d model with bone animation! does someone has some good tutorials or informations about?

bye


You should have a look at the Cal3D Library ( http://home.gna.org/cal3d ). It is a C++ library to load 3D models (from 3DS or others) and performs bones animation. It works transparently with OpenGL and DirectX. Tutorials are included.

Share this post


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

  • Advertisement