Jump to content
  • Advertisement
Sign in to follow this  
iedoc

loading models

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

does anybody know where i could learn how to load models from a 3d modeling program? i would like to learn how to load from maya.

Share this post


Link to post
Share on other sites
Advertisement
What you will want to do is export your model in the .OBJ format. Then you can use a opengl OBJ loading tutorial, such as the one here (Tutorials->OpenGL->Page 8->.obj Loading), then load the model like that. That is your best bet with Maya. Now for all that texture specific stuff, I'm not sure if it will workw ith OBJ files.

Share this post


Link to post
Share on other sites
thanks for replying. ive been looking for a good tutorial on how to load obj files into c++, and this one looks good. i hope it is anyways.

Share this post


Link to post
Share on other sites
iedoc: You have ask exactly the same question here. There have been quite a few replys to your question. I even wrote up half of the .obj loading code for you. You should realy try to do it. If you get stuck tell us where you get stuck and we will help you.

If you are looking for ready to use code that you can copy&paste you wont learn a thing. If the concept of loading a model or representing a model with data structures gets over your head, it would be a good idea, to get more familiar with this concepts by doing something simpler. Display lists for example would be a step into the direction of loading and displaying complex 3d models.

Maybe you should also take some time to familiarize your self with data stuctures in C++ or any other language. The greatest tools won't be worth a thing if you don't know how and when to use them.

just my 2 Cents.

Share this post


Link to post
Share on other sites
sorry, sorry. i know i asked already, but i thought nobody would reply again. anyways, im not looking for copy and paste code, thats what im having troubles with. i want to learn it theroughly or whatever, but i can't find a tutorial that explains everything. i finally got the obj loaded and i can see it and everything, and i got sort of the hang of things, but now, i don't know how to get textures onto it, could you please help me with that? i seriously tried a lot of things, i just cant do it.

now that i think of it, maybe im just not ready for models, i can do a lot of other things, but this model stuff is hard.

Share this post


Link to post
Share on other sites
one more thing, is there a good plugin for maya or 3ds max that will export in .obj?

Share this post


Link to post
Share on other sites
For texture you have to turn texturing on and you have to load and bind the texture. How this is done is explained here. You just have to adapt the idea to use the texture and vertex coordinates in the .obj file.

As for e precise description of the .obj file format there is one here. There are some advanced features that you will not need in it though.

Share this post


Link to post
Share on other sites
i know how to load textures and use them and stuff, i just don't know how to load them from the .obj file, i don't get how the 1/1/1 2/2/2 stuff works, could somebody please help me?

[Edited by - iedoc on June 16, 2005 8:22:48 AM]

Share this post


Link to post
Share on other sites
it means vertex_index/texture_index/normal_index

supose you have stored them in three arrays (2 dimensional arrays) you would do somthing like this
for lets say face

f 1/2/1 5/3/3 123/75/32


glNormal3f(normals[0][0], normal[0][1], normal[0][2]);
glTextCoord2f(texture[1][0], texture[1][1])
glVertex3f(vertex[1][0], vertex[1][1], vertex[1][2]);

glNormal3f(normals[2][0], normal[2][1], normal[2][2]);
glTextCoord2f(texture[2][0], texture[2][1])
glVertex3f(vertex[4][0], vertex[4][1], vertex[4][2]);

glNormal3f(normals[31][0], normal[31][1], normal[31][2]);
glTextCoord2f(texture[74][0], texture[74][1])
glVertex3f(vertex[122][0], vertex[122][1], vertex[122][2]);




Notice that you have to subtract 1 from the indexes since they start at 1 while array indexes start at 0.

The texture filename and materials are stored in a seperate file wich is marked in the .obj with 'include bla.mtl' if I recall correctly. This should have been created when exporting the file. Just open it up and take a look at it. its preaty staight forward.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!