Skip to content

Commit 0186ef9

Browse files
authored
Merge pull request #323 from Unity-Technologies/UNI-29415-fix-so-cone-angle-animated-maya
UNI-29415 fix so spot angle animates cone angle in Maya
2 parents 37b85f8 + 315d298 commit 0186ef9

File tree

1 file changed

+44
-45
lines changed

1 file changed

+44
-45
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,8 @@ protected void ExportAnimationCurve (UnityEngine.Object uniObj,
15361536
Debug.Log ("Exporting animation for " + uniObj.ToString() + " (" + uniPropertyName + ")");
15371537
}
15381538

1539-
FbxPropertyChannelPair fbxPropertyChannelPair;
1540-
if (!FbxPropertyChannelPair.TryGetValue (uniPropertyName, out fbxPropertyChannelPair)) {
1539+
FbxPropertyChannelPair[] fbxPropertyChannelPairs;
1540+
if (!FbxPropertyChannelPair.TryGetValue (uniPropertyName, out fbxPropertyChannelPairs)) {
15411541
Debug.LogWarning (string.Format ("no mapping from Unity '{0}' to fbx property", uniPropertyName));
15421542
return;
15431543
}
@@ -1555,39 +1555,35 @@ protected void ExportAnimationCurve (UnityEngine.Object uniObj,
15551555
return;
15561556
}
15571557

1558-
// map unity property name to fbx property
1559-
var fbxProperty = fbxNode.FindProperty(fbxPropertyChannelPair.Property, false);
1560-
if (!fbxProperty.IsValid())
1561-
{
1562-
var fbxNodeAttribute = fbxNode.GetNodeAttribute();
1563-
if (fbxNodeAttribute != null)
1564-
{
1565-
fbxProperty = fbxNodeAttribute.FindProperty(fbxPropertyChannelPair.Property, false);
1558+
foreach (var fbxPropertyChannelPair in fbxPropertyChannelPairs) {
1559+
// map unity property name to fbx property
1560+
var fbxProperty = fbxNode.FindProperty (fbxPropertyChannelPair.Property, false);
1561+
if (!fbxProperty.IsValid ()) {
1562+
var fbxNodeAttribute = fbxNode.GetNodeAttribute ();
1563+
if (fbxNodeAttribute != null) {
1564+
fbxProperty = fbxNodeAttribute.FindProperty (fbxPropertyChannelPair.Property, false);
1565+
}
1566+
}
1567+
if (!fbxProperty.IsValid ()) {
1568+
Debug.LogError (string.Format ("no fbx property {0} found on {1} node or nodeAttribute ", fbxPropertyChannelPair.Property, fbxNode.GetName ()));
1569+
return;
15661570
}
1567-
}
1568-
if (!fbxProperty.IsValid())
1569-
{
1570-
Debug.LogError(string.Format("no fbx property {0} found on {1} node or nodeAttribute ", fbxPropertyChannelPair.Property, fbxNode.GetName()));
1571-
return;
1572-
}
15731571

1574-
// Create the AnimCurve on the channel
1575-
FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve (fbxAnimLayer, fbxPropertyChannelPair.Channel, true);
1572+
// Create the AnimCurve on the channel
1573+
FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve (fbxAnimLayer, fbxPropertyChannelPair.Channel, true);
15761574

1577-
// create a convert scene helper so that we can convert from Unity to Maya
1578-
// AxisSystem (LeftHanded to RightHanded) and FBX's default units
1579-
// (Meters to Centimetres)
1580-
var convertSceneHelper = new UnityToMayaConvertSceneHelper (uniPropertyName);
1575+
// create a convert scene helper so that we can convert from Unity to Maya
1576+
// AxisSystem (LeftHanded to RightHanded) and FBX's default units
1577+
// (Meters to Centimetres)
1578+
var convertSceneHelper = new UnityToMayaConvertSceneHelper (uniPropertyName);
15811579

1582-
// TODO: we'll resample the curve so we don't have to
1583-
// configure tangents
1584-
if (ModelExporter.ExportSettings.BakeAnimation)
1585-
{
1586-
ExportAnimationSamples(uniAnimCurve, fbxAnimCurve, frameRate, convertSceneHelper);
1587-
}
1588-
else
1589-
{
1590-
ExportAnimationKeys(uniAnimCurve, fbxAnimCurve, convertSceneHelper);
1580+
// TODO: we'll resample the curve so we don't have to
1581+
// configure tangents
1582+
if (ModelExporter.ExportSettings.BakeAnimation) {
1583+
ExportAnimationSamples (uniAnimCurve, fbxAnimCurve, frameRate, convertSceneHelper);
1584+
} else {
1585+
ExportAnimationKeys (uniAnimCurve, fbxAnimCurve, convertSceneHelper);
1586+
}
15911587
}
15921588
}
15931589

@@ -1642,75 +1638,78 @@ public FbxPropertyChannelPair(string p, string c):this() {
16421638
/// Map a Unity property name to the corresponding FBX property and
16431639
/// channel names.
16441640
/// </summary>
1645-
public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPair prop)
1641+
public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPair[] prop)
16461642
{
16471643
System.StringComparison ct = System.StringComparison.CurrentCulture;
16481644

16491645
// Transform Scaling
16501646
if (uniPropertyName.StartsWith ("m_LocalScale.x", ct) || uniPropertyName.EndsWith ("S.x", ct)) {
1651-
prop = new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_X);
1647+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_X) };
16521648
return true;
16531649
}
16541650
if (uniPropertyName.StartsWith ("m_LocalScale.y", ct) || uniPropertyName.EndsWith ("S.y", ct)) {
1655-
prop = new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Y);
1651+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Y) };
16561652
return true;
16571653
}
16581654
if (uniPropertyName.StartsWith ("m_LocalScale.z", ct) || uniPropertyName.EndsWith ("S.z", ct)) {
1659-
prop = new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Z);
1655+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Z) };
16601656
return true;
16611657
}
16621658

