diff --git a/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.cpp b/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.cpp index b3e208e1b..64520dd88 100644 --- a/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.cpp +++ b/src/osgPlugins/fbx/fbxMaterialToOsgStateSet.cpp @@ -193,16 +193,35 @@ osg::ref_ptr FbxMaterialToOsgStateSet::fbxTextureToOsgTexture(co } } - FbxFileTexture* FbxMaterialToOsgStateSet::selectFbxFileTexture(const FbxProperty& lProperty) { if (lProperty.IsValid()) { - int lNbTex = lProperty.GetSrcObjectCount(); - for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) + // check if layered textures are used... + int layeredTextureCount = lProperty.GetSrcObjectCount(); + if (layeredTextureCount) { - FbxFileTexture* lTexture = FbxCast(lProperty.GetSrcObject(lTextureIndex)); - if (lTexture) return lTexture; + // find the first valud FileTexture + for (int layeredTextureIndex = 0; layeredTextureIndex(lProperty.GetSrcObject(layeredTextureIndex)); + int lNbTex = layered_texture->GetSrcObjectCount(); + for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) + { + FbxFileTexture* lTexture = FbxCast(layered_texture->GetSrcObject(lTextureIndex)); + if (lTexture) return lTexture; + } + } + } + else + { + // find the first valud FileTexture + int lNbTex = lProperty.GetSrcObjectCount(); + for(int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) + { + FbxFileTexture* lTexture = FbxCast(lProperty.GetSrcObject(lTextureIndex)); + if (lTexture) return lTexture; + } } } return 0;