Skip to main content
gamedev.net
🔒 Locked

3ds max export plugin help

Started by bfi3d Mar 6, 2009 at 5:21 PM 1 replies 1.5k views
Original Post
bfi3d
bfi3d
how to index the material Id of the face of a mesh in 3ds max? I known the Id could be gained just in this way: pMesh->getFaceMtlIndex(i) but which material is index 0? which material is index 1? .... Should I using the method just like the followwing ? Or shuold I gain the material through the 24 material balls? Or other methods?

void extractMtls(Mtl* pMtl)
{
if(pMtl &&pMtl->ClassID() == Class_ID(DMTL_CLASS_ID, 0))
{
mtlVector.push_back((StdMat*)pMtl);
}

int subId;
for(subId = 0; subId < pMtl->NumSubMtls(); subId ++)
{
extractMtls(pMtl->GetSubMtl(subId));
}
}

Anyone can help me? Thx in advance!
alexcg
alexcg
Sorry, I don't know 3ds Max API well, so here it's something like pseudocode (actually it's piece of my exporter written on MaxScript).
-- node - triangle mesh, that we want to export to filematerial = node.materialmesh = convertToMesh nodeisMaterial = material != undefinedisMultiMaterial = ((classOf material) == multiMaterial)numFaces = getNumFaces meshfor i = 1 to numFaces do(  if isMaterial then  (    if isMultiMaterial then -- material is multiMaterial    (      matID = getFaceMatID mesh i      outputMaterial material[matID] -- output material data for current face      -- material[matID] - submaterial of material with index matID    )    else -- we have only 1 material applied to the object    (      outputMaterial material    )  )  else -- we have no applied materials to the object  (    format "No material" to:file  )  --  -- export face (vertices, texture coordinates, etc)  --)


Logic with 3ds Max API will be the same.
You can read about Multi Materials in the 3ds Max SDK Help.

P.S. Sorry for my poor English.
bfi3d
bfi3d
Thx for your reply. After reading your code, I have got some idea to solve the problem.

P.S. My english is also poor.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.