Hi nasboy3d,
I heard back from the dev, here is his answer:
The FBX SDK does not provide a re-mapping function for this particular purpose. You will need to write one yourself (most likely after you loaded the file and before sending the data to your device). The code below is a possible example. Note that it simply shows how to access and modify the data but the algorithm may not work as you expect. No testing has been performed and the code is provided simply as a guide line.
for (int i = 0; i < lScene->GetSrcObjectCount(FbxMesh::ClassId); i++)
{
FbxMesh* lMesh = (FbxMesh*)lScene->GetSrcObject(FbxMesh::ClassId, i);
FbxLayerElementUV* lUVs = lMesh->GetLayer(0)->GetUVs();
ConvertMapping(lUVs, lMesh);
}
void ConvertMapping(FbxLayerElementUV* pUVs, FbxMesh* pMesh)
{
if (pUVs->GetMappingMode() == FbxLayerElement::eByPolygonVertex)
{
if (pUVs->GetReferenceMode() == FbxLayerElement::eIndexToDirect)
{
FbxArray<int> lNewIndexToDirect;
FbxArray<FbxVector2> lNewUVs;
// keep track of the processed control points
FbxSet lProcessedCP(pMesh->GetControlPointsCount());
for (int i = 0; i < pMesh->GetControlPointsCount(); i++)
lProcessedCP.Add((FbxHandle)i, (FbxHandle)false);
// visit each polygon and polygon vertex
for (int p = 0; p < pMesh->GetPolygonCount(); p++)
{
for (int pv = 0; pv < pMesh->GetPolygonSize(p); pv++)
{
int lCP = pMesh->GetPolygonVertex(p, pv);
// check if we already processed this control point
if (lProcessedCP.Get((FbxHandle)lCP) == 0)
{
FbxVector2 uv = pUVs->GetDirectArray().GetAt(lCP);
lNewUVs.Add(uv);
lNewIndexToDirect.Add(lCP);
lProcessedCP.SetItem((FbxHandle)lCP, (FbxHandle)true);
}
}
}
// change the content of the index array and its mapping
pUVs->SetMappingMode(FbxLayerElement::eByControlPoint);
pUVs->GetIndexArray().Clear();
pUVs->GetIndexArray().Resize(lNewIndexToDirect.GetCount());
int* lIndexArray = (int*)pUVs->GetIndexArray().GetLocked();
for (int i = 0; i < lNewIndexToDirect.GetCount(); i++)
lIndexArray = lNewIndexToDirect.GetAt(i);
pUVs->GetIndexArray().Release((void**)&lIndexArray);
// and the content of the direct array
pUVs->GetDirectArray().Clear();
pUVs->GetDirectArray().Resize(lNewUVs.GetCount());
FbxVector2* lDirectArray = (FbxVector2*)pUVs->GetDirectArray().GetLocked();
for (int j = 0; j < lNewUVs.GetCount(); j++)
lDirectArray = lNewUVs.GetAt(j);
pUVs->GetDirectArray().Release((void**)&lDirectArray);
}
}
}
Regards,
Carlos