Added FbxLayeredTexture support

This commit is contained in:
Robert Osfield 2018-03-12 10:29:04 +00:00
parent 125263f216
commit 957bd4b886

View File

@ -193,16 +193,35 @@ osg::ref_ptr<osg::Texture2D> FbxMaterialToOsgStateSet::fbxTextureToOsgTexture(co
} }
} }
FbxFileTexture* FbxMaterialToOsgStateSet::selectFbxFileTexture(const FbxProperty& lProperty) FbxFileTexture* FbxMaterialToOsgStateSet::selectFbxFileTexture(const FbxProperty& lProperty)
{ {
if (lProperty.IsValid()) if (lProperty.IsValid())
{ {
int lNbTex = lProperty.GetSrcObjectCount<FbxFileTexture>(); // check if layered textures are used...
for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) int layeredTextureCount = lProperty.GetSrcObjectCount<FbxLayeredTexture>();
if (layeredTextureCount)
{ {
FbxFileTexture* lTexture = FbxCast<FbxFileTexture>(lProperty.GetSrcObject<FbxFileTexture>(lTextureIndex)); // find the first valud FileTexture
if (lTexture) return lTexture; for (int layeredTextureIndex = 0; layeredTextureIndex<layeredTextureCount; ++layeredTextureIndex)
{
FbxLayeredTexture* layered_texture = FbxCast<FbxLayeredTexture>(lProperty.GetSrcObject<FbxLayeredTexture>(layeredTextureIndex));
int lNbTex = layered_texture->GetSrcObjectCount<FbxFileTexture>();
for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++)
{
FbxFileTexture* lTexture = FbxCast<FbxFileTexture>(layered_texture->GetSrcObject<FbxFileTexture>(lTextureIndex));
if (lTexture) return lTexture;
}
}
}
else
{
// find the first valud FileTexture
int lNbTex = lProperty.GetSrcObjectCount<FbxFileTexture>();
for(int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++)
{
FbxFileTexture* lTexture = FbxCast<FbxFileTexture>(lProperty.GetSrcObject<FbxFileTexture>(lTextureIndex));
if (lTexture) return lTexture;
}
} }
} }
return 0; return 0;