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 fbxskeleton.h |
13 | #ifndef _FBXSDK_SCENE_GEOMETRY_SKELETON_H_ |
14 | #define _FBXSDK_SCENE_GEOMETRY_SKELETON_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/scene/geometry/fbxnodeattribute.h> |
19 | |
20 | #include <fbxsdk/fbxsdk_nsbegin.h> |
21 | |
22 | /** This class specializes a node attribute to represent the elements forming "bone" |
23 | * chains. The FbxSkeleton name of the class comes from the analogy with the human body |
24 | * skeletal structure. In fact, an object of this type is nothing more than a transform |
25 | * node with special properties that are useful for its graphical representation and during |
26 | * IK/FK and skin deformation computations. Typically, a scene will contain chains of FbxSkeleton |
27 | * node attributes that, together, form a skeleton segment. For instance, the representation of the |
28 | * leg of a character can be achieved using one parent node with the attribute eRoot, followed by |
29 | * one child (femur) of type eLimb, this child having a child also (tibia) of the same type. Finally, |
30 | * terminated with a last node attribute of type eEffector (ankle). |
31 | * |
32 | * \nosubgrouping |
33 | */ |
34 | class FBXSDK_DLL FbxSkeleton : public FbxNodeAttribute |
35 | { |
36 | FBXSDK_OBJECT_DECLARE(FbxSkeleton,FbxNodeAttribute); |
37 | |
38 | public: |
39 | //! Return the type of node attribute (i.e: FbxNodeAttribute::EType::eSkeleton). |
40 | virtual FbxNodeAttribute::EType GetAttributeType() const; |
41 | |
42 | //! Reset the skeleton to default values and type to \c eRoot. |
43 | void Reset(); |
44 | |
45 | /** |
46 | * \name Skeleton Properties |
47 | */ |
48 | //@{ |
49 | |
50 | /** \enum EType Skeleton types. |
51 | * \remarks \e eEffector is synonymous to \e eRoot. |
52 | * \remarks The \e eLimbNode type is a bone defined uniquely by a transform and a size value while |
53 | * \remarks the \e eLimb type is a bone defined by a transform and a length. |
54 | */ |
55 | enum EType |
56 | { |
57 | eRoot, /*!< First element of a chain. */ |
58 | eLimb, /*!< Chain element. */ |
59 | eLimbNode, /*!< Chain element. */ |
60 | eEffector /*!< Last element of a chain. */ |
61 | }; |
62 | |
63 | /** Set the skeleton type. |
64 | * \param pSkeletonType Skeleton type identifier. |
65 | */ |
66 | void SetSkeletonType(EType pSkeletonType); |
67 | |
68 | /** Get the skeleton type. |
69 | * \return Skeleton type identifier. |
70 | */ |
71 | EType GetSkeletonType() const; |
72 | |
73 | /** Get a flag to know if the skeleton type was set. |
74 | * \return \c true if a call to SetSkeletonType() has been made. |
75 | * \remarks When the attribute is not set, the application can choose to ignore the attribute or use the default value. |
76 | * \remarks The flag is set back to \c false when Reset() is called. |
77 | */ |
78 | bool GetSkeletonTypeIsSet() const; |
79 | |
80 | /** Get the default value for the skeleton type. |
81 | * \return \c eRoot |
82 | */ |
83 | EType GetSkeletonTypeDefaultValue() const; |
84 | |
85 | /** Get the default value for the limb length. |
86 | * \return 1.0 |
87 | */ |
88 | double GetLimbLengthDefaultValue() const; |
89 | |
90 | /** Get the default value for the limb node size. |
91 | * \return 100.0 |
92 | */ |
93 | double GetLimbNodeSizeDefaultValue() const; |
94 | |
95 | /** Set limb or limb node color. |
96 | * \param pColor RGB values for the limb color. |
97 | * \return \c true if skeleton type is \c eLimb or \c eLimbNode, \c false otherwise. |
98 | * \remarks Limb or limb node color is only set if skeleton type is \c eLimb or \c eLimbNode. |
99 | */ |
100 | bool SetLimbNodeColor(const FbxColor& pColor); |
101 | |
102 | /** Get limb or limb node color. |
103 | * \return Currently set limb color. |
104 | * \remarks Limb or limb node color is only valid if skeleton type is \c eLimb or \c eLimbNode. |
105 | */ |
106 | FbxColor GetLimbNodeColor() const; |
107 | |
108 | /** Get a flag to know if the limb node color was set. |
109 | * \return \c true if a call to SetLimbNodeColor() has been made. |
110 | * \remarks When the attribute is not set, the application can choose to ignore the attribute or use the default value. |
111 | * \remarks The flag is set back to \c false when Reset() is called. |
112 | */ |
113 | bool GetLimbNodeColorIsSet() const; |
114 | |
115 | /** Get the default value for the limb node color. |
116 | * \return R=0.8, G=0.8, B=0.8 |
117 | */ |
118 | FbxColor GetLimbNodeColorDefaultValue() const; |
119 | |
120 | /** To see if this skeleton is Root. |
121 | * \return \c true if this is root of the skeleton, \c false otherwise. |
122 | * \remarks if a skeleton node do not have a parent or its parent is not a skeleton node itself, then this |
123 | * skeleton is root in the hierarchy. |
124 | */ |
125 | bool IsSkeletonRoot() const; |
126 | |
127 | //@} |
128 | |
129 | |
130 | /** |
131 | * \name Property Names |
132 | */ |
133 | static const char* sSize; |
134 | static const char* sLimbLength; |
135 | |
136 | /** |
137 | * \name Property Default Values |
138 | */ |
139 | //@{ |
140 | static const FbxDouble sDefaultSize; |
141 | static const FbxDouble sDefaultLimbLength; |
142 | |
143 | |
144 | ////////////////////////////////////////////////////////////////////////// |
145 | // |
146 | // Properties |
147 | // |
148 | ////////////////////////////////////////////////////////////////////////// |
149 | |
150 | /** This property handles the limb node size. |
151 | * |
152 | * To access this property do: Size.Get(). |
153 | * To set this property do: Size.Set(FbxDouble). |
154 | * |
155 | * Default value is 100.0 |
156 | */ |
157 | FbxPropertyT<FbxDouble> Size; |
158 | |
159 | /** This property handles the skeleton limb length. |
160 | * |
161 | * To access this property do: LimbLength.Get(). |
162 | * To set this property do: LimbLength.Set(FbxDouble). |
163 | * |
164 | * FbxSkeleton is a node attribute and it will be attached to a FbxNode which represents the transform. |
165 | * Given a chain of skeleton nodes the parent and child skeletons will be attached to a parent node and a child node. |
166 | * The orientation of the limb is computed from the vector between the parent and child position (from parent to child). |
167 | * The LimbLength represents the proportion |
168 | * of the parent node's position to the child node's position which is used to compute the actual limb length. |
169 | * The default value of 1.0 means the LimbLength is equal to the length between the parent and child node's position. |
170 | * So if the value is 0.5, it means the LimbLength will be half of the length between the parent and child node's position. |
171 | */ |
172 | FbxPropertyT<FbxDouble> LimbLength; |
173 | |
174 | /***************************************************************************************************************************** |
175 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
176 | *****************************************************************************************************************************/ |
177 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
178 | virtual FbxObject& Copy(const FbxObject& pObject); |
179 | |
180 | protected: |
181 | virtual void Construct(const FbxObject* pFrom); |
182 | virtual void ConstructProperties(bool pForceSet); |
183 | |
184 | void Reset( bool pResetProperties ); |
185 | |
186 | virtual const char* GetTypeName() const; |
187 | virtual FbxStringList GetTypeFlags() const; |
188 | |
189 | EType mSkeletonType; |
190 | |
191 | bool mLimbLengthIsSet; |
192 | bool mLimbNodeSizeIsSet; |
193 | bool mLimbNodeColorIsSet; |
194 | bool mSkeletonTypeIsSet; |
195 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
196 | }; |
197 | |
198 | #include <fbxsdk/fbxsdk_nsend.h> |
199 | |
200 | #endif /* _FBXSDK_SCENE_GEOMETRY_SKELETON_H_ */ |
201 | |