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 fbxcontrolset.h
13#ifndef _FBXSDK_SCENE_CONSTRAINT_CONTROL_SET_H_
14#define _FBXSDK_SCENE_CONSTRAINT_CONTROL_SET_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/constraint/fbxcharacter.h>
19
20#include <fbxsdk/fbxsdk_nsbegin.h>
21
22class FbxControlSetPlug;
23
24/** \class FbxControlSetLink
25 *
26 * \brief This class represents a link between a given character's FK node and the associated node in the character hierarchy.
27 *
28 */
29class FBXSDK_DLL FbxControlSetLink
30{
31public:
32 //! Default constructor.
33 FbxControlSetLink();
34
35 /** Copy constructor.
36 * \param pControlSetLink Given object.
37 */
38 FbxControlSetLink(const FbxControlSetLink& pControlSetLink);
39
40 /** Assignment operator.
41 * \param pControlSetLink Another FbxControlSetLink object assigned to this one.
42 */
43 FbxControlSetLink& operator=(const FbxControlSetLink& pControlSetLink);
44
45 /** Reset to default values.
46 *
47 * Member mNode is set to \c NULL and member mTemplateName is cleared.
48 */
49 void Reset();
50
51 //! The character's node in a hierarchy linked to this control set link.
52 FbxNode* mNode;
53
54 //! A template name is a naming convention that is used to automatically map
55 //! the nodes of other skeletons that use the same naming convention for automatic characterization.
56 FbxString mTemplateName;
57};
58
59/**
60 * An effector wraps a character node (FbxNode) used to animate its control rig (FbxControlSet) via inverse kinematics.
61 */
62class FBXSDK_DLL FbxEffector
63{
64public:
65 enum ESetId
66 {
67 eDefaultSet,
68 eAux1Set,
69 eAux2Set,
70 eAux3Set,
71 eAux4Set,
72 eAux5Set,
73 eAux6Set,
74 eAux7Set,
75 eAux8Set,
76 eAux9Set,
77 eAux10Set,
78 eAux11Set,
79 eAux12Set,
80 eAux13Set,
81 eAux14Set,
82 eSetIdCount
83 };
84
85 enum ENodeId
86 {
87 eHips,
88 eLeftAnkle,
89 eRightAnkle,
90 eLeftWrist,
91 eRightWrist,
92 eLeftKnee,
93 eRightKnee,
94 eLeftElbow,
95 eRightElbow,
96 eChestOrigin,
97 eChestEnd,
98 eLeftFoot,
99 eRightFoot,
100 eLeftShoulder,
101 eRightShoulder,
102 eHead,
103 eLeftHip,
104 eRightHip,
105 eLeftHand,
106 eRightHand,
107 eLeftHandThumb,
108 eLeftHandIndex,
109 eLeftHandMiddle,
110 eLeftHandRing,
111 eLeftHandPinky,
112 eLeftHandExtraFinger,
113 eRightHandThumb,
114 eRightHandIndex,
115 eRightHandMiddle,
116 eRightHandRing,
117 eRightHandPinky,
118 eRightHandExtraFinger,
119 eLeftFootThumb,
120 eLeftFootIndex,
121 eLeftFootMiddle,
122 eLeftFootRing,
123 eLeftFootPinky,
124 eLeftFootExtraFinger,
125 eRightFootThumb,
126 eRightFootIndex,
127 eRightFootMiddle,
128 eRightFootRing,
129 eRightFootPinky,
130 eRightFootExtraFinger,
131 eNodeIdCount,
132 eNodeIdInvalid=-1
133 };
134
135 //! Default constructor with uninitialized character node.
136 FbxEffector();
137
138 /** Assignment operator.
139 * \param pEffector Another FbxEffector assigned to this one.
140 */
141 FbxEffector& operator=(const FbxEffector& pEffector);
142
143 /** Reset to default values.
144 * - mNode is set to NULL.
145 * - mShow is set to true.
146 */
147 void Reset();
148
149 //! The character's node in a hierarchy linked to this effector.
150 FbxNode* mNode;
151
152 //! \c true if the effector is visible, \c false if hidden
153 bool mShow;
154
155/*****************************************************************************************************************************
156** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
157*****************************************************************************************************************************/
158#ifndef DOXYGEN_SHOULD_SKIP_THIS
159 //These members are for backward compatibility and should not be used.
160 //These properties are now published through class FbxControlSetPlug.
161 bool mTActive;
162 bool mRActive;
163 bool mCandidateTActive;
164 bool mCandidateRActive;
165#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
166};
167
168/** \class FbxControlSet
169 *
170 * This class contains all methods to either set-up an exported control rig or query information on an imported control rig.
171 * A Control rig is a character manipulation tool that lets you change the position and orientation
172 * of a character to create or alter animation.
173 *
174 * This class also contains some methods to manipulate the FbxEffector and FbxControlSetLink.
175 *
176 * The FbxControlSet class contains FK rig (Forward Kinematics) and IK rig (Inverse Kinematics) animation. The FK rig is represented
177 * by a list of nodes while the IK rig is represented by a list of effectors.
178 *
179 * You can access the FK rig with the FbxControlSetLink class, using the functions FbxControlSet::SetControlSetLink() and FbxControlSet::GetControlSetLink().
180 *
181 * You can access the IK rig with the FbxEffector class, using the functions FbxControlSet::SetEffector() and FbxControlSet::GetEffector().
182 *
183 * \see FbxEffector, FbxControlSetLink
184 */
185class FBXSDK_DLL FbxControlSet
186{
187public:
188 /** Reset to default values.
189 * Reset all effector and control set links.
190 */
191 void Reset();
192
193 /** \enum EType Control rig type.
194 * - \e eNone No Control rig.
195 * - \e eFkIk Both an FK rig and IK rig.
196 * - \e eIkOnly Only an IK rig.
197 */
198 enum EType
199 {
200 eNone,
201 eFkIk,
202 eIkOnly
203 };
204
205 /** Set type as given.
206 * \param pType The given type.
207 */
208 void SetType(EType pType);
209
210 /** Get type.
211 * \return The gotten type.
212 */
213 EType GetType() const;
214
215 /** Set use axis flag as given.
216 * \param pUseAxis The given use axis flag.
217 */
218 void SetUseAxis(bool pUseAxis);
219
220 /** Get use axis flag.
221 * \return The gotten use axis flag.
222 */
223 bool GetUseAxis() const;
224
225 /** Set lock transform flag as given.
226 * \param pLockTransform The given lock transform flag.
227 */
228 void SetLockTransform(bool pLockTransform);
229
230 /** Get lock transform flag.
231 * \return The gotten lock transform flag.
232 */
233 bool GetLockTransform()const;
234
235 /** Set lock 3D pick flag as given.
236 * \param pLock3DPick The given lock 3D pick flag.
237 */
238 void SetLock3DPick(bool pLock3DPick);
239
240 /** Get lock 3D pick flag.
241 * \return The gotten lock 3D pick flag.
242 */
243 bool GetLock3DPick() const;
244
245 /** Set a control set link for a character node ID.
246 * \param pCharacterNodeId Character node ID.
247 * \param pControlSetLink Control set link to be associated with the Character node ID.
248 * \return \c true if successful, \c false otherwise.
249 * \remarks You should avoid setting a control set link for
250 * eCharacterLeftFloor, eCharacterRightFloor, eCharacterLeftHandFloor, eCharacterRightHandFloor,
251 * eCharacterProps0, eCharacterProps1, eCharacterProps2, eCharacterProps3 or eCharacterProps4.
252 * None of these nodes are part of a control set.
253 */
254 bool SetControlSetLink(FbxCharacter::ENodeId pCharacterNodeId, const FbxControlSetLink& pControlSetLink);
255
256 /** Get the control set link associated with a character node ID.
257 * \param pCharacterNodeId Requested character node ID.
258 * \param pControlSetLink Optional pointer that returns the control set link if the function succeeds.
259 * \return \c true if successful, \c false otherwise.
260 * \remarks You should avoid getting a control set link for
261 * eCharacterLeftFloor, eCharacterRightFloor, eCharacterLeftHandFloor, eCharacterRightHandFloor,
262 * eCharacterProps0, eCharacterProps1, eCharacterProps2, eCharacterProps3 or eCharacterProps4.
263 * None of these nodes are part of a control set.
264 */
265 bool GetControlSetLink(FbxCharacter::ENodeId pCharacterNodeId, FbxControlSetLink* pControlSetLink = NULL) const;
266
267 /** Set an effector node for an effector node ID.
268 * \param pEffectorNodeId Effector node ID.
269 * \param pEffector Effector to be associated with the effector node ID.
270 * \return \c true if successful, \c false otherwise.
271 */
272 bool SetEffector(FbxEffector::ENodeId pEffectorNodeId, FbxEffector pEffector);
273
274 /** Get the effector associated with an effector node ID.
275 * \param pEffectorNodeId ID of requested effector node.
276 * \param pEffector Optional pointer that returns the effector if the function succeeds.
277 * \return \c true if successful, \c false otherwise.
278 */
279 bool GetEffector(FbxEffector::ENodeId pEffectorNodeId, FbxEffector* pEffector = NULL);
280
281 /** Set an auxiliary effector node for an effector node ID.
282 * \param pEffectorNodeId Effector node ID.
283 * \param pNode Auxiliary effector node to be associated with the effector node ID.
284 * \param pEffectorSetId Effector set ID. Set to FbxEffector::eAux1Set by default.
285 * \return \c true if successful, \c false otherwise.
286 */
287 bool SetEffectorAux(FbxEffector::ENodeId pEffectorNodeId, FbxNode* pNode, FbxEffector::ESetId pEffectorSetId=FbxEffector::eAux1Set);
288
289 /** Get the auxiliary effector associated with an effector node ID.
290 * \param pEffectorNodeId ID of requested auxiliary effector node.
291 * \param pNode Optional pointer that returns the auxiliary effector node if the function succeeds.
292 * \param pEffectorSetId Effector set ID. Set to FbxEffector::eAux1Set by default.
293 * \return \c true if successful, \c false otherwise.
294 */
295 bool GetEffectorAux(FbxEffector::ENodeId pEffectorNodeId, FbxNode** pNode=NULL, FbxEffector::ESetId pEffectorSetId=FbxEffector::eAux1Set) const;
296
297 /** Get the name associated with an effector node ID.
298 * \param pEffectorNodeId Effector node ID.
299 * \return Name associated with the effector node ID.
300 */
301 static char* GetEffectorNodeName(FbxEffector::ENodeId pEffectorNodeId);
302
303 /** Get ID associated with an effector node name.
304 * \param pEffectorNodeName Effector node name.
305 * \return Effector node ID associated with the given effector node name, or FbxEffector::eNodeIdInvalid (-1) if
306 * no effector node with pEffectorNodeName exists.
307 */
308 static FbxEffector::ENodeId GetEffectorNodeId(char* pEffectorNodeName);
309
310/*****************************************************************************************************************************
311** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
312*****************************************************************************************************************************/
313#ifndef DOXYGEN_SHOULD_SKIP_THIS
314 void FromPlug(FbxControlSetPlug *pPlug);
315 void ToPlug(FbxControlSetPlug *pPlug);
316
317private:
318 FbxControlSet();
319 ~FbxControlSet();
320
321 FbxCharacter* mCharacter;
322 EType mType;
323 bool mUseAxis;
324 bool mLockTransform;
325 bool mLock3DPick;
326 FbxControlSetLink mControlSetLink[FbxCharacter::eNodeIdCount]; // Except floor node IDs!
327 FbxEffector mEffector[FbxEffector::eNodeIdCount];
328 FbxNode* mEffectorAux[FbxEffector::eNodeIdCount][FbxEffector::eSetIdCount-1];
329
330 FBXSDK_FRIEND_NEW();
331 friend class FbxCharacter;
332 friend class FbxNode;
333#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
334};
335
336/** Plug class for control set.
337 * \nosubgrouping
338 */
339class FBXSDK_DLL FbxControlSetPlug : public FbxObject
340{
341 FBXSDK_OBJECT_DECLARE(FbxControlSetPlug, FbxObject);
342
343public:
344 //! EType property of control set.
345 FbxPropertyT<FbxControlSet::EType> ControlSetType;
346
347 //! Use axis flag.
348 FbxPropertyT<FbxBool> UseAxis;
349
350 //! Reference character.
351 FbxPropertyT<FbxReference> Character;
352
353protected:
354 virtual void Construct(const FbxObject* pFrom);
355 virtual void ConstructProperties(bool pForceSet);
356 virtual FbxStringList GetTypeFlags() const;
357
358private:
359 FbxArray<FbxProperty> mFKBuf;
360 FbxArray<FbxProperty> mIKBuf;
361
362 friend class FbxScene;
363 friend class FbxControlSet;
364};
365
366inline EFbxType FbxTypeOf(const FbxControlSet::EType&){ return eFbxEnum; }
367
368#include <fbxsdk/fbxsdk_nsend.h>
369
370#endif /* _FBXSDK_SCENE_CONSTRAINT_CONTROL_SET_H_ */
371