@@ -1984,14 +1984,22 @@ private void ExportAnimationCurve (FbxNode fbxNode,
1984
1984
Debug . LogError ( string . Format ( "no fbx property {0} found on {1} node or nodeAttribute " , fbxPropertyChannelPair . Property , fbxNode . GetName ( ) ) ) ;
1985
1985
return ;
1986
1986
}
1987
+ if ( ! fbxProperty . GetFlag ( FbxPropertyFlags . EFlags . eAnimatable ) )
1988
+ {
1989
+ Debug . LogErrorFormat ( "fbx property {0} found on node {1} is not animatable" , fbxPropertyChannelPair . Property , fbxNode . GetName ( ) ) ;
1990
+ }
1987
1991
1988
1992
// Create the AnimCurve on the channel
1989
1993
FbxAnimCurve fbxAnimCurve = fbxProperty . GetCurve ( fbxAnimLayer , fbxPropertyChannelPair . Channel , true ) ;
1994
+ if ( fbxAnimCurve == null )
1995
+ {
1996
+ return ;
1997
+ }
1990
1998
1991
1999
// create a convert scene helper so that we can convert from Unity to Maya
1992
2000
// AxisSystem (LeftHanded to RightHanded) and FBX's default units
1993
2001
// (Meters to Centimetres)
1994
- var convertSceneHelper = new UnityToMayaConvertSceneHelper ( uniPropertyName ) ;
2002
+ var convertSceneHelper = new UnityToMayaConvertSceneHelper ( uniPropertyName , fbxNode ) ;
1995
2003
1996
2004
// TODO: we'll resample the curve so we don't have to
1997
2005
// configure tangents
@@ -2008,10 +2016,14 @@ internal class UnityToMayaConvertSceneHelper
2008
2016
bool convertDistance = false ;
2009
2017
bool convertLtoR = false ;
2010
2018
bool convertToRadian = false ;
2019
+ bool convertLensShiftX = false ;
2020
+ bool convertLensShiftY = false ;
2021
+
2022
+ FbxCamera camera = null ;
2011
2023
2012
2024
float unitScaleFactor = 1f ;
2013
2025
2014
- public UnityToMayaConvertSceneHelper ( string uniPropertyName )
2026
+ public UnityToMayaConvertSceneHelper ( string uniPropertyName , FbxNode fbxNode )
2015
2027
{
2016
2028
System . StringComparison cc = System . StringComparison . CurrentCulture ;
2017
2029
@@ -2025,6 +2037,12 @@ public UnityToMayaConvertSceneHelper(string uniPropertyName)
2025
2037
convertDistance |= partT ;
2026
2038
convertDistance |= uniPropertyName . StartsWith ( "m_Intensity" , cc ) ;
2027
2039
convertDistance |= uniPropertyName . ToLower ( ) . EndsWith ( "weight" , cc ) ;
2040
+ convertLensShiftX |= uniPropertyName . StartsWith ( "m_LensShift.x" , cc ) ;
2041
+ convertLensShiftY |= uniPropertyName . StartsWith ( "m_LensShift.y" , cc ) ;
2042
+ if ( convertLensShiftX || convertLensShiftY )
2043
+ {
2044
+ camera = fbxNode . GetCamera ( ) ;
2045
+ }
2028
2046
2029
2047
// The ParentConstraint's source Rotation Offsets are read in as radians, so make sure they are exported as radians
2030
2048
convertToRadian = uniPropertyName . StartsWith ( "m_RotationOffsets.Array.data" , cc ) ;
@@ -2043,9 +2061,26 @@ public UnityToMayaConvertSceneHelper(string uniPropertyName)
2043
2061
2044
2062
public float Convert ( float value )
2045
2063
{
2064
+ float convertedValue = value ;
2065
+ if ( convertLensShiftX || convertLensShiftY )
2066
+ {
2067
+ convertedValue = Mathf . Clamp ( Mathf . Abs ( value ) , 0f , 1f ) * Mathf . Sign ( value ) ;
2068
+ }
2069
+ if ( camera != null )
2070
+ {
2071
+ if ( convertLensShiftX )
2072
+ {
2073
+ convertedValue *= ( float ) camera . GetApertureWidth ( ) ;
2074
+ }
2075
+ else if ( convertLensShiftY )
2076
+ {
2077
+ convertedValue *= ( float ) camera . GetApertureHeight ( ) ;
2078
+ }
2079
+ }
2080
+
2046
2081
// left handed to right handed conversion
2047
2082
// meters to centimetres conversion
2048
- return unitScaleFactor * value ;
2083
+ return unitScaleFactor * convertedValue ;
2049
2084
}
2050
2085
2051
2086
}
0 commit comments