Jump to content
  • Advertisement
Sign in to follow this  
Marco H

Got a problem with ms3d-loading (materials)

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

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 :-)

Share this post


Link to post
Share on other sites
Advertisement
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.


/* 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

Share this post


Link to post
Share on other sites
Thanks, I found out where the problem was located. In my draw method I did the following:

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

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!