fbxcontrolset.h 13 KB

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