I ventured into loading FBX Meshes do to the ability for morph targets, skeletal mesh animation and other neat stuff that we all love. However, tutorials on FBX SDK are hard to come by like finding the last milk in a apocolypic future store. I grabbed some samples from others and somehow miracably able to create a mesh. However, the UV's aren't right.
As sceen in the attachment. I looked at it closely and it appears to me that the UV's are using something other than the UV's. The code i have is:
for (int j = 0; j < meshArray.Size(); j++) {
vCount = meshArray[j]->GetControlPointsCount();
m_vertices = new myVertex[vCount];
Face face;
polygonCount = meshArray[j]->GetPolygonVertexCount() / 3;
numIndices = meshArray[j]->GetPolygonVertexCount();
FbxVector4 *vert = meshArray[j]->GetControlPoints();
int arrayIndex = 0;
//memcpy(vert, meshArray[j]->GetControlPoints(), sizeof(FbxVector4)* vCount);
for (int i = 0; i < polygonCount; i++) {
for (unsigned int k = 0; k < 3; k++) {
int index = 0;
FbxVector4 fbxNorm(0, 0, 0, 0);
FbxVector2 fbxUV(0, 0);
FbxVector4 Vers(0, 0, 0, 0);
FbxStringList UVStringNames;
meshArray[j]->GetUVSetNames(UVStringNames);
bool texCoordFound = false;
face.indices[k] = index = meshArray[j]->GetPolygonVertex(i, k);
Vers = vert[index];
m_vertices[index].position = XMFLOAT4(Vers.mData[0],Vers.mData[2],Vers.mData[1],0.0f);
meshArray[j]->GetPolygonVertexNormal(i, k, fbxNorm);
m_vertices[index].normal = XMFLOAT3(fbxNorm.mData[0], fbxNorm.mData[2], fbxNorm.mData[1]);
FbxLayerElementUV* fbxLayerUV = meshArray[j]->GetLayer(0)->GetUVs();
if (fbxLayerUV) {
int fbxUVIndex = 0;
switch (fbxLayerUV->GetMappingMode())
{
case FbxLayerElement::eByControlPoint :
fbxUVIndex = face.indices[k];
break;
case FbxLayerElement::eByPolygonVertex :
fbxUVIndex = meshArray[j]->GetTextureUVIndex(i, k, FbxLayerElement::eTextureDiffuse);
break;
}
fbxUV = fbxLayerUV->GetDirectArray().GetAt(fbxUVIndex);
}
m_vertices[index].texture = XMFLOAT2(fbxUV.mData[0], fbxUV.mData[1]);
}
Faces.push_back(face);
}
}
int indexCount = Faces.size() * 3;
indices = new unsigned long[indexCount];
int indicie = 0;
for (unsigned int i = 0; i < Faces.size(); ++i) {
indices[indicie++] = Faces[i].indices[2];
indices[indicie++] = Faces[i].indices[1];
indices[indicie++] = Faces[i].indices[0];
}
Faces.clear();
Perhaps the indices aren't really well. I believe I switched the order of how the indices are drawn for some reason but can't remember why because I moved on to MD5 mesh and MD5 animation loading. However, unhappy with loading MD5 and want to continue looking into how I can correct the FBX mesh's texture coordiants.
I'll also look at the viewScene sample that came with the SDK as well in the meantime.