Got a problem with ms3d-loading (materials)
Hello,
I have got a problem with the materials of Milkshape. In my programm I use the ms3d files to load models. Everything is fine, except for the materials. I found out, that the number of materials limits the number of groups, being drawn with a material.
For Example: I have 10 groups and 3 materials. So, only the first 3 groups have their texture, the others are blank.
Do you have any suggestion what could be going wrong?
Thanks in advance :-)
In milkshape, Materials are referenced just like vertices; that is the global model msModel(see below) stores an array of material objects. The materials are then referenced by the mesh (or group) msMesh(see below) by an index. When you want to draw a group you must first find the material from your own material array, bind it, and then draw the group. That way if groups share the same material you dont have to load it twice. Also note that milkshape stores its materials using relative paths.
Good luck on your model loader. Once you get milkshape to load, I recommend that you write your own format to fit your needs. You can also write milkshape plugins to export to your own format (that way you can pull off modular animation).
Cheers,
-llvllatrix
/* msModel */typedef struct msModel{ int nNumMeshes; int nNumAllocedMeshes; msMesh* pMeshes; int nNumMaterials; int nNumAllocedMaterials; msMaterial* pMaterials; int nNumBones; int nNumAllocedBones; msBone* pBones; int nFrame; int nTotalFrames; msVec3 Position; msVec3 Rotation;} msModel;/* msMesh */typedef struct msMesh{ byte nFlags; char szName[MS_MAX_NAME]; char nMaterialIndex; word nNumVertices; word nNumAllocedVertices; msVertex* pVertices; word nNumNormals; word nNumAllocedNormals; msVec3* pNormals; word nNumTriangles; word nNumAllocedTriangles; msTriangle* pTriangles;} msMesh;
Good luck on your model loader. Once you get milkshape to load, I recommend that you write your own format to fit your needs. You can also write milkshape plugins to export to your own format (that way you can pull off modular animation).
Cheers,
-llvllatrix
Thanks, I found out where the problem was located. In my draw method I did the following:
Thanks man, though the mistake was obvious I did not realize it...
Would be a nice idea, but the Milkshape models have everything I need, so why to change anything? I simply want some models to get loaded and therefore Milkshape and its models are just right.
Thanks for you help,
Marco
for(unsigned int x=0;x<(*num_groups);x++) { act_material=group_list[x].materialIndex; //[...] if(act_material >= 0) { if(materials[x].texID > 0) //and here was the error //must be materials[act_material].texID { glBindTexture(GL_TEXTURE_2D,materials[act_material] .texID); //same here //[...]
Thanks man, though the mistake was obvious I did not realize it...
Quote: Good luck on your model loader. Once you get milkshape to load, I recommend that you write your own format to fit your needs. You can also write milkshape plugins to export to your own format (that way you can pull off modular animation).
Would be a nice idea, but the Milkshape models have everything I need, so why to change anything? I simply want some models to get loaded and therefore Milkshape and its models are just right.
Thanks for you help,
Marco
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement