3D Model Loader

Started by
25 comments, last by Surfman19 17 years, 9 months ago
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.
Advertisement
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
Deutschland wird Weltmeister!

And I could help you out with a md2-loader but without animation, too...
It's included in the downloads here
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]
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.
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
runtime error - are you sure? does the program crash at this point`?
yes! could u test it with my model? please;) italy will win;)))
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]
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

This topic is closed to new replies.

Advertisement