16631659
// Transform Translation
16641660
if (uniPropertyName.StartsWith ("m_LocalPosition.x", ct) || uniPropertyName.EndsWith ("T.x", ct)) {
1665-
prop = new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_X);
1661+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_X) };
16661662
return true;
16671663
}
16681664
if (uniPropertyName.StartsWith ("m_LocalPosition.y", ct) || uniPropertyName.EndsWith ("T.y", ct)) {
1669-
prop = new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Y);
1665+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Y) };
16701666
return true;
16711667
}
16721668
if (uniPropertyName.StartsWith ("m_LocalPosition.z", ct) || uniPropertyName.EndsWith ("T.z", ct)) {
1673-
prop = new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Z);
1669+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Z) };
16741670
return true;
16751671
}
16761672

16771673
if (uniPropertyName.StartsWith("m_Intensity", ct))
16781674
{
1679-
prop = new FbxPropertyChannelPair ("Intensity", null);
1675+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Intensity", null) };
16801676
return true;
16811677
}
16821678

16831679
if (uniPropertyName.StartsWith("m_SpotAngle", ct))
16841680
{
1685-
prop = new FbxPropertyChannelPair ("OuterAngle", null);
1681+
prop = new FbxPropertyChannelPair[]{
1682+
new FbxPropertyChannelPair ("OuterAngle", null),
1683+
new FbxPropertyChannelPair ("InnerAngle", null)
1684+
};
16861685
return true;
16871686
}
16881687

16891688
if (uniPropertyName.StartsWith("m_Color.r", ct))
16901689
{
1691-
prop = new FbxPropertyChannelPair ("Color", Globals.FBXSDK_CURVENODE_COLOR_RED);
1690+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Color", Globals.FBXSDK_CURVENODE_COLOR_RED) };
16921691
return true;
16931692
}
16941693

16951694
if (uniPropertyName.StartsWith("m_Color.g", ct))
16961695
{
1697-
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_GREEN);
1696+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_GREEN) };
16981697
return true;
16991698
}
17001699

17011700
if (uniPropertyName.StartsWith("m_Color.b", ct))
17021701
{
1703-
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_BLUE);
1702+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_BLUE) };
17041703
return true;
17051704
}
17061705

17071706
if (uniPropertyName.StartsWith("field of view", ct))
17081707
{
1709-
prop = new FbxPropertyChannelPair("FieldOfView", null);
1708+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair("FieldOfView", null) };
17101709
return true;
17111710
}
17121711

1713-
prop = new FbxPropertyChannelPair ();
1712+
prop = new FbxPropertyChannelPair[]{};
17141713
return false;
17151714
}
17161715
}

0 commit comments

Comments
 (0)