@@ -204,20 +204,26 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene)
204
204
// copy control point data from Unity to FBX
205
205
for ( int v = 0 ; v < NumControlPoints ; v ++ )
206
206
{
207
- fbxMesh . SetControlPointAt ( new FbxVector4 ( meshInfo . Vertices [ v ] . x , meshInfo . Vertices [ v ] . y , meshInfo . Vertices [ v ] . z ) , v ) ;
207
+ // convert from left to right-handed by negating x (Unity negates x again on import)
208
+ fbxMesh . SetControlPointAt ( new FbxVector4 ( - meshInfo . Vertices [ v ] . x , meshInfo . Vertices [ v ] . y , meshInfo . Vertices [ v ] . z ) , v ) ;
208
209
}
209
210
210
211
ExportUVs ( meshInfo , fbxMesh ) ;
211
212
212
213
var fbxMaterial = ExportMaterial ( meshInfo . Material , fbxScene ) ;
213
214
fbxNode . AddMaterial ( fbxMaterial ) ;
214
215
216
+ /*
217
+ * Triangles have to be added in reverse order,
218
+ * or else they will be inverted on import
219
+ * (due to the conversion from left to right handed coords)
220
+ */
215
221
for ( int f = 0 ; f < meshInfo . Triangles . Length / 3 ; f ++ )
216
222
{
217
223
fbxMesh . BeginPolygon ( ) ;
218
- fbxMesh . AddPolygon ( meshInfo . Triangles [ 3 * f ] ) ;
219
- fbxMesh . AddPolygon ( meshInfo . Triangles [ 3 * f + 1 ] ) ;
220
224
fbxMesh . AddPolygon ( meshInfo . Triangles [ 3 * f + 2 ] ) ;
225
+ fbxMesh . AddPolygon ( meshInfo . Triangles [ 3 * f + 1 ] ) ;
226
+ fbxMesh . AddPolygon ( meshInfo . Triangles [ 3 * f ] ) ;
221
227
fbxMesh . EndPolygon ( ) ;
222
228
}
223
229
@@ -235,8 +241,10 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
235
241
UnityEngine . Vector3 unityScale = unityTransform . localScale ;
236
242
237
243
// 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 ) ;
244
+ // Negating the x value of the translation, and the y and z values of the rotation
245
+ // to convert from Unity to Maya coordinates (left to righthanded)
246
+ var fbxTranslate = new FbxDouble3 ( - unityTranslate . x , unityTranslate . y , unityTranslate . z ) ;
247
+ var fbxRotate = new FbxDouble3 ( unityRotate . x , - unityRotate . y , - unityRotate . z ) ;
240
248
var fbxScale = new FbxDouble3 ( unityScale . x , unityScale . y , unityScale . z ) ;
241
249
242
250
// set the local position of fbxNode
0 commit comments