Skip to content

Commit 06bc7ce

Browse files
committed
fix so triangles are not inverted when exported
1 parent 0a50003 commit 06bc7ce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Assets/Editor/FbxExporter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene)
204204
// copy control point data from Unity to FBX
205205
for (int v = 0; v < NumControlPoints; v++)
206206
{
207-
fbxMesh.SetControlPointAt(new FbxVector4 (meshInfo.Vertices [v].x, meshInfo.Vertices [v].y, meshInfo.Vertices [v].z), v);
207+
fbxMesh.SetControlPointAt(new FbxVector4 (-meshInfo.Vertices [v].x, meshInfo.Vertices [v].y, meshInfo.Vertices [v].z), v);
208208
}
209209

210210
ExportUVs (meshInfo, fbxMesh);
@@ -215,9 +215,9 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene)
215215
for (int f = 0; f < meshInfo.Triangles.Length / 3; f++)
216216
{
217217
fbxMesh.BeginPolygon ();
218-
fbxMesh.AddPolygon (meshInfo.Triangles [3 * f]);
219-
fbxMesh.AddPolygon (meshInfo.Triangles [3 * f + 1]);
220-
fbxMesh.AddPolygon (meshInfo.Triangles [3 * f + 2]);
218+
fbxMesh.AddPolygon (meshInfo.Triangles [3 * f + 2]);
219+
fbxMesh.AddPolygon (meshInfo.Triangles [3 * f + 1]);
220+
fbxMesh.AddPolygon (meshInfo.Triangles [3 * f]);
221221
fbxMesh.EndPolygon ();
222222
}
223223

@@ -235,8 +235,8 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
235235
UnityEngine.Vector3 unityScale = unityTransform.localScale;
236236

237237
// transfer transform data from Unity to Fbx
238-
var fbxTranslate = new FbxDouble3 (unityTranslate.x, unityTranslate.y, unityTranslate.z);
239-
var fbxRotate = new FbxDouble3 (unityRotate.x, unityRotate.y, unityRotate.z);
238+
var fbxTranslate = new FbxDouble3 (-unityTranslate.x, unityTranslate.y, unityTranslate.z);
239+
var fbxRotate = new FbxDouble3 (unityRotate.x, -unityRotate.y, -unityRotate.z);
240240
var fbxScale = new FbxDouble3 (unityScale.x, unityScale.y, unityScale.z);
241241

242242
// set the local position of fbxNode

0 commit comments

Comments
 (0)