fbxskin.h 7.7 KB

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