Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

textures and materials relations

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
260 Views, 3 Replies

textures and materials relations

Hi

i´m making an exporter to my own format from fbx files and i can get the material from a layer and textures with this code

mesh->GetLayer(layer_index)->GetMaterials()
or
mesh->GetLayer(layer_index)->GetDiffuseTextures()

being mesh a KFbxMesh object.

i also can get all the info i want from the materials and textures (colors, factors, texture filenames, uv´s, etc..)

My problem is that i don´t know how to know the relation between the materials and the textures. I mean, i don´t know which textures belong to each material

i´ve looked in the material class, but don´t see any reference to which textures belongs to it. Nothing in the texture class neither

any idea???

help will be appreciated

PS: sorry for my english
3 REPLIES 3
Message 2 of 4
Numerator
in reply to: Anonymous

The layers are mapped to polygons in the elements of each layer. Depending on the mapping mode, there will be an array of polygon ids that the material is mapped to. For example:


for (int i = 0; i < pMesh->GetLayerCount(); i++)
{

KFbxLayer * pLayer = pMesh->GetLayer(i);
if (pLayer == NULL)
continue;

KFbxLayerElementMaterial* pMaterialLayer = pLayer->GetMaterials();
if (pMaterialLayer == NULL)
return S_OK;


KFbxLayerElement::EMappingMode mappingMode = pMaterialLayer->GetMappingMode();


if (mappingMode == KFbxLayerElement::eBY_POLYGON )
{


if (pMaterialLayer->GetReferenceMode() == KFbxLayerElement::eINDEX ||
pMaterialLayer->GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
{
int i;
int* lMaterialIndices = pMaterialLayer->GetIndexArray().GetArray();
int lMaterialIndexCount = pMaterialLayer->GetIndexArray().GetCount();


for (i = 0; i < lMaterialIndexCount; i++)
{
int matID = lMaterialIndices ;


per_polygon_material = matID;


}
....

-Doug
Message 3 of 4
Anonymous
in reply to: Anonymous

so, as far as i understand your reply

in order to know which diffuse texture belongs to each material i have to compare the polygons referenced by the material and the polygons referenced by the texture
if both (material and texture) do reference to the same polygon group, it means that the texture is the one used by the material

i don´t know if that is exactly what you wanted to say, cause i can´t see any reference to textures in your reply, buy anyway, you´ve given me a method to know what i was looking for

thanks 😉
Message 4 of 4
Numerator
in reply to: Anonymous

>i don´t know if that is exactly what you wanted to say,
Yes, that is what I was trying to say 😉 Textures use polygon indices as well.

-Doug

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report