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 fbxgeometry.h
13#ifndef _FBXSDK_SCENE_GEOMETRY_H_
14#define _FBXSDK_SCENE_GEOMETRY_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/geometry/fbxgeometrybase.h>
19#include <fbxsdk/scene/geometry/fbxdeformer.h>
20#include <fbxsdk/scene/geometry/fbxshape.h>
21#include <fbxsdk/scene/geometry/fbxblendshape.h>
22#include <fbxsdk/scene/geometry/fbxblendshapechannel.h>
23
24#include <fbxsdk/fbxsdk_nsbegin.h>
25
26class FbxStatus;
27class FbxGeometryWeightedMap;
28
29/** The base class of geometric objects that support control point deformations (e.g. FbxMesh, FbxNurbs,
30* and FbxPatch). The FbxGeometry provides support for the following kinds of deformations.
31*
32* \li Skin deformation deformers
33* \li Vertex cache deformers
34* \li Geometry weighted maps
35* \li Shapes
36*
37* Most of the methods of FbxGeometry are wrappers to simplify the access/manipulation of the connections
38* to the deformers. For example, calling the GetDeformerCount() method is the same
39* thing as calling:
40*
41* \code
42* geometry.GetSrcObjectCount(FbxDeformer::ClassId)
43* \endcode
44*/
45class FBXSDK_DLL FbxGeometry : public FbxGeometryBase
46{
47 FBXSDK_OBJECT_DECLARE(FbxGeometry,FbxGeometryBase);
48
49public:
50 /** Returns the node attribute type.
51 * This method is derived in the more high level classes (FbxMesh, FbxNurbs, etc...) and returns the
52 * actual type of the geometry object.
53 *
54 * \return \e eUnknown
55 */
56 virtual FbxNodeAttribute::EType GetAttributeType() const;
57
58 /**
59 * \name Deformer Management
60 */
61 //@{
62
63 /** Adds a deformer to this geometry (as mentioned in the description of this class, adding a deformer is a synonym
64 * for "connect a deformer").
65 * \param pDeformer Pointer to the deformer to be added.
66 * \return Index of the added deformer.
67 */
68 int AddDeformer(FbxDeformer* pDeformer);
69
70 /** Remove a deformer.
71 * \param pIndex Index of deformer to remove.
72 * \param pStatus The FbxStatus object to hold error codes.
73 * \return Pointer to the removed deformer (or \c NULL if pIndex is out of range).
74 */
75 FbxDeformer* RemoveDeformer(int pIndex, FbxStatus* pStatus = NULL);
76
77 /** Returns the number of deformers.
78 * \return The number of deformers that are connected to this geometry.
79 */
80 int GetDeformerCount() const;
81
82 /** Returns the deformer at the specified index.
83 * \param pIndex The specified deformer index.
84 * \param pStatus The FbxStatus object to hold error codes.
85 * \return Pointer to the deformer (or \c NULL if pIndex is out of range).
86 */
87 FbxDeformer* GetDeformer(int pIndex, FbxStatus* pStatus = NULL) const;
88
89 /** Returns the number of deformers of a specified type.
90 * \param pType The specified deformer type.
91 * \return The number of deformers of the specified type.
92 */
93 int GetDeformerCount(FbxDeformer::EDeformerType pType) const;
94
95 /** Returns the deformer of a specified type at the specified index.
96 * \param pIndex The specified deformer index.
97 * \param pType The specified deformer type.
98 * \param pStatus The FbxStatus object to hold error codes.
99 * \return Pointer to the deformer (or \c NULL if pIndex is out of range).
100 */
101 FbxDeformer* GetDeformer(int pIndex, FbxDeformer::EDeformerType pType, FbxStatus* pStatus = NULL) const;
102
103 //@}
104
105 /**
106 * \name Geometry Weighted Maps Management
107 */
108 //@{
109
110 /** Returns the source geometry weighted map that is connected to this geometry.
111 * \return Pointer to the source geometry weighted map that is connected to this geometry if any.
112 */
113 FbxGeometryWeightedMap* GetSourceGeometryWeightedMap();
114
115 /** Returns the number of destination geometry weighted map(s) that are connected to this geometry.
116 * \return The number of destination geometry weighted map(s) that are connected to this geometry.
117 */
118 int GetDestinationGeometryWeightedMapCount() const;
119
120 /** Returns the destination geometry weighted map at a specified index.
121 * \param pIndex The specified index.
122 * \return Pointer to the destination geometry weighted map at the specified index (if any).
123 */
124 FbxGeometryWeightedMap* GetDestinationGeometryWeightedMap(int pIndex);
125
126 //@}
127
128 /**
129 * \name Shape Management
130 */
131 //@{
132
133 /** Add a shape to the specified blend shape deformer and blend shape channel of this geometry.
134 * \param pBlendShapeIndex The blend shape deformer index.
135 * \param pBlendShapeChannelIndex The blend shape channel index.
136 * \param pShape Pointer to the shape object to be added.
137 * \param pPercent The full deform percentage of this shape.
138 * \param pStatus The FbxStatus object to hold error codes.
139 * \return \c true if success, \c false otherwise.
140 */
141 bool AddShape(int pBlendShapeIndex, int pBlendShapeChannelIndex, FbxShape* pShape, double pPercent = 100, FbxStatus* pStatus = NULL);
142
143 /** Removes all the shapes without destroying them.
144 * If shapes aren't explicitly destroyed before calling this function, they will be
145 * destroyed along with the SDK manager that created them.
146 */
147 void ClearShape();
148
149 /** Returns the number of shapes.
150 * \return The number of shapes that have been added to this geometry.
151 */
152 int GetShapeCount() const;
153
154 /** Returns the number of shapes.
155 * \param pBlendShapeIndex The blend shape deformer index.
156 * \param pBlendShapeChannelIndex The blend shape channel index.
157 * \param pStatus The FbxStatus object to hold error codes.
158 * \return The number of shapes that have been added to this blend shape channel of this blend shape deformer.
159 */
160 int GetShapeCount(int pBlendShapeIndex, int pBlendShapeChannelIndex, FbxStatus* pStatus = NULL) const;
161
162 /** Returns the shape found at the specified index on a blend shape channel of a blend shape deformer.
163 * \param pBlendShapeIndex The blend shape deformer index.
164 * \param pBlendShapeChannelIndex The blend shape channel index.
165 * \param pShapeIndex The specified shape index.
166 * \param pStatus The FbxStatus object to hold error codes.
167 * \return Pointer to the shape (or \c NULL if pIndex is out of range).
168 */
169 FbxShape* GetShape(int pBlendShapeIndex, int pBlendShapeChannelIndex, int pShapeIndex, FbxStatus* pStatus = NULL);
170
171 /** Returns the shape found at the specified index on a blend shape channel of a blend shape deformer.
172 * \param pBlendShapeIndex The blend shape deformer index.
173 * \param pBlendShapeChannelIndex The blend shape channel index.
174 * \param pShapeIndex The specified shape index.
175 * \param pStatus The FbxStatus object to hold error codes.
176 * \return Pointer to the shape (or \c NULL if pIndex is out of range).
177 */
178 const FbxShape* GetShape(int pBlendShapeIndex, int pBlendShapeChannelIndex, int pShapeIndex, FbxStatus* pStatus = NULL) const;
179
180 /** Get the shape animation curve.
181 * The shape channel is an animatable property with a value range from 0 to 100 (with 100 being full shape deformation).
182 * The default value is 0.
183 * \param pBlendShapeIndex The blend shape deformer index.
184 * \param pBlendShapeChannelIndex The blend shape channel index.
185 * \param pLayer The animation layer from which we want to get the requested animation curve.
186 * \param pCreateAsNeeded If \c true, creates the animation curve if it is not already present.
187 * \param pStatus The FbxStatus object to hold error codes.
188 * \return Animation curve (or NULL if an error occurred).
189 * \remarks If pLayer is left at NULL, the method will use the first layer of the Animation stack.
190 */
191 FbxAnimCurve* GetShapeChannel(int pBlendShapeIndex, int pBlendShapeChannelIndex, FbxAnimLayer* pLayer, bool pCreateAsNeeded = false, FbxStatus* pStatus = NULL);
192 //@}
193
194 /** NURBS and Patches surface modes.
195 * This information is never directly used inside the FBX SDK. Applications can use these values if they wish to
196 * carry the "rendering" details of the NURBS and Patches. The FBX SDK guarantee that the value (member of the FbxNurbs,
197 * FbxNurbsSurface and FbxPatch classes) is stored to FBX files and retrieved from them.
198 * \remarks The enum has been defined in this class to avoid symbols duplication.
199 */
200 enum ESurfaceMode
201 {
202 eRaw, //! Raw.
203 eLowNoNormals, //! Low and no normals.
204 eLow, //! Low.
205 eHighNoNormals, //! High and no normals.
206 eHigh //! High.
207 };
208
209 /**
210 * \name Pivot Management
211 * The geometry pivot is used to specify additional translation, rotation,
212 * and scaling information applied to all control points when the model is
213 * exported.
214 */
215 //@{
216
217 /** Returns the pivot matrix.
218 * \param pXMatrix Placeholder for the returned matrix.
219 * \return Reference to the passed argument.
220 */
221 FbxAMatrix& GetPivot(FbxAMatrix& pXMatrix) const;
222
223 /** Sets the pivot matrix.
224 * \param pXMatrix The transformation matrix that is assigned to the pivot matrix.
225 */
226 void SetPivot(FbxAMatrix& pXMatrix);
227
228 /** Applies the pivot matrix to all vertices/normals of the geometry.
229 */
230 void ApplyPivot();
231
232 //@}
233
234 /**
235 * \name Default Animation Values
236 * These functions provides direct access to default animation values that are specific to a geometry.
237 * These functions only work if the geometry has been associated with a node.
238 */
239 //@{
240
241 /** Sets the default deformation for a specified shape.
242 * The default shape property has a value range from 0 to 100 (with 100 being full shape deformation).
243 * The default value is 0.
244 * \param pBlendShapeIndex The blend shape deformer index.
245 * \param pBlendShapeChannelIndex The blend shape channel index.
246 * \param pPercent Deformation percentage (on a scale ranging from 0 to 100).
247 * \remarks This function has no effect if pIndex is out of range.
248 */
249 void SetDefaultShape(int pBlendShapeIndex, int pBlendShapeChannelIndex, double pPercent);
250
251 /** Sets the default deformation for a specified channel.
252 * The default shape property has a value range from 0 to 100 (with 100 being full shape deformation).
253 * The default value is 0.
254 * \param pBlendShapeChannel The blend shape channel.
255 * \param pPercent Deformation percentage (on a scale ranging from 0 to 100).
256 * \remarks This function has no effect if pShapeName is invalid.
257 */
258 void SetDefaultShape(FbxBlendShapeChannel* pBlendShapeChannel, double pPercent);
259
260 /** Returns the default deformation value for the specified shape.
261 * The default shape property has a value range from 0 to 100 (with 100 being full shape deformation).
262 * The default value is 0.
263 * \param pBlendShapeIndex The blend shape deformer index.
264 * \param pBlendShapeChannelIndex The blend shape channel index.
265 * \return The deformation value for the specified shape, or 0 if pIndex is out of range.
266 */
267 double GetDefaultShape(int pBlendShapeIndex, int pBlendShapeChannelIndex) const;
268
269 /** Returns the default deformation value for the specified channel.
270 * The default shape property has a value range from 0 to 100 (with 100 being full shape deformation).
271 * The default value is 0.
272 * \param pBlendShapeChannel The blend shape channel.
273 * \return The deformation value for the specified shape, or 0 if pShapeName is invalid.
274 */
275 double GetDefaultShape(FbxBlendShapeChannel* pBlendShapeChannel) const;
276
277 //@}
278
279/*****************************************************************************************************************************
280** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
281*****************************************************************************************************************************/
282#ifndef DOXYGEN_SHOULD_SKIP_THIS
283 virtual FbxObject& Copy(const FbxObject& pObject);
284 virtual FbxObject* Clone(FbxObject::ECloneType pCloneType=eDeepClone, FbxObject* pContainer=NULL, void* pSet = NULL) const;
285
286 void CleanShapeChannels(FbxAnimLayer* pAnimLayer);
287 void CleanShapeChannel(FbxAnimLayer* pAnimLayer, int pShapeIndex);
288 void CreateShapeChannelProperties(FbxString& pShapeName);
289 void ConvertShapeNamesToV5Format(FbxString pTakeNodeName);
290 void ConvertShapeNamesToV5Format(FbxString pTakeNodeName, int pShapeIndex);
291 void RevertShapeNamesToV6Format(FbxString pTakeNodeName);
292 void RevertShapeNamesToV6Format(FbxString pTakeNodeName, int pShapeIndex);
293 void ClearTemporaryShapeNames();
294
295protected:
296 virtual void Construct(const FbxObject* pFrom);
297 virtual void Destruct(bool pRecursive);
298 virtual void SetDocument(FbxDocument* pDocument);
299
300 FbxString CreateShapeChannelName(int pShapeIndex);
301 FbxString CreateShapeChannelName(FbxString pShapeName);
302
303 void CopyDeformers(const FbxGeometry* pGeometry);
304 void CopyPivot(const FbxGeometry* pSource);
305
306 // Used during FBX v5 file store
307 FbxArray<FbxString*> mShapeNameArrayV6;
308 FbxArray<FbxString*> mShapeNameArrayV5;
309 FbxArray<FbxString*> mShapeChannelNameArrayV5;
310
311 FbxAMatrix* mPivot;
312
313#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
314};
315
316#include <fbxsdk/fbxsdk_nsend.h>
317
318#endif /* _FBXSDK_SCENE_GEOMETRY_H_ */
319