1 | /**************************************************************************************** |
2 | |
3 | Copyright (C) 2015 Autodesk, Inc. |
4 | All rights reserved. |
5 | |
6 | Use of this software is subject to the terms of the Autodesk license agreement |
7 | provided at the time of installation or download, or which otherwise accompanies |
8 | this software in either electronic or hard copy form. |
9 | |
10 | ****************************************************************************************/ |
11 | |
12 | //! \file fbxanimevalclassic.h |
13 | #ifndef _FBXSDK_SCENE_ANIMATION_EVALUATOR_CLASSIC_H_ |
14 | #define _FBXSDK_SCENE_ANIMATION_EVALUATOR_CLASSIC_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/fbxobject.h> |
19 | #include <fbxsdk/scene/animation/fbxanimevaluator.h> |
20 | #include <fbxsdk/scene/animation/fbxanimlayer.h> |
21 | |
22 | #include <fbxsdk/fbxsdk_nsbegin.h> |
23 | |
24 | /** An evaluator implementation that behaves like the original FBX SDK (2010 and previous) evaluation system. |
25 | * |
26 | * It works by implementing the abstract class FbxAnimEvaluator, which is used as the main interface for evaluators. |
27 | * \note While this class can be instanced at any time, it is preferable to access the evaluator via the function |
28 | * FbxScene::GetEvaluator(), which will automatically return the default evaluator used in the current FBX SDK. |
29 | * This is very useful because it will allow the user to use the very same evaluator used by the FBX SDK internally. |
30 | * \see FbxAnimEvaluator, FbxScene |
31 | */ |
32 | class FBXSDK_DLL FbxAnimEvalClassic : public FbxAnimEvaluator |
33 | { |
34 | FBXSDK_OBJECT_DECLARE(FbxAnimEvalClassic, FbxAnimEvaluator); |
35 | |
36 | enum EBlendType {eSimple, eRotation, eScaling}; |
37 | |
38 | /** Calculate values of properties LclTranslation, LclRotation, LclScaling of a node at the specified time |
39 | * and update the mLT, mLR, mLT fields of the node's NodeEvalState. |
40 | * \param pResult The NodeEvalState to update. |
41 | * \param pNode The node to evaluate. |
42 | * \param pTime The time used for evaluate. If FBXSDK_TIME_INFINITE is used, this returns the default value, without animation curves evaluation. |
43 | * \param pStack The current animation stack used by the evaluator. |
44 | * \remarks Values of properties LclTranslation, LclRotation, LclScaling will be updated to pResult->mLT, pResult->mLR, pResult->mLS. |
45 | * The translation, rotation and scaling limits are taken into consideration. |
46 | * Only LclTranslation, LclRotation and LclScaling are taken into accounts, no other transform, such as pivot, offset are calculated here. |
47 | */ |
48 | void ComputeTRSLocal(FbxNodeEvalState* pResult, FbxNode* pNode, const FbxTime& pTime, FbxAnimStack* pStack); |
49 | |
50 | /** Calculate global transform of a node at the specified time and update the mGX field of the node's NodeEvalState. |
51 | * \param pResult The NodeEvalState to update. |
52 | * \param pNode The node to evaluate. |
53 | * \param pTime The time used for evaluate. If FBXSDK_TIME_INFINITE is used, this returns the default value, without animation curves evaluation. |
54 | * \param pStack The current animation stack used by the evaluator. |
55 | * \param pPivotSet The pivot set to take into account. |
56 | * \param pApplyTarget Applies the necessary transform to align into the target node |
57 | * \remarks Calculated global transform will be updated to pResult->mGX. |
58 | * ComputeGlobalTransform must be called after the call to ComputeTRSLocal, there is a dependency. |
59 | * All transforms are taken into account, including: |
60 | * Transform = Translation * RotationOffset* RotationPivot* PreRotation * LocalRotation* PostRotation * RotationPivotInverse* ScalingOffset* ScalingPivot* LocalScaling* ScalingPivotInverse |
61 | * Also,the translation, rotation and scaling limits are taken into consideration. |
62 | */ |
63 | void ComputeGlobalTransform(FbxNodeEvalState* pResult, FbxNode* pNode, const FbxTime& pTime, FbxAnimStack* pStack, FbxNode::EPivotSet pPivotSet, bool pApplyTarget); |
64 | |
65 | /** Calculate local transform of a node at the specified time and update the mLX field of the node's NodeEvalState. |
66 | * \param pResult The NodeEvalState to update. |
67 | * \param pNode The node to evaluate. |
68 | * \param pTime The time used for evaluate. If FBXSDK_TIME_INFINITE is used, this returns the default value, without animation curves evaluation. |
69 | * \param pStack The current animation stack used by the evaluator. |
70 | * \param pPivotSet The pivot set to take into account. |
71 | * \param pApplyTarget Applies the necessary transform to align into the target node |
72 | * \remarks Calculated local transform will be updated to pResult->mLX. |
73 | * ComputeLocalTransform must be called after the call to ComputeGlobalTransform, there is a dependency. |
74 | * The local transform matrix is calculated in this way: ParentGlobal.Inverse() * Global, all transforms such as pre/post rotation are taken into consideration. |
75 | * To get values of properties LclTranslation, LclRotaion and LclScaling at the specified time, please use ComputeTRSLocal. |
76 | * Also,the translation, rotation and scaling limits are taken into consideration. |
77 | */ |
78 | void ComputeLocalTransform(FbxNodeEvalState* pResult, FbxNode* pNode, const FbxTime& pTime, FbxAnimStack* pStack, FbxNode::EPivotSet pPivotSet, bool pApplyTarget); |
79 | |
80 | /** Check if the property has corresponding animation curve node on the specified animation layer. |
81 | * \param pProperty The property to check. |
82 | * \param pAnimLayer The animation layer to check on. |
83 | * \return \c true if pProperty has corresponding animation curve node on pAnimLayer, \c false otherwise. |
84 | */ |
85 | bool HasAnimationCurveNode(FbxProperty& pProperty, FbxAnimLayer* pAnimLayer); |
86 | |
87 | /** Calculate values of properties LclTranslation, LclRotation, LclScaling of a node at the specified time on certain animation layer. |
88 | * \param pResult The NodeEvalState to update. |
89 | * \param pNode The node to evaluate. |
90 | * \param pLT To take the calculated value of LclTranslation. |
91 | * \param pLR To take the calculated value of LclRotation. |
92 | * \param pLS To take the calculated value of LclScaling. |
93 | * \param pTime The time used for evaluate. |
94 | * \param pLayer The current animation layer used to do the calculation. |
95 | * \param pBlend if \c false, only animation on current layer will be taken into account, and pResult->mCurveNode will be updated accordingly. |
96 | if \c true, the value on this animation layer will be blended with current value of pLT, pLR and pLS. |
97 | * \remarks The usual usage of this function is to call it on the first animation layer with out blending, then call it repeatedly on other |
98 | * animation layers with blending to get the blended value of pLT, pLR and pLS of all animation layers. |
99 | */ |
100 | void ComputeTRSAnimationLayer(FbxNodeEvalState* pResult, FbxNode* pNode, FbxVector4& pLT, FbxVector4& pLR, FbxVector4& pLS, const FbxTime& pTime, FbxAnimLayer* pLayer, bool pBlend); |
101 | |
102 | /** Blend value of a property on certain animation layer to pResult. |
103 | * \param pResult The blended value of the property. |
104 | * \param pResultSize The elements number of the property value. |
105 | * \param pProperty The property to be blended. |
106 | * \param pEvalState An auxiliary parameter, the NodeEvalState to get rotation order for eRotation type blending. |
107 | * \param pTime The time used for evaluate. |
108 | * \param pLayer The current animation layer used to do the calculation. |
109 | * \param pType There are three blend types, eSimple, eRotation, eScaling |
110 | * \remarks The blended value will be kept in pResult. |
111 | */ |
112 | void BlendPropertyEvalWithLayer(double* pResult, int pResultSize, FbxProperty& pProperty, FbxNodeEvalState* pEvalState, const FbxTime& pTime, FbxAnimLayer* pLayer, EBlendType pType); |
113 | |
114 | /** Blends two arrays of values in a simple weighted linear blending way. |
115 | * \param pResult The first array of values to be blended. |
116 | * \param pResultSize The number of elements of the first value to be blended. |
117 | * \param pApply The second array of values to be blended. |
118 | * \param pApplySize The number of elements of the second value to be blended. |
119 | * \param pWeight The weight used to blend. |
120 | * \param pBlendMode The blend mode to use. |
121 | * \see BlendMode |
122 | * \remarks The blended value will be kept in pResult. |
123 | */ |
124 | void BlendSimple(double* pResult, int pResultSize, double* pApply, int pApplySize, double pWeight, FbxAnimLayer::EBlendMode pBlendMode); |
125 | |
126 | /** Blends two arrays of values representing rotations. |
127 | * \param pResult The first array of values to be blended. |
128 | * \param pResultSize The number of elements of the first value to be blended. |
129 | * \param pApply The second array of values to be blended. |
130 | * \param pApplySize The number of elements of the second value to be blended. |
131 | * \param pWeight The weight used to blend. |
132 | * \param pBlendMode The blend mode to use. |
133 | * \param pRotAccuMode The rotation accumulation mode. |
134 | * \param pRotationOrder The rotation order to be used for blending. |
135 | * \remarks The blended value will be kept in pResult. And this blend should not be used with anything other than rotations. |
136 | * \see BlendMode, RotationAccumulationMode |
137 | */ |
138 | void BlendRotation(double* pResult, int pResultSize, double* pApply, int pApplySize, double pWeight, FbxAnimLayer::EBlendMode pBlendMode, FbxAnimLayer::ERotationAccumulationMode pRotAccuMode, int pRotationOrder); |
139 | |
140 | /** Blends two arrays of values representing scaling transforms. |
141 | * \param pResult The first array of values to be blended. |
142 | * \param pResultSize The number of elements of the first value to be blended. |
143 | * \param pApply The second array of values to be blended. |
144 | * \param pApplySize The number of elements of the second value to be blended. |
145 | * \param pWeight The weight used to blend. |
146 | * \param pBlendMode The blend mode to use. |
147 | * \param pScaleAccuMode The scaling accumulation mode. |
148 | * \remarks The blended value will be kept in pResult.And this blend should not be used with anything other than scaling transform. |
149 | * \see BlendMode, ScaleAccumulationMode. |
150 | */ |
151 | void BlendScaling(double* pResult, int pResultSize, double* pApply, int pApplySize, double pWeight, FbxAnimLayer::EBlendMode pBlendMode, FbxAnimLayer::EScaleAccumulationMode pScaleAccuMode); |
152 | |
153 | /***************************************************************************************************************************** |
154 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
155 | *****************************************************************************************************************************/ |
156 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
157 | protected: |
158 | virtual void Construct(const FbxObject* pFrom); |
159 | virtual void Destruct(bool pRecursive); |
160 | |
161 | virtual void EvaluateNodeTransform(FbxNodeEvalState* pResult, FbxNode* pNode, const FbxTime& pTime, FbxNode::EPivotSet pPivotSet, bool pApplyTarget); |
162 | virtual void EvaluatePropertyValue(FbxPropertyEvalState* pResult, FbxProperty& pProperty, const FbxTime& pTime); |
163 | |
164 | private: |
165 | double* mPropertyValues; |
166 | int mPropertySize; |
167 | |
168 | double* mCurveNodeEvalValues; |
169 | int mCurveNodeEvalSize; |
170 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
171 | }; |
172 | |
173 | #include <fbxsdk/fbxsdk_nsend.h> |
174 | |
175 | #endif /* _FBXSDK_SCENE_ANIMATION_EVALUATOR_CLASSIC_H_ */ |
176 | |