Hi,
based on my experience during the last months I noticed that many times some
authoring software tends to export FBX models using FbxLayeredTexture instead
of FbxFileTexture even if only 1 texture is really used. When loading such
models with the current version of the FBX plugin, the model would look
un-textured.
I'd like to propose to support FbxLayeredTexture along with FbxFileTexture
properties, I've already a modified version of the fbxMaterialToOsgStateSet.cpp
file in order to read at least the first layer of a layered texture.
My idea is to replace this:
Code:
int lNbTex = lProperty.GetSrcObjectCount<FbxFileTexture>();
for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++)
{
FbxFileTexture* lTexture =
FbxCast<FbxFileTexture>(lProperty.GetSrcObject<FbxFileTexture>(lTextureIndex));
if (lTexture)
{
result.diffuseTexture = fbxTextureToOsgTexture(lTexture);
result.diffuseChannel = lTexture->UVSet.Get();
result.diffuseScaleU = lTexture->GetScaleU();
result.diffuseScaleV = lTexture->GetScaleV();
}
//For now only allow 1 texture
break;
}
with this (for every supported channel, not only the diffuse one of course):
Code:
// check if layered textures are used...
int layeredTextureCount =
lProperty.GetSrcObjectCount<FbxLayeredTexture>();
if(layeredTextureCount)
{
FbxLayeredTexture* layered_texture =
FbxCast<FbxLayeredTexture>(lProperty.GetSrcObject<FbxLayeredTexture>(0));
int lNbTex = layered_texture->GetSrcObjectCount<FbxFileTexture>();
if(lNbTex)
{
// at least 1 texture, use 1st...
for (int lTextureIndex = 0; lTextureIndex < lNbTex;
lTextureIndex++)
{
FbxFileTexture* lTexture =
FbxCast<FbxFileTexture>(layered_texture->GetSrcObject<FbxFileTexture>(lTextureIndex));
if (lTexture)
{
result.diffuseTexture =
fbxTextureToOsgTexture(lTexture);
result.diffuseChannel = lTexture->UVSet.Get();
result.diffuseScaleU = lTexture->GetScaleU();
result.diffuseScaleV = lTexture->GetScaleV();
}
//For now only allow 1 texture
break;
}
}
else
OSG_WARN << "FBX: Missing Textures in FbxLayeredTexture." <<
std::endl;
}
else
{
int lNbTex = lProperty.GetSrcObjectCount<FbxFileTexture>();
for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++)
{
FbxFileTexture* lTexture =
FbxCast<FbxFileTexture>(lProperty.GetSrcObject<FbxFileTexture>(lTextureIndex));
if (lTexture)
{
result.diffuseTexture = fbxTextureToOsgTexture(lTexture);
result.diffuseChannel = lTexture->UVSet.Get();
result.diffuseScaleU = lTexture->GetScaleU();
result.diffuseScaleV = lTexture->GetScaleV();
}
//For now only allow 1 texture
break;
}
}
What do you think?
Alessandro
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72794#72794
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org