I have looked at the code for exporting LOD's to fbx and it is the same for all LOD's
#region Add UV coords
// Create UV for Diffuse channel
FbxLayerElementUV UVDiffuseLayer = FbxLayerElementUV.Create(mesh, "DiffuseUV");
UVDiffuseLayer.Mapping_Mode = FbxLayerElement.MappingMode.ByPolygonVertex;
UVDiffuseLayer.Reference_Mode = FbxLayerElement.ReferenceMode.IndexToDirect;
for (int i = 0; i < Verts.Length; i++)
{
FbxVector2 fu = new FbxVector2(Verts[i].TextureCoordinate.X, Verts[i].TextureCoordinate.Y);
UVDiffuseLayer.DirectArray.Add(fu);
}
layer.SetUVs(UVDiffuseLayer, FbxLayerElement.LayerElementType.DiffuseTextures);
#endregion
You can see I don't play with the UV coordinates at all. I just save them. So if it works for one LOD, it should work for all.
On a normal mesh, i.e. not a LOD, I do play with the UV coordinates.
#region Add UV coords
// Create UV for Diffuse channel
FbxLayerElementUV UVDiffuseLayer = FbxLayerElementUV.Create(mesh, "DiffuseUV");
UVDiffuseLayer.Mapping_Mode = FbxLayerElement.MappingMode.ByPolygonVertex;
UVDiffuseLayer.Reference_Mode = FbxLayerElement.ReferenceMode.IndexToDirect;
for (int i = 0; i < Verts.Length; i++)
{
FbxVector2 fu = getFBXUV(i);
//Debug.WriteLine(String.Format("{0}\t\t({1},{2})", i, Verts[i].TextureCoordinate.X, Verts[i].TextureCoordinate.Y));
UVDiffuseLayer.DirectArray.Add(fu);
}
layer.SetUVs(UVDiffuseLayer, FbxLayerElement.LayerElementType.DiffuseTextures);
#endregion
FbxVector2 getFBXUV(int i)
{
float x = Verts[i].TextureCoordinate.X;
x -= (int)x;
if (x < 0)
x += 1;
float y = Verts[i].TextureCoordinate.Y;
y -= (int)y;
if (y < 0)
y += 1;
y = 1 - y;
return new FbxVector2(x, y);
}
I did this after a long conversation with Mike I think. So long ago I am not sure why.
When it comes to hooks, I was correct. The problem is that FBX does not store matrices directly. A matrix is represented by translation, rotation, and scaling.
#region Hooks
foreach (Hook h in Hooks)
{
FbxNode hnode = FbxNode.Create(Form1.Instance.sdkManager, h.Name);
hnode.Shading_Mode = FbxNode.ShadingMode.WireFrame;
Quaternion qrot;
Vector3 tran;
Vector3 scl;
h.matrix.Decompose(out scl, out qrot, out tran);
Vector3 hlrot = FromQ2(rotation);
hnode.Limits.ScalingLimitActive = false;
hnode.Limits.RotationLimitActive = false;
hnode.RotationActive = true;
hnode.ScalingActive = true;
hnode.SetRotationOrder(FbxNode.PivotSet.SourceSet, FbxRotationOrder.EulerZXY);
Vector3 rtran = tran;
hnode.LclTranslation.Set(new FbxDouble3(rtran.X, rtran.Y, rtran.Z));
hnode.LclScaling.Set(new FbxDouble3(scl.X, scl.Y, scl.Z));
hnode.LclRotation.Set(new FbxDouble3(hlrot.X, hlrot.Y, hlrot.Z));
if (Form1.ExportHooks)
node.AddChild(hnode);
}
#endregion
Now there is lot's that can go wrong with that. It could just be the rotation order is incorrect I set it to FbxRotationOrder.EulerZXY which could easily be wrong.
I don't have any 3D editors that can load FBX so I am limited with what I can test. However I do have autodesk's FBX converter and everything I have looked at so far seems fine.