fbxnurbs.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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 fbxnurbs.h
  9. #ifndef _FBXSDK_SCENE_GEOMETRY_NURBS_H_
  10. #define _FBXSDK_SCENE_GEOMETRY_NURBS_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/scene/geometry/fbxgeometry.h>
  13. #include <fbxsdk/fbxsdk_nsbegin.h>
  14. /** A NURBS surface is a type of parametric geometry. A NURBS surface is defined by the
  15. order, form, knot vector and control points in the U and V coordinates.
  16. For more information on the meaning of form, knot vectors and control points,
  17. see the FbxNurbsCurve documentation. The same rules apply for the NURBS curves
  18. and NURBS surfaces, but NURBS surfaces have two dimensions (U and V).
  19. * \nosubgrouping
  20. */
  21. class FBXSDK_DLL FbxNurbs : public FbxGeometry
  22. {
  23. FBXSDK_OBJECT_DECLARE(FbxNurbs, FbxGeometry);
  24. public:
  25. //! Returns the FbxNodeAttribute::EType::eNurbs node attribute type.
  26. virtual FbxNodeAttribute::EType GetAttributeType() const;
  27. //! Resets the NURBS surface its default values.
  28. void Reset();
  29. /**
  30. * \name NURBS surface properties
  31. */
  32. //@{
  33. /** Sets the surface mode.
  34. * \param pMode Surface mode identifier (see class FbxGeometry)
  35. */
  36. void SetSurfaceMode(FbxGeometry::ESurfaceMode pMode);
  37. /** Returns the surface mode.
  38. * \return The surface mode identifier that is currently set.
  39. */
  40. inline ESurfaceMode GetSurfaceMode() const {return mSurfaceMode;}
  41. /** NURBS types.
  42. */
  43. enum EType
  44. {
  45. ePeriodic, //!< Periodic.
  46. eClosed, //!< Closed.
  47. eOpen //!< Open.
  48. };
  49. /** Allocates memory space for an array of control points as well as knot
  50. * and multiplicity vectors.
  51. * \param pUCount Number of U-dimension control points.
  52. * \param pUType U-dimension NURBS type.
  53. * \param pVCount Number of V-dimension control points.
  54. * \param pVType V-dimension NURBS type.
  55. * \remarks Always call this function after FbxNurbs::SetOrder().
  56. */
  57. void InitControlPoints(int pUCount, EType pUType, int pVCount, EType pVType);
  58. /** Returns the number of U-dimension control points.
  59. * \return Number of U-dimension control points.
  60. */
  61. inline int GetUCount() const {return mUCount;}
  62. /** Returns the number of V-dimension control points.
  63. * \return Number of V-dimension control points.
  64. */
  65. inline int GetVCount() const {return mVCount;}
  66. /** Returns the U-dimension NURBS type.
  67. * \return NURBS type identifier.
  68. */
  69. inline EType GetNurbsUType() const {return mUType;}
  70. /** Returns the V-dimension NURBS type.
  71. * \return NURBS type identifier.
  72. */
  73. inline EType GetNurbsVType() const {return mVType;}
  74. /** Returns the number of elements in the U-dimension knot vector. See FbxNurbsCurve for more information.
  75. * \return The number of elements in the U-dimension knot vector.
  76. */
  77. int GetUKnotCount() const;
  78. /** Returns the U-dimension knot vector.
  79. * \return Pointer to the U-dimension knot vector.
  80. */
  81. double* GetUKnotVector() const;
  82. /** Returns the number of elements in the V-dimension knot vector. See FbxNurbsCurve for more information.
  83. * \return The number of elements in the V-dimension knot vector.
  84. */
  85. int GetVKnotCount() const;
  86. /** Returns the V-dimension knot vector.
  87. * \return Pointer to the V-dimension knot vector.
  88. */
  89. double* GetVKnotVector() const;
  90. /** Returns multiplicity of U-dimension control points.
  91. * \return Pointer to the array of multiplicity values.
  92. * \remarks The length of this vector is equal to the U count.
  93. * Its elements are set to 1 by default.
  94. */
  95. int* GetUMultiplicityVector() const;
  96. /** Returns multiplicity of V-dimension control points.
  97. * \return Pointer to the array of multiplicity values.
  98. * \remarks The length of this vector is equal to the V count.
  99. * Its elements are set to 1 by default.
  100. */
  101. int* GetVMultiplicityVector() const;
  102. /** Sets the order of the NURBS surface.
  103. * \param pUOrder NURBS order in U dimension.
  104. * \param pVOrder NURBS order in V dimension.
  105. */
  106. void SetOrder(FbxUInt pUOrder, FbxUInt pVOrder);
  107. /** Returns the NURBS order in U dimension.
  108. * \return NURBS order in U dimension.
  109. */
  110. inline int GetUOrder() const {return mUOrder;}
  111. /** Returns the NURBS order in V dimension.
  112. * \return NURBS order in V dimension.
  113. */
  114. inline int GetVOrder() const {return mVOrder;}
  115. /** Sets the NURBS step.
  116. * The step value is the number of divisions between adjacent control points.
  117. * \param pUStep Steps in U dimension.
  118. * \param pVStep Steps in V dimension.
  119. */
  120. void SetStep(int pUStep, int pVStep);
  121. /** Returns the number of divisions between adjacent control points in U dimension.
  122. * \return Steps in U dimension.
  123. */
  124. inline int GetUStep() const {return mUStep;}
  125. /** Returns the number of divisions between adjacent control points in V dimension.
  126. * \return Steps in V dimension.
  127. */
  128. inline int GetVStep() const {return mVStep;}
  129. /** Calculates the number of surface spans in the U dimension.
  130. * See FbxNurbsCurve::GetSpanCount() for more information.
  131. * \return The number of spans in the U dimension if the surface has been initialized.
  132. * If the spans have not been initialized, returns -1.
  133. */
  134. int GetUSpanCount() const;
  135. /** Calculates the number of surface spans in the V dimension.
  136. * See FbxNurbsCurve::GetSpanCount() for more information.
  137. * \return The number of spans in the V dimension if the surface has been initialized.
  138. * If the spans have not been initialized, returns -1.
  139. */
  140. int GetVSpanCount() const;
  141. //@}
  142. /**
  143. * \name NURBS export flags
  144. */
  145. //@{
  146. /** Sets the flag that induces UV flipping at export.
  147. * \param pFlag If \c true, UV flipping occurs.
  148. */
  149. void SetApplyFlipUV(bool pFlag);
  150. /** Returns the flag that induces UV flipping at export.
  151. * \return The current state of the UV flip flag.
  152. */
  153. bool GetApplyFlipUV() const;
  154. /** Sets the flag that induces link flipping at export.
  155. * \param pFlag If \c true, the links control points indices are flipped.
  156. */
  157. void SetApplyFlipLinks(bool pFlag);
  158. /** Returns the flag that induces link flipping at export.
  159. * \return The current state of the link flip flag.
  160. */
  161. bool GetApplyFlipLinks() const;
  162. /** Returns flip flags state.
  163. * \return \c True if we need to flip either the UV or the links.
  164. */
  165. bool GetApplyFlip() const { return GetApplyFlipUV() || GetApplyFlipLinks(); }
  166. //@}
  167. /*****************************************************************************************************************************
  168. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  169. *****************************************************************************************************************************/
  170. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  171. // Error identifiers, these are only used internally.
  172. enum EErrorCode
  173. {
  174. eNurbsTypeUnknown,
  175. eWrongNumberOfControlPoint,
  176. eWeightTooSmall,
  177. eUMultiplicityVectorError,
  178. eVMultiplicityVectorError,
  179. eUKnotVectorError,
  180. eVKnotVectorError,
  181. eErrorCount
  182. };
  183. virtual FbxObject& Copy(const FbxObject& pObject);
  184. virtual void SetControlPointAt(const FbxVector4 &pCtrlPoint , int pIndex) { ParentClass::SetControlPointAt(pCtrlPoint, pIndex); }
  185. virtual void InitControlPoints(int pCount) { ParentClass::InitControlPoints(pCount); }
  186. protected:
  187. virtual void Construct(const FbxObject* pFrom);
  188. virtual void Destruct(bool pRecursive);
  189. FbxUInt mUOrder, mVOrder;
  190. int mUCount, mVCount;
  191. int mUStep, mVStep;
  192. EType mUType, mVType;
  193. double* mUKnotVector;
  194. double* mVKnotVector;
  195. int* mUMultiplicityVector;
  196. int* mVMultiplicityVector;
  197. ESurfaceMode mSurfaceMode;
  198. // Export flags.
  199. bool mApplyFlipUV;
  200. bool mApplyFlipLinks;
  201. friend class FbxGeometryConverter;
  202. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  203. };
  204. #include <fbxsdk/fbxsdk_nsend.h>
  205. #endif /* _FBXSDK_SCENE_GEOMETRY_NURBS_H_ */