From 957bd4b8866b35a9fa1c5ab708fc6c9d897efd22 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 12 Mar 2018 10:29:04 +0000 Subject: [PATCH] Added FbxLayeredTexture support --- .../fbx/fbxMaterialToOsgStateSet.cpp | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) 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;