Advertisement

3d models (maya)

Started by May 31, 2005 11:41 AM
33 comments, last by iedoc 19 years, 5 months ago
C++ source code for an obj loader. It's not 100% finished, but all of the mesh and material stuff works. (it's just the nurbs and curves that are a little flaky, but that shouldn't affect you since maya wont export them).

The obj file format is desceptive, it's actually a bit more complicated than it at first seems - most of this is down to the format not identifying how many data elements there are before you read them. The format does also support nurbs and materials, though not many people handle those.

My loaders are designed to be a bit more complete. They get slightly more complicated because they can optionally calculate normals/tangents and they can convert the data into vertex arrays or vertex buffer objects. (C++ one doesn't calculate tangents).

gametutorials.com used to have an obj loading tutorial as well....

thanks again robthebloke.

how did you guys learn how to load models?
Advertisement
took a stab at it, got it wrong, did it better next time, repeat....
all right, i guess ill try it again. actually, ill just keep trying it till i learn how to do it.

isn't there a book or something that will tell me how to do this?

also, is nefthy's code right? will that help me with loading the .obj, cause i tried for like 3 hours to use that and one of nehe's tutorials to get it to work, and i couldn't figure it out.

i don't even care anymore if its .obj files that are loaded, i just want to learn how to load models from maya. and if not that, any modeling program is fine.

[Edited by - iedoc on June 12, 2005 3:53:28 PM]
Why don't you post what you've coded so far so we can see what is wrong. Also post the obj file you are trying to load.
thats ok, i was finaly able to load obj, but now i don't know how to load textures, but im pretty sure i can figure that out on my own.

one more thing, what does .obj support and not support?
Advertisement
nevermind, i know how to load textures now, thanks guys.

does .obj support animation, cause if it does, can someone help me out with it?
obj doesn't support animation, as far as I know. At least, it isn't in the specs... Try looking into more advanced formats as .x and .3ds for that.
i would, but i don't know how to load them
ok, this is what i got right now.

glBindTexture(GL_TEXTURE_2D, texture[1]);

for(int i = 0; i < Model.totalFaces; i++)
{

if(Model.polyList.numPoints == 3) glBegin(GL_TRIANGLES);
else if(Model.polyList.numPoints == 4) glBegin(GL_QUADS);
else glBegin(GL_POLYGON);

for(int j = 0; j < Model.polyList.numPoints; j++)
{

glTexCoord2f(Model.texturecoords.tu,
Model.texturecoords.tv);


glNormal3f(Model.polyList.normal.x,
Model.polyList.normal.y,
Model.polyList.normal.z);

glVertex3f(Model.vertices[Model.polyList.Indices[j]].x,
Model.vertices[Model.polyList.Indices[j]].y,
Model.vertices[Model.polyList.Indices[j]].z);
}

glEnd();
}

everything is ok, but when i load up the game, the model just has one plain color, im guessing its the last one read from the texture. what should i do to make it so it has the texture on it?

This topic is closed to new replies.

Advertisement