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 fbxskin.h
13#ifndef _FBXSDK_SCENE_GEOMETRY_SKIN_H_
14#define _FBXSDK_SCENE_GEOMETRY_SKIN_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/geometry/fbxdeformer.h>
19
20#include <fbxsdk/fbxsdk_nsbegin.h>
21
22class FbxCluster;
23class FbxGeometry;
24
25/** Skin deformer class.
26 *
27 * A skin deformer contains clusters (FbxCluster). Each cluster acts on a subset of the geometry's
28 * control points, with different weights. For example, a mesh of humanoid shape
29 * can have a skin attached, that describes the way the humanoid mesh is deformed
30 * by bones. When the bones are animated, the clusters act on the geometry to
31 * animate it too.
32 *
33 * The corresponding deformer types are FbxDeformer::eSkin.
34 * \nosubgrouping
35 */
36
37class FBXSDK_DLL FbxSkin : public FbxDeformer
38{
39 FBXSDK_OBJECT_DECLARE(FbxSkin, FbxDeformer);
40
41public:
42 /** Set deformation accuracy.
43 * \remarks Use the Accuracy option to set the accuracy of skin deformations.
44 * 100% is full accuracy and 1% is a rough estimation of the envelope deformation.
45 * \param pDeformAccuracy value for deformation accuracy.
46 */
47 void SetDeformAccuracy(double pDeformAccuracy);
48
49 /** Get deformation accuracy.
50 * \return deformation accuracy value.
51 */
52 double GetDeformAccuracy() const;
53
54 /** Set the geometry affected by this skin deformer.
55 * \param pGeometry Pointer to the geometry object to set.
56 * \return \c true on success, \c false otherwise.
57 */
58 bool SetGeometry(FbxGeometry* pGeometry);
59
60 /** Get the geometry affected by this skin deformer.
61 * \return a pointer to the geometry if set or NULL.
62 */
63 FbxGeometry* GetGeometry();
64
65 /** Add a cluster.
66 * \param pCluster Pointer to the cluster object to add.
67 * \return \c true on success, \c false otherwise.
68 */
69 bool AddCluster(FbxCluster* pCluster);
70
71 /** Remove cluster at given index.
72 * \param pCluster Pointer to the cluster to remove from this skin deformer.
73 * \return Pointer to cluster or \c NULL if pCluster is not owned by this skin deformer.
74 */
75 FbxCluster* RemoveCluster(FbxCluster* pCluster);
76
77 /** Get the number of clusters.
78 * \return Number of clusters that have been added to this object.
79 */
80 int GetClusterCount() const;
81
82 /** Get cluster at given index.
83 * \param pIndex Index of cluster.
84 * \return Pointer to cluster or \c NULL if index is out of range.
85 */
86 FbxCluster* GetCluster(int pIndex);
87
88 /** Get cluster at given index.
89 * \param pIndex Index of cluster.
90 * \return Pointer to cluster or \c NULL if index is out of range.
91 */
92 const FbxCluster* GetCluster(int pIndex) const;
93
94 /** Get the type of the deformer.
95 * \return Deformer type identifier.
96 */
97 EDeformerType GetDeformerType() const {return eSkin; };
98
99 /** \enum EType Skinning type.
100 * The skinning type decides which method will be used to do the skinning.
101 * - \e eRigid Type eRigid means rigid skinning, which means only one joint can influence each control point.
102 * - \e eLinear Type eLinear means the classic linear smooth skinning.
103 * - \e eDualQuaternion Type eDualQuaternion means the dual quaternion smooth skinning.
104 * - \e eBlend Type eBlend means to blend classic linear and dual quaternion smooth skinning according to blend weights.
105 */
106 enum EType
107 {
108 eRigid,
109 eLinear,
110 eDualQuaternion,
111 eBlend
112 };
113
114 /** Set the skinning type.
115 * \param pType The skinning type.
116 */
117 void SetSkinningType(EType pType);
118
119 /** Get the skinning type.
120 * \return The skinning type.
121 */
122 EType GetSkinningType() const;
123
124 /**
125 * \name Control Points
126 * A skin has an array of indices to control points and associated blend weights.
127 * The indices refer to the control points in the instance of class FbxGeometry.
128 * The blend weights are the influence of the different skinning type over the
129 * deformation effect of the indexed control points.
130 */
131 //@{
132
133 /** Add an element in both arrays of control point indices and blendWeights.
134 * \param pIndex The index of the control point.
135 * \param pBlendWeight The blend weight for this control point. The value should between 0 and 1.
136 * Any value that is less than 0 will be set to 0, any value that is greater than 1 will be set to 1.
137 * 0 means completely linear skinning, 1 means completely dual quaternion skinning,
138 * a value between 0 and 1 means the weighted blending of the above two skinning methods.
139 */
140 void AddControlPointIndex(int pIndex, double pBlendWeight = 0);
141
142 /** Get the length of the arrays of control point indices and blend weights.
143 * \return Length of the arrays of control point indices and blend weights.
144 * Returns 0 if no control point indices have been added or the arrays have been reset.
145 */
146 int GetControlPointIndicesCount() const;
147
148 /** Get the array of control point indices.
149 * \return Pointer to the array of control point indices.
150 * \c NULL if no control point indices have been added or the array has been reset.
151 */
152 int* GetControlPointIndices() const;
153
154 /** Get the array of control point blend weights.
155 * \return Pointer to the array of control point blend weights.
156 * \c NULL if no control point indices have been added or the array has been reset.
157 */
158 double* GetControlPointBlendWeights() const;
159
160 /** Set the array size for the three arrays: the array of control point indices, the array of weights
161 * and the array of blend weights.
162 * \param pCount The new count.
163 */
164 void SetControlPointIWCount(int pCount);
165
166 //@}
167
168/*****************************************************************************************************************************
169** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
170*****************************************************************************************************************************/
171#ifndef DOXYGEN_SHOULD_SKIP_THIS
172 virtual void Compact();
173 virtual FbxObject& Copy(const FbxObject& pObject);
174 virtual FbxObject* Clone(FbxObject::ECloneType pCloneType=eDeepClone, FbxObject* pContainer=NULL, void* pSet = NULL) const;
175
176protected:
177 virtual void Construct(const FbxObject* pFrom);
178 virtual FbxStringList GetTypeFlags() const;
179
180 // Skin deformer
181 double mDeformAccuracy;
182 EType mSkinningType;
183
184 //Control points
185 FbxArray<int> mControlPointIndices;
186 FbxArray<double> mControlPointBlendWeights;
187#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
188};
189
190#include <fbxsdk/fbxsdk_nsend.h>
191
192#endif /* _FBXSDK_SCENE_GEOMETRY_SKIN_H_ */
193