Skip to content

Commit 6d18025

Browse files
committed
move "Skel" into a constant
* remove "n" from loop * add node name to error * clarify comment about exporting bones with 0 rotation
1 parent c35952a commit 6d18025

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ public enum ExportFormat
107107
/// </summary>
108108
private static string DefaultCamera = "";
109109

110+
private const string SkeletonPrefix = "_Skel";
111+
110112
/// <summary>
111113
/// name prefix for custom properties
112114
/// </summary>
@@ -864,7 +866,7 @@ private bool ExportSkeleton (SkinnedMeshRenderer skinnedMesh, FbxScene fbxScene,
864866

865867
// Step 0: map transform to index so we can look up index by bone.
866868
Dictionary<Transform, int> index = new Dictionary<Transform, int>();
867-
for (int boneIndex = 0, n = bones.Length; boneIndex < n; boneIndex++) {
869+
for (int boneIndex = 0; boneIndex < bones.Length; boneIndex++) {
868870
Transform unityBoneTransform = bones [boneIndex];
869871
index[unityBoneTransform] = boneIndex;
870872
}
@@ -882,12 +884,12 @@ private bool ExportSkeleton (SkinnedMeshRenderer skinnedMesh, FbxScene fbxScene,
882884
// its corresponding parent, or to the scene if there is none.
883885
FbxNode fbxBoneNode;
884886
if (!MapUnityObjectToFbxNode.TryGetValue (t.gameObject, out fbxBoneNode)) {
885-
Debug.LogError ("node should already be created");
887+
Debug.LogErrorFormat("Node {0} should already be created", t.name);
886888
}
887889

888890
// Set it up as a skeleton node if we haven't already.
889891
if (fbxBoneNode.GetSkeleton () == null) {
890-
FbxSkeleton fbxSkeleton = FbxSkeleton.Create (fbxScene, t.name + "_Skel");
892+
FbxSkeleton fbxSkeleton = FbxSkeleton.Create (fbxScene, t.name + SkeletonPrefix);
891893

892894
var fbxSkeletonType = skinnedMesh.rootBone != t
893895
? FbxSkeleton.EType.eLimbNode : FbxSkeleton.EType.eRoot;
@@ -957,7 +959,8 @@ private bool ExportSkeleton (SkinnedMeshRenderer skinnedMesh, FbxScene fbxScene,
957959
double sign;
958960
matrix.GetElements (out translation, out rotation, out shear, out scale, out sign);
959961

960-
// Bones should have zero rotation, and use a pivot instead.
962+
// Export bones with zero rotation, using a pivot instead to set the rotation
963+
// so that the bones are easier to animate and the rotation shows up as the "joint orientation" in Maya.
961964
fbxBone.LclTranslation.Set (new FbxDouble3(-translation.X*UnitScaleFactor, translation.Y*UnitScaleFactor, translation.Z*UnitScaleFactor));
962965
fbxBone.LclRotation.Set (new FbxDouble3(0,0,0));
963966
fbxBone.LclScaling.Set (new FbxDouble3 (scale.X, scale.Y, scale.Z));

0 commit comments

Comments
 (0)