|
Hello, to import materials correctly, you need both Way A and Way B.
Way A is to import the material itself, and Way B is to tell you how the material should be applied on a mesh.
For example, by Way A you can get all materials in the scene, define parameters of them, such as diffuse, specular, etc. Then by way B you can get the index array which tell you how there materials are mapped to the mesh.
For how the layerelement describe the mapping between material/uv and mesh, please take a look at FBX SDK Programmer’s Guide, the section “Applying Textures and Materials to Meshes->Using layers to control how a model is rendered->Creating layer elements for materials and textures”
To get the material or UV on all layers, yes, you need to use a loop.
Texture is different, they are connected to materials, so you need to get material first and then get the connected texture on certain property, for example, if you want to get the diffuse texture, you need to do :
lProperty = lSurfaceMaterial->FindProperty(KFbxSurfaceMaterial::sDiffuse);
if(lProperty.IsValid())
{
lDiffuseTexture = KFbxCast <KFbxTexture>(lProperty.GetSrcObject(KFbxTexture::ClassId, 0));
}
Please also take a look at ViewScene sample, GlDrawMesh() in GlFunction.cxx.
All the above are based on FBX SDK 2011.3.1, if you are using a earlier version, there might be difference.
Author: Jiayang Xu
|