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 fbxproperty.h |
13 | #ifndef _FBXSDK_CORE_PROPERTY_H_ |
14 | #define _FBXSDK_CORE_PROPERTY_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/fbxquery.h> |
19 | #include <fbxsdk/core/fbxpropertydef.h> |
20 | #include <fbxsdk/core/fbxpropertytypes.h> |
21 | #include <fbxsdk/core/fbxdatatypes.h> |
22 | #include <fbxsdk/core/base/fbxmap.h> |
23 | #include <fbxsdk/core/base/fbxset.h> |
24 | |
25 | #include <fbxsdk/fbxsdk_nsbegin.h> |
26 | |
27 | class FbxObject; |
28 | class FbxAnimStack; |
29 | class FbxAnimLayer; |
30 | class FbxAnimCurveNode; |
31 | class FbxAnimCurve; |
32 | class FbxAnimEvaluator; |
33 | |
34 | /** \brief Class to hold user properties. |
35 | * \nosubgrouping |
36 | */ |
37 | class FBXSDK_DLL FbxProperty |
38 | { |
39 | public: |
40 | /** |
41 | * \name Constructor and Destructor. |
42 | */ |
43 | //@{ |
44 | /** Creates a runtime property on the specified property. |
45 | * \param pCompoundProperty The parent property of this property. |
46 | * \param pDataType The data type of this property. |
47 | * \param pName The property name. |
48 | * \param pLabel The label of this property. |
49 | * \param pCheckForDup If \c true, parent property checks if it has a child property already with pName, if \c false, the new property is created. |
50 | * \param pWasFound If pCheckForDup is \c true, this flag is set to indicate whether the pCompoundProperty already has a child property with pName. |
51 | */ |
52 | static FbxProperty Create(const FbxProperty& pCompoundProperty, const FbxDataType& pDataType, const char* pName, const char* pLabel="" , bool pCheckForDup=true, bool* pWasFound=NULL); |
53 | |
54 | /** Creates a runtime property on the specified object. |
55 | * \param pObject The object on which the property will be created. |
56 | * \param pDataType The data type of this property. |
57 | * \param pName The property name. |
58 | * \param pLabel The label of this property. |
59 | * \param pCheckForDup If \c true, pObject checks whether it already has a property with pName, if \c false, a new property is created. |
60 | * \param pWasFound If pCheckForDup is \c true, this flag is set to indicate whether the pObject already has a child property with pName. |
61 | */ |
62 | static FbxProperty Create(FbxObject* pObject, const FbxDataType& pDataType, const char* pName, const char* pLabel="" , bool pCheckForDup=true, bool* pWasFound=NULL); |
63 | |
64 | /** Creates a dynamic property from another property on the specified property. |
65 | * \param pCompoundProperty The parent property of this property. |
66 | * \param pFromProperty The property copied by this property. |
67 | * \param pCheckForDup If \c true, parent property checks if it already has a child property that has the name of pFromProperty, if \c false, a new property is created. |
68 | * \remark Only the property name, label, min/max, enums and flags are copied. |
69 | */ |
70 | static FbxProperty CreateFrom(const FbxProperty& pCompoundProperty, FbxProperty& pFromProperty, bool pCheckForDup=true); |
71 | |
72 | /** Creates a dynamic property from another property on the specified object. |
73 | * \param pObject The object that contains this property. |
74 | * \param pFromProperty The property copied by this property. |
75 | * \param pCheckForDup If \c true, pObject checks if it already has a property that has the name of pFromProperty, if \c false, a new property is created. |
76 | * \remark Only the property name, label, min/max, enums and flags are copied. |
77 | */ |
78 | static FbxProperty CreateFrom(FbxObject* pObject, FbxProperty& pFromProperty, bool pCheckForDup=true); |
79 | |
80 | /** Destroys a dynamic property. |
81 | */ |
82 | void Destroy(); |
83 | |
84 | /** Destroys a dynamic property and its children |
85 | * \remarks Destroy all children of current property, and current property will also be destroyed. |
86 | */ |
87 | void DestroyRecursively(); |
88 | |
89 | /** Destroys children of a dynamic property. |
90 | * \remarks Destroy all children of current property, and current property will not be destroyed. |
91 | */ |
92 | void DestroyChildren(); |
93 | |
94 | /** Static property constructor. |
95 | */ |
96 | FbxProperty(); |
97 | |
98 | /** Copy constructor for properties. |
99 | * \param pProperty The property copied to this one. |
100 | */ |
101 | FbxProperty(const FbxProperty& pProperty); |
102 | |
103 | /** Copy constructor for properties. |
104 | * \param pPropertyHandle The property handle copied to this property handle. |
105 | */ |
106 | FbxProperty(const FbxPropertyHandle& pPropertyHandle); |
107 | |
108 | /** Static property destructor. |
109 | */ |
110 | ~FbxProperty(); |
111 | //@} |
112 | |
113 | /** |
114 | * \name Property Identification. |
115 | */ |
116 | //@{ |
117 | /** Returns the property data type. |
118 | * \return The property data type. |
119 | */ |
120 | FbxDataType GetPropertyDataType() const; |
121 | |
122 | /** Returns the internal name of the property. |
123 | * \return Property internal name string. |
124 | */ |
125 | FbxString GetName() const; |
126 | |
127 | /** Returns the internal name of the property. |
128 | * \return Property internal name string. |
129 | */ |
130 | const char* GetNameAsCStr() const; |
131 | |
132 | /** Returns the hierarchical name of the property. |
133 | * \return Property hierarchical name string. |
134 | */ |
135 | FbxString GetHierarchicalName() const; |
136 | |
137 | /** Returns the property label. |
138 | * \param pReturnNameIfEmpty If \c true, lets this method return the internal name if the label is empty. |
139 | * \return The property label if set, or the property internal name if the pReturnNameIfEmpty |
140 | * flag is set to \c true and the label has not been defined. |
141 | * \remarks Some applications may ignore the label field and work uniquely with the |
142 | * internal name. Therefore, it should not be taken for granted that a label exists. Also, remember |
143 | * that the label does not get saved in the FBX file. It only exists while the property object is |
144 | * in memory. |
145 | */ |
146 | FbxString GetLabel(bool pReturnNameIfEmpty=true) const; |
147 | |
148 | |
149 | /** Sets a label for the property. |
150 | * \param pLabel Label string. |
151 | */ |
152 | void SetLabel(const FbxString& pLabel); |
153 | |
154 | /** Returns the object that contains the property. |
155 | * \return The property object owner (or null if the property is an orphan). |
156 | */ |
157 | FbxObject* GetFbxObject() const; |
158 | //@} |
159 | |
160 | /** |
161 | * \name User data |
162 | */ |
163 | //@{ |
164 | /** Sets the user tag. |
165 | * \param pTag The user tag to be set. |
166 | */ |
167 | void SetUserTag(int pTag); |
168 | |
169 | //! Gets the user tag. |
170 | int GetUserTag(); |
171 | |
172 | /** Sets the user data pointer. |
173 | * \param pUserData The user data pointer. |
174 | */ |
175 | void SetUserDataPtr(void* pUserData); |
176 | |
177 | /** Gets the user data pointer. |
178 | * \return The user data pointer. |
179 | */ |
180 | void* GetUserDataPtr(); |
181 | //@} |
182 | |
183 | /** |
184 | * \name Property Flags. |
185 | */ |
186 | //@{ |
187 | /** Changes the property attribute. |
188 | * \param pFlag Property attribute identifier. |
189 | * \param pValue New state of pFlag. |
190 | */ |
191 | void ModifyFlag(FbxPropertyFlags::EFlags pFlag, bool pValue); |
192 | |
193 | /** Returns the state of the property attribute. |
194 | * \param pFlag Property attribute identifier. |
195 | * \return The state of the property attribute(pFlag). |
196 | */ |
197 | bool GetFlag(FbxPropertyFlags::EFlags pFlag) const; |
198 | |
199 | /** Returns the state of all of the property attributes. |
200 | * \return The state of the property attributes(pFlags). |
201 | */ |
202 | FbxPropertyFlags::EFlags GetFlags() const; |
203 | |
204 | /** Returns the inheritance type of the given flag, similar to GetValueInheritType(). |
205 | * \param pFlag The flag to be queried. |
206 | * \return The inheritance type of the specific flag. |
207 | */ |
208 | FbxPropertyFlags::EInheritType GetFlagInheritType( FbxPropertyFlags::EFlags pFlag ) const; |
209 | |
210 | /** Sets the inheritance type for the specific flag, similar to SetValueInheritType(). |
211 | * \param pFlag The flag to be set. |
212 | * \param pType The inheritance type to be set. |
213 | * \return \c True on success, \c false otherwise. |
214 | */ |
215 | bool SetFlagInheritType( FbxPropertyFlags::EFlags pFlag, FbxPropertyFlags::EInheritType pType ); |
216 | |
217 | /** Checks if the property flag has been modified from its default value. |
218 | * \param pFlag The flag to be queried. |
219 | * \return \c True if the value of this property has changed, \c false otherwise |
220 | */ |
221 | bool ModifiedFlag( FbxPropertyFlags::EFlags pFlag ) const; |
222 | //@} |
223 | |
224 | /** |
225 | * \name Assignment and comparison operators |
226 | */ |
227 | //@{ |
228 | /** Assignment operator. |
229 | * \param pProperty The property assigned to this property. |
230 | * \return This property. |
231 | */ |
232 | FbxProperty& operator= (const FbxProperty& pProperty); |
233 | |
234 | /** Equivalence operator. |
235 | * \param pProperty The property compared to this property. |
236 | * \return \c True if equal, \c false otherwise. |
237 | */ |
238 | bool operator== (const FbxProperty& pProperty) const; |
239 | |
240 | /** Non-equivalence operator. |
241 | * \param pProperty The property compared to this property. |
242 | * \return \c True if unequal, \c false otherwise. |
243 | */ |
244 | bool operator!= (const FbxProperty& pProperty) const; |
245 | |
246 | /** Lesser operator, used to sort property in map. |
247 | * \param pProperty The property compared to this property. |
248 | * \return \c true if less, \c false otherwise. */ |
249 | bool operator< (const FbxProperty& pProperty) const; |
250 | |
251 | /** Greater operator, used to sort property in map. |
252 | * \param pProperty The property compared to this property. |
253 | * \return \c true if greater, \c false otherwise. */ |
254 | bool operator> (const FbxProperty& pProperty) const; |
255 | |
256 | /** Equivalence operator. |
257 | * \param pValue The value compared to this property. |
258 | * \return \c True if this property is valid and pValue doesn't equal zero, or this property is invalid and pValue equals zero, \c false otherwise. |
259 | */ |
260 | inline bool operator== (int pValue) const { return (pValue == 0) ? !IsValid() : IsValid(); } |
261 | |
262 | /** Non-equivalence operator. |
263 | * \param pValue The value compared to this property. |
264 | * \return \c True if this property is valid and pValue equals zero, or this property is invalid and pValue doesn't equal zero, \c false otherwise. |
265 | */ |
266 | inline bool operator!= (int pValue) const { return (pValue != 0) ? !IsValid() : IsValid(); } |
267 | |
268 | /** Compares this property's value to another property's value. |
269 | * \param pProperty The property whose value is compared with this property's value. |
270 | * \return \c True if equal, \c false otherwise. |
271 | */ |
272 | bool CompareValue(const FbxProperty& pProperty) const; |
273 | //@} |
274 | |
275 | /** Copies the value of a property. |
276 | * \param pProperty The property from which to derive the value. |
277 | * \return \c True if value has been copied successfully, \c false otherwise. |
278 | */ |
279 | bool CopyValue(const FbxProperty& pProperty); |
280 | |
281 | /** |
282 | * \name Value management. |
283 | */ |
284 | //@{ |
285 | /** Gets the value of the property. |
286 | * \tparam T The data type of the value. |
287 | * \return The property value. |
288 | */ |
289 | template <class T> inline T Get() const { T lValue; Get(&lValue, FbxTypeOf(lValue)); return lValue; } |
290 | |
291 | /** Sets the value of the property. |
292 | * \param pValue The new value |
293 | * \return \c True if type is compatible and the value is set successfully, \c false otherwise. |
294 | */ |
295 | template <class T> inline bool Set(const T& pValue){ return Set(&pValue, FbxTypeOf(pValue)); } |
296 | |
297 | /** Judges the property's validity. |
298 | * \return \c True if this property is valid, \c false otherwise. |
299 | */ |
300 | bool IsValid() const; |
301 | |
302 | /** Checks if the specified property's value has changed from its default value. |
303 | * \param pProperty Property that is tested. |
304 | * \return \c True if the property value is still the default, \c false otherwise. |
305 | * \remarks If the inheritance type of pProperty's value is eOverride, pProperty's value should |
306 | * have been modified, so pProperty doesn't have the default value. |
307 | * If the inheritance type of pProperty's value is eInherit, that means pProperty's value inherits |
308 | * the referenced object's property value, so pProperty has the default value. |
309 | */ |
310 | static bool HasDefaultValue(FbxProperty& pProperty); |
311 | |
312 | /** Queries the inheritance type of the property. |
313 | * Use this method to determine if this property's value is overridden from the default |
314 | * value, or from the referenced object, if this object is a clone. |
315 | * \return The inheritance type of the property. |
316 | */ |
317 | FbxPropertyFlags::EInheritType GetValueInheritType() const; |
318 | |
319 | /** Sets the inheritance type of the property. |
320 | * Use the method to explicitly override the default value of the property, |
321 | * or the referenced object's property value, if this object is a clone. |
322 | * |
323 | * You can also use this to explicitly inherit the default value of the property, |
324 | * or the referenced object's property value, if this object is a clone. |
325 | * |
326 | * \param pType The new inheritance type. |
327 | * \return \c True on success, \c false otherwise. |
328 | */ |
329 | bool SetValueInheritType( FbxPropertyFlags::EInheritType pType ); |
330 | |
331 | /** Checks if the property's value has been modified from its default value. |
332 | * \return \c True if the value of the property has changed, \c false otherwise. |
333 | * \remarks If the inheritance type of the property's value is eOverride, the property's value should |
334 | * have been modified, it returns \c true. |
335 | * If the inheritance type of the property's value is eInherit, that means the property's value inherits |
336 | * the referenced object's property value, so the property's value is not modified and it returns \c false. |
337 | */ |
338 | bool Modified() const; |
339 | //@} |
340 | |
341 | /** |
342 | * \name Property Limits. |
343 | * Property limits are provided for convenience if some applications desire to |
344 | * bound the range of possible values for a given type property. FBX will never |
345 | * apply these limits internally, however it will store and retrieve the limits values |
346 | * from files, and will assure that they are persistent in memory |
347 | * while the property exists. |
348 | * |
349 | * Notes: |
350 | * - The limit value is truncated to the property data type. |
351 | * |
352 | * - These limits are meaningless for the boolean type. It is the responsibility of the |
353 | * calling application to implement the necessary instructions to limit the property of boolean type. |
354 | * |
355 | * - The SetMinLimit/SetMaxLimit methods will do nothing if SupportSetLimitsAsDoube() returns false. |
356 | */ |
357 | //@{ |
358 | /** Returns whether setting limits as a double number on this property type is allowed. |
359 | * \return \c True if allowed, \c false otherwise. |
360 | */ |
361 | bool SupportSetLimitAsDouble() const; |
362 | |
363 | /** Sets a minimum property value limit. |
364 | * \param pMin Minimum value allowed. |
365 | * \return \c True if the limit has been set, \c false otherwise. |
366 | */ |
367 | bool SetMinLimit(double pMin); |
368 | |
369 | /** Returns whether a minimum limit exists, if it returns false, |
370 | * calling GetMinLimit() produces undefined behavior. |
371 | * \return \c True when a minimum limit exists, \c false otherwise. |
372 | */ |
373 | bool HasMinLimit() const; |
374 | |
375 | /** Returns the minimum property value limit. |
376 | * \return The minimum value limit. |
377 | */ |
378 | double GetMinLimit() const; |
379 | |
380 | /** Returns whether a maximum limit exists, if it returns false, |
381 | * calling GetMaxLimit() produces undefined behavior. |
382 | * \return \c True when a maximum limit exists, \c false otherwise. |
383 | */ |
384 | bool HasMaxLimit() const; |
385 | |
386 | /** Sets a maximum property value limit. |
387 | * \param pMax Maximum value allowed. |
388 | * \return \c True if the limit has been set, \c false otherwise. |
389 | */ |
390 | bool SetMaxLimit(double pMax); |
391 | |
392 | /** Returns the maximum property value. |
393 | * \return The maximum value limit. |
394 | */ |
395 | double GetMaxLimit() const; |
396 | |
397 | /** Sets the minimum and maximum value limit of the property. |
398 | * \param pMin Minimum value allowed. |
399 | * \param pMax Maximum value allowed. |
400 | \return \c True if both the min and max limit have been set, \c false otherwise. |
401 | */ |
402 | bool SetLimits(double pMin, double pMax); |
403 | //@} |
404 | |
405 | /** |
406 | * \name Enum and property list |
407 | */ |
408 | //@{ |
409 | /** Adds a string value at the end of the enumeration list. |
410 | * \param pStringValue The string value to be added. |
411 | * \return The index in the list where the string is added or -1 if the action failed. |
412 | * \remarks This function is only valid if the property type is eFbxEnum or eFbxEnumM. |
413 | * \remarks If the property is of type eFbxEnum, trying to add a value that is already |
414 | * in the enumeration list will fail. |
415 | * Empty strings are not allowed. |
416 | */ |
417 | int AddEnumValue(const char* pStringValue); |
418 | |
419 | /** Inserts a string value at the specific index. |
420 | * \param pIndex Zero bound index. |
421 | * \param pStringValue The string value to be inserted. |
422 | * \remarks This function is only valid if the property type is eFbxEnum or eFbxEnumM. |
423 | * \remarks If the property is of type eFbxEnum, trying to insert a value that is already |
424 | * in the enumeration list will fail. |
425 | * pIndex must be in the range [0, ListValueGetCount()]. |
426 | * Empty strings are not allowed. |
427 | */ |
428 | void InsertEnumValue(int pIndex, const char* pStringValue); |
429 | |
430 | /** Returns the number of elements in the enumeration list. |
431 | * \return The number of elements in the enumeration list. |
432 | * \remarks This function returns 0 if the property type is not eFbxEnum or eFbxEnumM. |
433 | */ |
434 | int GetEnumCount() const; |
435 | |
436 | /** Sets a string value at the specific index. |
437 | * \param pIndex Zero bound index. |
438 | * \param pStringValue The string value at the specific index. |
439 | * \remarks This function is only valid if the property type is eFbxEnum or eFbxEnumM. |
440 | * \remarks If the property is of type eFbxEnum, trying to set a value that is already |
441 | * in the enumeration list will fail. |
442 | * The function assigns the string value to the specific index. |
443 | * A string value must exist at the specific index in order to be changed. |
444 | * Empty strings are not allowed. |
445 | */ |
446 | void SetEnumValue(int pIndex, const char* pStringValue); |
447 | |
448 | /** Removes the string value at the specified index. |
449 | * \param pIndex Index of the string value to be removed. |
450 | * \remarks This function is only valid if the property type is eFbxEnum or eFbxEnuM. |
451 | */ |
452 | void RemoveEnumValue(int pIndex); |
453 | |
454 | /** Returns a string value at the specified index |
455 | * \param pIndex Zero bound index. |
456 | * \remarks This function is only valid if the property type is eFbxEnum or eFbxEnumM. |
457 | */ |
458 | const char* GetEnumValue(int pIndex) const; |
459 | //@} |
460 | |
461 | /** |
462 | * \name Hierarchical properties |
463 | */ |
464 | //@{ |
465 | /** Judges if this property is the root property. |
466 | * \return \c True when this property is a root property, \c false otherwise. |
467 | */ |
468 | inline bool IsRoot() const { return mPropertyHandle.IsRoot(); } |
469 | |
470 | /** Judges whether this property is a child of the specified property. |
471 | * \param pParent The specified property. |
472 | * \return \c True when this property is a child of the specified property, \c false otherwise. |
473 | */ |
474 | inline bool IsChildOf(const FbxProperty& pParent) const { return mPropertyHandle.IsChildOf(pParent.mPropertyHandle); } |
475 | |
476 | /** Judges whether this property is a descendant of the specified property. |
477 | * \param pAncestor The specified property. |
478 | * \return \c True when this property is a descendant of the specified property, \c false otherwise. |
479 | */ |
480 | inline bool IsDescendentOf(const FbxProperty& pAncestor) const { return mPropertyHandle.IsDescendentOf(pAncestor.mPropertyHandle); } |
481 | |
482 | /** Returns the parent property of this property. |
483 | * \return The parent of this property. |
484 | */ |
485 | inline FbxProperty GetParent() const { return FbxProperty(mPropertyHandle.GetParent()); } |
486 | |
487 | /** Returns the first child of this property. |
488 | * \return The first child of this property, if there is none, an invalid property is returned. |
489 | */ |
490 | inline FbxProperty GetChild() const { return FbxProperty(mPropertyHandle.GetChild()); } |
491 | |
492 | /** Returns the sibling of this property. |
493 | * \return The sibling of this property, if there is none, an invalid property is returned. |
494 | */ |
495 | inline FbxProperty GetSibling() const { return FbxProperty(mPropertyHandle.GetSibling()); } |
496 | |
497 | /** Returns the first property that is a descendant of this property. |
498 | * \return The first descendant of this property, if there is none, an invalid property is returned. |
499 | */ |
500 | inline FbxProperty GetFirstDescendent() const { return FbxProperty(mPropertyHandle.GetFirstDescendent()); } |
501 | |
502 | /** Returns the property that follows pProperty that is a descendant of this property. |
503 | * \param pProperty The last found descendant. |
504 | * \return The property that follows pProperty, if there is none, an invalid property is returned. |
505 | */ |
506 | inline FbxProperty GetNextDescendent(const FbxProperty& pProperty) const { return FbxProperty(mPropertyHandle.GetNextDescendent(pProperty.mPropertyHandle)); } |
507 | |
508 | /** Searches a property using its name. |
509 | * \param pName The name of the property as a \c NULL terminated string. |
510 | * \param pCaseSensitive Whether the name is case-sensitive. |
511 | * \return A valid FbxProperty if the property is found, else |
512 | * an invalid FbxProperty. See FbxProperty::IsValid() |
513 | */ |
514 | inline FbxProperty Find (const char* pName, bool pCaseSensitive = true) const { return FbxProperty(mPropertyHandle.Find(pName,pCaseSensitive)); } |
515 | |
516 | /** Searches a property using its name and data type. |
517 | * \param pName The name of the property as a \c NULL terminated string. |
518 | * \param pDataType The data type of the property. |
519 | * \param pCaseSensitive Whether the name is case-sensitive. |
520 | * \return A valid FbxProperty if the property is found, else |
521 | * an invalid FbxProperty. See FbxProperty::IsValid() |
522 | */ |
523 | inline FbxProperty Find (const char* pName, const FbxDataType& pDataType, bool pCaseSensitive = true) const { return FbxProperty(mPropertyHandle.Find(pName,pDataType.GetTypeInfoHandle(),pCaseSensitive)); } |
524 | |
525 | /** Searches a property using its full name. |
526 | * \param pName The full name of the property as a \c NULL terminated string. |
527 | * \param pCaseSensitive whether the name is case-sensitive. |
528 | * \return A valid FbxProperty if the property is found, else |
529 | * an invalid FbxProperty. See FbxProperty::IsValid() |
530 | */ |
531 | inline FbxProperty FindHierarchical (const char* pName, bool pCaseSensitive = true) const { return FbxProperty(mPropertyHandle.Find(pName,sHierarchicalSeparator,pCaseSensitive)); } |
532 | |
533 | /** Searches a property using its full name and data type. |
534 | * \param pName The full name of the property as a \c NULL terminated string. |
535 | * \param pDataType The data type of the property. |
536 | * \param pCaseSensitive whether the name is case-sensitive. |
537 | * \return A valid FbxProperty if the property is found, else |
538 | * an invalid FbxProperty. See FbxProperty::IsValid() |
539 | */ |
540 | inline FbxProperty FindHierarchical (const char* pName, const FbxDataType& pDataType, bool pCaseSensitive = true) const { return FbxProperty(mPropertyHandle.Find(pName,sHierarchicalSeparator,pDataType.GetTypeInfoHandle(),pCaseSensitive)); } |
541 | //@} |
542 | |
543 | /** |
544 | * \name Optimizations |
545 | */ |
546 | //@{ |
547 | //! Internal function for building a property name map. |
548 | inline void BeginCreateOrFindProperty(){ mPropertyHandle.BeginCreateOrFindProperty(); } |
549 | |
550 | //! Internal function for clearing the property name map. |
551 | inline void EndCreateOrFindProperty(){ mPropertyHandle.EndCreateOrFindProperty(); } |
552 | |
553 | //!This is an internal class that you can use to build and clear the name map of properties. You can use the name map to speed up searching for property names. |
554 | class FbxPropertyNameCache |
555 | { |
556 | public: |
557 | /** Constructor, the name map is created in the constructor. |
558 | * \param prop Property for building and clearing the name map. |
559 | */ |
560 | FbxPropertyNameCache(const FbxProperty& prop) : mProp(const_cast<FbxProperty&>(prop)){ mProp.BeginCreateOrFindProperty(); } |
561 | |
562 | //! Destructor, the name map is destroyed in destructor. |
563 | ~FbxPropertyNameCache(){ mProp.EndCreateOrFindProperty(); } |
564 | |
565 | private: |
566 | FbxProperty& mProp; |
567 | FbxPropertyNameCache& operator=(const FbxPropertyNameCache& pOther){ mProp = pOther.mProp; mProp.BeginCreateOrFindProperty(); return *this; } |
568 | }; |
569 | //@} |
570 | |
571 | /** |
572 | * \name Animation Curve Management |
573 | */ |
574 | //@{ |
575 | /** Retrieve the proper animation evaluator to use for this property. |
576 | * \return If the object has no scene, returns the default evaluator, otherwise the object's scene evaluator. */ |
577 | FbxAnimEvaluator* GetAnimationEvaluator() const; |
578 | |
579 | /** Find out if the property is animated: has a curve node with curves. |
580 | * \param pAnimLayer The animation layer to test for curve presence. Set to NULL if you want to use the default animation layer of the default animation stack. |
581 | * \return \c true if the property is animated. */ |
582 | bool IsAnimated(FbxAnimLayer* pAnimLayer=NULL) const; |
583 | |
584 | /** Evaluate the value of a property if it has animation and return the result as the template type. |
585 | * \param pTime The time used for evaluate. If FBXSDK_TIME_INFINITE is used, this returns the default value, without animation curves evaluation. |
586 | * \param pForceEval Force the evaluator to refresh the evaluation state cache even if its already up-to-date. |
587 | * \return The property value at the specified time converted to the template type provided, if possible. |
588 | * \remark If the property type versus the template cannot be converted, the result is unknown. */ |
589 | template <class T> T EvaluateValue(const FbxTime& pTime=FBXSDK_TIME_INFINITE, bool pForceEval=false); |
590 | |
591 | /** Evaluate the value of a property if it has animation and return the result. |
592 | * \param pTime The time used for evaluate. If FBXSDK_TIME_INFINITE is used, this returns the default value, without animation curves evaluation. |
593 | * \param pForceEval Force the evaluator to refresh the evaluation state cache even if its already up-to-date. |
594 | * \return The property value at the specified time. */ |
595 | FbxPropertyValue& EvaluateValue(const FbxTime& pTime=FBXSDK_TIME_INFINITE, bool pForceEval=false); |
596 | |
597 | /** Creates a FbxAnimCurveNode on the specified layer. |
598 | * \param pAnimLayer The animation layer the FbxAnimCurveNode object is attached to. |
599 | * \return Pointer to the created FbxAnimCurveNode. |
600 | * \remarks This function check the property FbxPropertyFlags::eAnimatable flag and fails to execute if it is not set. |
601 | * \remarks If created, the FbxAnimCurveNode is automatically connected to the property and the animation layer. |
602 | * \remarks The created FbxAnimCurveNode does not automatically allocate anim curves. |
603 | * \remarks On the successful execution of this function, the property eAnimated flag is set to \c true. */ |
604 | FbxAnimCurveNode* CreateCurveNode(FbxAnimLayer* pAnimLayer); |
605 | |
606 | /** Get the property's animation curve node on the default animation stack and base layer. |
607 | * \param pCreate If \c true, create the animation curve node and return it if none were found. |
608 | * \return The animation curve node of this property, if found or created, otherwise NULL. |
609 | * \remark If the property flag FbxPropertyFlags::eAnimatable is not set, creating the curve node will fail. */ |
610 | FbxAnimCurveNode* GetCurveNode(bool pCreate=false); |
611 | |
612 | /** Get the property's animation curve node on the specified animation stack, using its base layer. |
613 | * \param pAnimStack The animation stack to use to get or create the property's animation curve node. |
614 | * \c NULL can be passed to automatically specify the default animation stack. |
615 | * \param pCreate If \c true, create the animation curve node and return it if none were found. |
616 | * \return The animation curve node of this property, if found or created, otherwise NULL. |
617 | * \remark If the property flag FbxPropertyFlags::eAnimatable is not set, creating the curve node will fail. */ |
618 | FbxAnimCurveNode* GetCurveNode(FbxAnimStack* pAnimStack, bool pCreate=false); |
619 | |
620 | /** Get the property's animation curve node on the specified animation layer. |
621 | * \param pAnimLayer The animation layer to use to get or create the property's animation curve node. Cannot be NULL. |
622 | * \param pCreate If \c true, create the animation curve node and return it if none were found. |
623 | * \return The animation curve node of this property, if found or created, otherwise NULL. |
624 | * \remark If the property flag FbxPropertyFlags::eAnimatable is not set, creating the curve node will fail. */ |
625 | FbxAnimCurveNode* GetCurveNode(FbxAnimLayer* pAnimLayer, bool pCreate=false); |
626 | |
627 | /** Get the FbxAnimCurve from the specified animation layer. |
628 | * This function expects to find a FbxAnimCurveNode object with the same name as the property and it |
629 | * attempts to retrieve the FbxAnimCurve from it. |
630 | * \param pAnimLayer The searched animation layer. |
631 | * \param pCreate Create a FbxAnimCurve if not found. |
632 | * \return Pointer to the FbxAnimCurve. Returns NULL in case of errors or pCreate is \c false and the curve is not found. |
633 | * \remark If the FbxAnimCurveNode does not exists but the property has the FbxPropertyFlags::eAnimatable flag set and |
634 | * pCreate is true, then this function will first create the FbxAnimCurveNode object and then the FbxAnimCurve. |
635 | * \remark If more than one FbxAnimCurveNode matching the name criteria are connected, the first one is returned. */ |
636 | inline FbxAnimCurve* GetCurve(FbxAnimLayer* pAnimLayer, bool pCreate=false) |
637 | { |
638 | return GetCurve(pAnimLayer, GetName(), NULL, pCreate); |
639 | } |
640 | |
641 | /** Get the FbxAnimCurve from the specified animation layer. |
642 | * This function expects to find a FbxAnimCurveNode object with the same name as the property and it |
643 | * attempts to retrieve the FbxAnimCurve from it. |
644 | * \param pAnimLayer The searched animation layer. |
645 | * \param pChannel Name of the channel we are looking for the animation curve. If NULL use the first defined channel. |
646 | * \param pCreate Create a FbxAnimCurve if not found. |
647 | * \return Pointer to the FbxAnimCurve. Returns NULL in case of errors or pCreate is \c false and the curve is not found. |
648 | * \remark If the FbxAnimCurveNode does not exists but the property has the FbxPropertyFlags::eAnimatable flag set and |
649 | * pCreate is true, then this function will first create the FbxAnimCurveNode object and then the FbxAnimCurve. |
650 | * \remark If more than one FbxAnimCurveNode matching the name criteria are connected, the first one is returned. */ |
651 | inline FbxAnimCurve* GetCurve(FbxAnimLayer* pAnimLayer, const char* pChannel, bool pCreate=false) |
652 | { |
653 | return GetCurve(pAnimLayer, GetName(), pChannel, pCreate); |
654 | } |
655 | |
656 | /** Get the FbxAnimCurve of the specified channel from the specified animation layer. |
657 | * This function looks for the FbxAnimCurveNode named pName and the channel pChannel. It |
658 | * will retrieves the FbxAnimCurve from it. |
659 | * \param pAnimLayer The searched animation layer. |
660 | * \param pName Name of the curve node. It is an error to leave this field empty. |
661 | * \param pChannel Name of the channel we are looking for the animation curve. If NULL |
662 | * use the first defined channel. |
663 | * \param pCreate Create a FbxAnimCurve if not found. |
664 | * \return Pointer to the FbxAnimCurve. Returns NULL in case of errors or pCreate is \c false and the curve is not found. |
665 | * \remark If the FbxAnimCurveNode does not exists but the property has the FbxPropertyFlags::eAnimatable flag set and |
666 | * pCreate is true, then this function will first create the FbxAnimCurveNode object and then the FbxAnimCurve. |
667 | * \remark If more than one FbxAnimCurveNode matching the name criteria are connected, the first one is returned. |
668 | * \remark If pChannel is NULL, this function is the equivalent of GetCurve(FbxAnimLayer*, bool). */ |
669 | FbxAnimCurve* GetCurve(FbxAnimLayer* pAnimLayer, const char* pName, const char* pChannel, bool pCreate); |
670 | //@} |
671 | |
672 | /** |
673 | * \name General Object Connection and Relationship Management |
674 | */ |
675 | //@{ |
676 | /** Connects this property to one source object. |
677 | * \param pObject The source object to which this property connects. |
678 | * \param pType The connection type between the property and the object. |
679 | * \return \c True on success, \c false otherwise. |
680 | */ |
681 | bool ConnectSrcObject(FbxObject* pObject, FbxConnection::EType pType=FbxConnection::eNone); |
682 | |
683 | /** Judges whether this property connects with the source object. |
684 | * \param pObject The source object. |
685 | * \return \c True if this property connects with the source object, \c false otherwise. |
686 | */ |
687 | bool IsConnectedSrcObject(const FbxObject* pObject) const; |
688 | |
689 | /** Disconnects this property from one source object. |
690 | * \param pObject The source object from which this property will be disconnected. |
691 | * \return \c True on success, \c false otherwise. |
692 | */ |
693 | bool DisconnectSrcObject(FbxObject* pObject); |
694 | |
695 | /** Disconnects this property from all the source objects. |
696 | * \return \c True if it disconnects all the source objects successfully, \c false otherwise. |
697 | */ |
698 | bool DisconnectAllSrcObject(); |
699 | |
700 | /** Disconnects this property from all source objects that satisfy a given criteria. |
701 | * \param pCriteria The given criteria. |
702 | * \return \c True if it disconnects all the source objects successfully, \c false otherwise. |
703 | */ |
704 | bool DisconnectAllSrcObject(const FbxCriteria& pCriteria); |
705 | |
706 | /** Disconnects this property from all the source objects of a specific class type. (Deprecated, please use DisconnectAllSrcObject<Type>() instead.) |
707 | * \param pClassId The specific class type. |
708 | * \return \c True if it disconnects all the source objects successfully, \c false otherwise. |
709 | */ |
710 | FBX_DEPRECATED bool DisconnectAllSrcObject(const FbxClassId& pClassId); |
711 | |
712 | /** Returns the number of source objects with which this property connects. |
713 | * \return The number of source objects with which this property connects. |
714 | */ |
715 | int GetSrcObjectCount() const; |
716 | |
717 | /** Returns the number of source objects that satisfy the given criteria with which this property connects. |
718 | * \param pCriteria The given criteria. |
719 | * \return The number of source objects that satisfy the given criteria with which this property connects. |
720 | */ |
721 | int GetSrcObjectCount(const FbxCriteria& pCriteria) const; |
722 | |
723 | /** Returns the number of source objects of the specific class type with which this property connects. (Deprecated, please use GetSrcObjectCount<Type>() instead.) |
724 | * \param pClassId The specific class type. |
725 | * \return The number of source objects of the specific class type with which this property connects. |
726 | */ |
727 | FBX_DEPRECATED int GetSrcObjectCount(const FbxClassId& pClassId) const; |
728 | |
729 | /** Returns the source object at the specified index with which this property connects. |
730 | * \param pIndex The specified index whose default value is 0. |
731 | * \return The source object at the specified index, NULL if not found. |
732 | */ |
733 | FbxObject* GetSrcObject(const int pIndex=0) const; |
734 | |
735 | /** Returns the source object that satisfies the criteria at the specified index with which this property connects. |
736 | * \param pCriteria The given criteria. |
737 | * \param pIndex The specified index whose default value is 0. |
738 | * \return The source object that satisfies the given criteria at the specified index, NULL if not found. |
739 | */ |
740 | FbxObject* GetSrcObject(const FbxCriteria& pCriteria, const int pIndex=0) const; |
741 | |
742 | /** Returns the source object of the specified class type at the specified index with which this property connects. (Deprecated, please use GetSrcObject<Type>() instead.) |
743 | * \param pClassId The specified class type. |
744 | * \param pIndex The specified index whose default value is 0. |
745 | * \return The source object of the specified class type at the specified index, NULL if not found. |
746 | */ |
747 | FBX_DEPRECATED FbxObject* GetSrcObject(const FbxClassId& pClassId, const int pIndex=0) const; |
748 | |
749 | /** Searches the source object with the specified name, starting with the specified index. |
750 | * \param pName The object name. |
751 | * \param pStartIndex The start index. |
752 | * \return The source object with the name, NULL if not found. |
753 | */ |
754 | FbxObject* FindSrcObject(const char* pName, const int pStartIndex=0) const; |
755 | |
756 | /** Searches the source object with the specified name which satisfies the given criteria, starting with the specified index. |
757 | * \param pCriteria The given criteria. |
758 | * \param pName The object name. |
759 | * \param pStartIndex The start index. |
760 | * \return The source object with the name, NULL if not found. |
761 | */ |
762 | FbxObject* FindSrcObject(const FbxCriteria& pCriteria, const char* pName, const int pStartIndex=0) const; |
763 | |
764 | /** Searches the source object with the specified name which is of the specified class type, starting with the specified index. (Deprecated, please use FindSrcObject<Type>() instead.) |
765 | * \param pClassId The specified class type. |
766 | * \param pName The object name. |
767 | * \param pStartIndex The start index. |
768 | * \return The source object with the name, NULL if not found. |
769 | */ |
770 | FBX_DEPRECATED FbxObject* FindSrcObject(const FbxClassId& pClassId, const char* pName, const int pStartIndex=0) const; |
771 | |
772 | /** Disconnects this property from all source objects of the specified class type. |
773 | * \tparam T The specified class type. |
774 | * \return \c True if it disconnects all source objects successfully, \c false otherwise. |
775 | */ |
776 | template <class T> inline bool DisconnectAllSrcObject(){ return DisconnectAllSrcObject(FbxCriteria::ObjectType(T::ClassId)); } |
777 | |
778 | /** Disconnects this property from all source objects which are of the specified class type and satisfy the given criteria. |
779 | * \tparam T The specified class type. |
780 | * \param pCriteria The given criteria. |
781 | * \return \c True if it disconnects all source objects successfully, \c false otherwise. |
782 | */ |
783 | template <class T> inline bool DisconnectAllSrcObject(const FbxCriteria& pCriteria){ return DisconnectAllSrcObject(FbxCriteria::ObjectType(T::ClassId) && pCriteria); } |
784 | |
785 | /** Returns the number of source objects of a specific class type with which this property connects. |
786 | * \tparam T The specified class type. |
787 | * \return The number of source objects of the specified class type with which this property connects. |
788 | */ |
789 | template <class T> inline int GetSrcObjectCount() const { return GetSrcObjectCount(FbxCriteria::ObjectType(T::ClassId)); } |
790 | |
791 | /** Returns the number of source objects which are of the specified class type and satisfy the given criteria with which this property connects. |
792 | * \tparam T The specified class type. |
793 | * \param pCriteria The given criteria. |
794 | * \return The number of source objects which are of the specified class type and satisfy the given criteria. |
795 | */ |
796 | template <class T> inline int GetSrcObjectCount(const FbxCriteria& pCriteria) const { return GetSrcObjectCount(FbxCriteria::ObjectType(T::ClassId) && pCriteria); } |
797 | |
798 | /** Returns the source object of the specified class type at the specified index. |
799 | * \tparam T The specified class type. |
800 | * \param pIndex The specified index whose default value is 0. |
801 | * \return The source object of a specified class type at the specified index, NULL if not found. |
802 | */ |
803 | template <class T> inline T* GetSrcObject(const int pIndex=0) const { return (T*)GetSrcObject(FbxCriteria::ObjectType(T::ClassId), pIndex); } |
804 | |
805 | /** Returns the source object which is of the specified class type and satisfies the given criteria at the specified index. |
806 | * \tparam T The specified class type. |
807 | * \param pCriteria The given criteria. |
808 | * \param pIndex The specified index whose default value is 0. |
809 | * \return The source object which is of the specified class type and satisfies the given criteria at the specified index, NULL if not found. |
810 | */ |
811 | template <class T> inline T* GetSrcObject(const FbxCriteria& pCriteria, const int pIndex=0) const { return (T*)GetSrcObject(FbxCriteria::ObjectType(T::ClassId) && pCriteria, pIndex); } |
812 | |
813 | /** Searches the source object with the specified name which is of the specified class type, starting with the specified index. |
814 | * \tparam T The specified class type. |
815 | * \param pName The object name. |
816 | * \param pStartIndex The start index. |
817 | * \return The source object with the name, NULL if not found. |
818 | */ |
819 | template <class T> inline T* FindSrcObject(const char* pName, const int pStartIndex=0) const { return (T*)FindSrcObject(FbxCriteria::ObjectType(T::ClassId), pName, pStartIndex); } |
820 | |
821 | /** Searches the source object with the specified name which is of the specified class type and satisfies the given criteria, starting with the specified index. |
822 | * \tparam T The specified class type. |
823 | * \param pCriteria The given criteria. |
824 | * \param pName The object name. |
825 | * \param pStartIndex The start index. |
826 | * \return The source object with the name, NULL if not found. |
827 | */ |
828 | template <class T> inline T* FindSrcObject(const FbxCriteria& pCriteria, const char* pName, const int pStartIndex=0) const { return (T*)FindSrcObject(FbxCriteria::ObjectType(T::ClassId) && pCriteria, pName, pStartIndex); } |
829 | |
830 | /** Connects this property to one destination object. |
831 | * \param pObject The destination object with which this property connects. |
832 | * \param pType The connection type between this property and the object. |
833 | * \return \c True on success, \c false otherwise. |
834 | */ |
835 | bool ConnectDstObject(FbxObject* pObject, FbxConnection::EType pType=FbxConnection::eNone); |
836 | |
837 | /** Judges whether this property connects with the destination object. |
838 | * \param pObject The destination object. |
839 | * \return \c True if this property connects with the destination object, \c false otherwise. |
840 | */ |
841 | bool IsConnectedDstObject(const FbxObject* pObject) const; |
842 | |
843 | /** Disconnects this property from the destination object. |
844 | * \param pObject The destination object from which this property disconnects from. |
845 | * \return \c True on success, \c false otherwise. |
846 | */ |
847 | bool DisconnectDstObject(FbxObject* pObject); |
848 | |
849 | /** Disconnects this property from all the destination objects. |
850 | * \return \c True if it disconnects all the destination objects successfully, \c false otherwise. |
851 | */ |
852 | bool DisconnectAllDstObject(); |
853 | |
854 | /** Disconnects this property from all the destination objects that satisfy given criteria. |
855 | * \param pCriteria The given criteria. |
856 | * \return \c True if it disconnects all the destination objects successfully, \c false otherwise. |
857 | */ |
858 | bool DisconnectAllDstObject(const FbxCriteria& pCriteria); |
859 | |
860 | /** Disconnects this property from all the destination objects of the specified class type. (Deprecated, please use DisconnectAllDstObject<Type>() instead.) |
861 | * \param pClassId The specified class type. |
862 | * \return \c True if it disconnects all the destination objects successfully, \c false otherwise. |
863 | */ |
864 | FBX_DEPRECATED bool DisconnectAllDstObject(const FbxClassId& pClassId); |
865 | |
866 | /** Returns the number of destination objects with which this property connects. |
867 | * \return The number of destination objects with which this property connects. |
868 | */ |
869 | int GetDstObjectCount() const; |
870 | |
871 | /** Returns the number of destination objects that satisfy the given criteria with which this property connects. |
872 | * \param pCriteria The given criteria. |
873 | * \return The number of destination objects that satisfy given criteria with which this property connects. |
874 | */ |
875 | int GetDstObjectCount(const FbxCriteria& pCriteria) const; |
876 | |
877 | /** Returns the number of destination objects of the specified class type with which this property connects. (Deprecated, please use GetDstObjectCount<Type>() instead.) |
878 | * \param pClassId The specified class type. |
879 | * \return The number of destination objects of the specified class type with which this property connects. |
880 | */ |
881 | FBX_DEPRECATED int GetDstObjectCount(const FbxClassId& pClassId) const; |
882 | |
883 | /** Returns the destination object at the specified index with which this property connects. |
884 | * \param pIndex The specified index whose default value is 0. |
885 | * \return The destination object at the specified index, NULL if not found. |
886 | */ |
887 | FbxObject* GetDstObject(const int pIndex=0) const; |
888 | |
889 | /** Returns the destination object that satisfies given criteria at the specified index with which this property connects. |
890 | * \param pCriteria The given criteria. |
891 | * \param pIndex The specified index whose default value is 0. |
892 | * \return The destination object that satisfies given criteria at the specified index, NULL if not found. |
893 | */ |
894 | FbxObject* GetDstObject(const FbxCriteria& pCriteria, const int pIndex=0) const; |
895 | |
896 | /** Returns the destination object of the specified class type at the specified index with which this property connects. (Deprecated, please use GetDstObject<Type>() instead.) |
897 | * \param pClassId The specified class type. |
898 | * \param pIndex The specified index whose default value is 0. |
899 | * \return The destination object of the specified class type at the specified index, NULL if not found. |
900 | */ |
901 | FBX_DEPRECATED FbxObject* GetDstObject(const FbxClassId& pClassId, const int pIndex=0) const; |
902 | |
903 | /** Searches the destination object with the specified name, starting with the specified index. |
904 | * \param pName The object name. |
905 | * \param pStartIndex The start index. |
906 | * \return The destination object with the name, NULL if not found. |
907 | */ |
908 | FbxObject* FindDstObject(const char* pName, const int pStartIndex=0) const; |
909 | |
910 | /** Searches the destination object with the specified name which satisfies the given criteria, starting with the specified index. |
911 | * \param pCriteria The given criteria. |
912 | * \param pName The object name. |
913 | * \param pStartIndex The start index. |
914 | * \return The destination object with the name, NULL if not found. |
915 | */ |
916 | FbxObject* FindDstObject(const FbxCriteria& pCriteria, const char* pName, const int pStartIndex=0) const; |
917 | |
918 | /** Searches the destination object with the specified name which is of the specified class type, starting with the specified index. (Deprecated, please use FindDstObject<Type>() instead.) |
919 | * \param pClassId The specified class type. |
920 | * \param pName The object name. |
921 | * \param pStartIndex The start index. |
922 | * \return The destination object with the name, NULL if not found. |
923 | */ |
924 | FBX_DEPRECATED FbxObject* FindDstObject(const FbxClassId& pClassId, const char* pName, const int pStartIndex=0) const; |
925 | |
926 | /** Disconnects this property from all the destination objects of the specified class type. |
927 | * \tparam T The specified class type. |
928 | * \return \c True if it disconnects all the destination objects successfully, \c false otherwise. |
929 | */ |
930 | template <class T> inline bool DisconnectAllDstObject(){ return DisconnectAllDstObject(FbxCriteria::ObjectType(T::ClassId)); } |
931 | |
932 | /** Disconnects this property from all the destination objects which are of the specified class type and satisfy the given criteria. |
933 | * \tparam T The specified class type. |
934 | * \param pCriteria The given criteria. |
935 | * \return \c True if it disconnects all the destination objects successfully, \c false otherwise. |
936 | */ |
937 | template <class T> inline bool DisconnectAllDstObject(const FbxCriteria& pCriteria){ return DisconnectAllDstObject(FbxCriteria::ObjectType(T::ClassId) && pCriteria); } |
938 | |
939 | /** Returns the number of destination objects of the specified class type with which this property connects. |
940 | * \tparam T The specified class type. |
941 | * \return The number of destination objects of the specified class type with which this property connects. |
942 | */ |
943 | template <class T> inline int GetDstObjectCount() const { return GetDstObjectCount(FbxCriteria::ObjectType(T::ClassId)); } |
944 | |
945 | /** Returns the number of destination objects which are of the specified class type and satisfy the given criteria with which this property connects. |
946 | * \tparam T The specified class type. |
947 | * \param pCriteria The given criteria. |
948 | * \return The number of destination objects which are of the specified class type and satisfy the given criteria with which this property connects. |
949 | */ |
950 | template <class T> inline int GetDstObjectCount(const FbxCriteria& pCriteria) const { return GetDstObjectCount(FbxCriteria::ObjectType(T::ClassId) && pCriteria); } |
951 | |
952 | /** Returns the destination object of the specified class type at the specified index with which this property connects. |
953 | * \tparam T The specified class type. |
954 | * \param pIndex The specified index whose default value is 0. |
955 | * \return The destination object of the specified class type at the specified index, NULL if not found. |
956 | */ |
957 | template <class T> inline T* GetDstObject(const int pIndex=0) const { return (T*)GetDstObject(FbxCriteria::ObjectType(T::ClassId), pIndex); } |
958 | |
959 | /** Returns the destination object which is of the specified class type and satisfies the given criteria at the specified index with which this property connects. |
960 | * \tparam T The specified class type. |
961 | * \param pCriteria The given criteria. |
962 | * \param pIndex The specified index whose default value is 0. |
963 | * \return The destination object which is of the specified class type and satisfies the given criteria at the specified index, NULL if not found. |
964 | */ |
965 | template <class T> inline T* GetDstObject(const FbxCriteria& pCriteria, const int pIndex=0) const { return (T*)GetDstObject(FbxCriteria::ObjectType(T::ClassId) && pCriteria, pIndex); } |
966 | |
967 | /** Searches the destination object with the specified name which is of the specified class type, starting with the specified index. |
968 | * \tparam T The specified class type. |
969 | * \param pName The object name. |
970 | * \param pStartIndex The start index. |
971 | * \return The source object with the name, NULL if not found. |
972 | */ |
973 | template <class T> inline T* FindDstObject(const char* pName, const int pStartIndex=0) const { return (T*)FindDstObject(FbxCriteria::ObjectType(T::ClassId), pName, pStartIndex); } |
974 | |
975 | /** Searches the destination object with the specified name which is of the specified class type and satisfies the given criteria, starting with the specified index. |
976 | * \tparam T The specified class type. |
977 | * \param pCriteria The given criteria. |
978 | * \param pName The object name. |
979 | * \param pStartIndex The start index. |
980 | * \return The source object with the name, NULL if not found. |
981 | */ |
982 | template <class T> inline T* FindDstObject(const FbxCriteria& pCriteria, const char* pName, const int pStartIndex=0) const { return (T*)FindDstObject(FbxCriteria::ObjectType(T::ClassId) && pCriteria, pName, pStartIndex); } |
983 | //@} |
984 | |
985 | /** |
986 | * \name General Property Connection and Relationship Management |
987 | */ |
988 | //@{ |
989 | // Properties |
990 | /** Connects this property to a source property. |
991 | * \param pProperty The source property with which this property connects. |
992 | * \return \c True on success, \c false otherwise. |
993 | */ |
994 | bool ConnectSrcProperty(const FbxProperty& pProperty); |
995 | |
996 | /** Judges whether this property connects with the specified source property. |
997 | * \param pProperty The specified source property. |
998 | * \return \c True if this property connects with the specified source property, \c false otherwise. |
999 | */ |
1000 | bool IsConnectedSrcProperty(const FbxProperty& pProperty); |
1001 | |
1002 | /** Disconnects this property from the specified source property. |
1003 | * \param pProperty The specified source property. |
1004 | * \return \c True on success, \c false otherwise. |
1005 | */ |
1006 | bool DisconnectSrcProperty(const FbxProperty& pProperty); |
1007 | |
1008 | /** Returns the number of source properties with which this property connects. |
1009 | * \return The number of source properties with which this property connects. |
1010 | */ |
1011 | int GetSrcPropertyCount() const; |
1012 | |
1013 | /** Connects this property to a destination property. |
1014 | * \param pProperty The destination property with which this property connects. |
1015 | * \return \c True on success, \c false otherwise. |
1016 | */ |
1017 | bool ConnectDstProperty(const FbxProperty& pProperty); |
1018 | |
1019 | /** Judges if this property connects with the specified destination property. |
1020 | * \param pProperty The specified destination property. |
1021 | * \return \c True if this property connects with the specified destination property, \c false otherwise. |
1022 | */ |
1023 | bool IsConnectedDstProperty(const FbxProperty& pProperty); |
1024 | |
1025 | /** Disconnects this property from the specified destination property. |
1026 | * \param pProperty The specified destination property. |
1027 | * \return \c True on success, \c false otherwise. |
1028 | */ |
1029 | bool DisconnectDstProperty(const FbxProperty& pProperty); |
1030 | |
1031 | /** Returns the number of destination properties with which this property connects. |
1032 | * \return The number of destination properties with which this property connects. |
1033 | */ |
1034 | int GetDstPropertyCount() const; |
1035 | |
1036 | //!Clears the connection cache of this property, this cache is used to store the connections that satisfy the given criteria. |
1037 | void ClearConnectCache(); |
1038 | |
1039 | /** Returns the source property at the specified index with which this property connects. |
1040 | * \param pIndex The specified index. |
1041 | * \return The source property at the specified index. |
1042 | */ |
1043 | FbxProperty GetSrcProperty(const int pIndex=0) const; |
1044 | |
1045 | /** Searches the source property with the specified name, starting with the specified index with which this property connects. |
1046 | * \param pName The specified property name. |
1047 | * \param pStartIndex The start index. |
1048 | * \return The source property with the specified name. |
1049 | */ |
1050 | FbxProperty FindSrcProperty(const char* pName, const int pStartIndex=0) const; |
1051 | |
1052 | /** Returns the destination property at the specified index with which this property connects. |
1053 | * \param pIndex The specified index. |
1054 | * \return The destination property at the specified index. |
1055 | */ |
1056 | FbxProperty GetDstProperty(const int pIndex=0) const; |
1057 | |
1058 | /** Searches the destination property with the specified name, starting with the specified index with which this property connects. |
1059 | * \param pName The specified property name. |
1060 | * \param pStartIndex The start index. |
1061 | * \return The destination property with the specified name. |
1062 | */ |
1063 | FbxProperty FindDstProperty(const char* pName, const int pStartIndex=0) const; |
1064 | //@} |
1065 | |
1066 | //! Hierarchical separator of properties. |
1067 | static const char* sHierarchicalSeparator; |
1068 | |
1069 | /***************************************************************************************************************************** |
1070 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
1071 | *****************************************************************************************************************************/ |
1072 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
1073 | protected: |
1074 | FbxProperty(FbxObject* pObject, const char* pName, const FbxDataType& pDataType=FbxDataType(), const char* pLabel="" ); |
1075 | FbxProperty(const FbxProperty& pParent, const char* pName, const FbxDataType& pDataType, const char* pLabel); |
1076 | |
1077 | bool Set(const void* pValue, const EFbxType& pValueType, bool pCheckForValueEquality=true); |
1078 | bool Get(void* pValue, const EFbxType& pValueType) const; |
1079 | |
1080 | bool NotifySetRequest(); |
1081 | bool NotifySet(); |
1082 | bool NotifyGet() const; |
1083 | |
1084 | private: |
1085 | inline void* Get() const { FBX_ASSERT_NOW("Cannot get property value as void!" ); return NULL; } |
1086 | inline bool Set(const void* &){ FBX_ASSERT_NOW("Cannot set property value as void!" ); return false; } |
1087 | |
1088 | bool ConnectSrc(const FbxProperty& pProperty, FbxConnection::EType pType=FbxConnection::eNone); |
1089 | bool DisconnectSrc(const FbxProperty& pProperty); |
1090 | bool DisconnectAllSrc(); |
1091 | bool DisconnectAllSrc(const FbxCriteria& pCriteria); |
1092 | bool IsConnectedSrc(const FbxProperty& pProperty) const; |
1093 | int GetSrcCount() const; |
1094 | int GetSrcCount(const FbxCriteria& pCriteria) const; |
1095 | FbxProperty GetSrc(int pIndex=0) const; |
1096 | FbxProperty GetSrc(const FbxCriteria& pCriteria, int pIndex=0) const; |
1097 | FbxProperty FindSrc(const FbxCriteria& pCriteria, const char* pName, int pStartIndex=0) const; |
1098 | |
1099 | bool ConnectDst(const FbxProperty& pProperty, FbxConnection::EType pType=FbxConnection::eNone); |
1100 | bool DisconnectDst(const FbxProperty& pProperty); |
1101 | bool DisconnectAllDst(); |
1102 | bool DisconnectAllDst(const FbxCriteria& pCriteria); |
1103 | bool IsConnectedDst(const FbxProperty& pProperty) const; |
1104 | int GetDstCount() const; |
1105 | int GetDstCount(const FbxCriteria& pCriteria) const; |
1106 | FbxProperty GetDst(int pIndex=0) const; |
1107 | FbxProperty GetDst(const FbxCriteria& pCriteria, int pIndex=0) const; |
1108 | FbxProperty FindDst(const FbxCriteria& pCriteria, const char* pName, int pStartIndex=0) const; |
1109 | |
1110 | mutable FbxPropertyHandle mPropertyHandle; |
1111 | |
1112 | friend class FbxObject; |
1113 | friend class FbxIOSettings; |
1114 | friend class FbxBindingOperator; |
1115 | friend class FbxAnimEvalClassic; |
1116 | friend void FbxMarkObject(FbxObject* pObject, FbxMap<FbxObject*, int>& pObjectDstDisconnectCount, FbxSet<FbxObject*>& pObjectsToDeleted, FbxArray<FbxObject*>& pObjectToDeletedInSequence); |
1117 | friend void FbxCleanUpConnectionsAtDestructionBoundary(FbxScene* pObject, FbxArray<FbxObject*>& pObjectToDeletedInSequence); |
1118 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
1119 | }; |
1120 | |
1121 | /** \brief This template class is used to contain user properties of specific data types. |
1122 | * \nosubgrouping |
1123 | */ |
1124 | template <class T> class FbxPropertyT : public FbxProperty |
1125 | { |
1126 | public: |
1127 | /** |
1128 | * \name Static initialization. |
1129 | */ |
1130 | //@{ |
1131 | /** Creates a property and initializes it using a specific value and flag. |
1132 | * \param pObject The object that contains this property. |
1133 | * \param pName The name of the property. |
1134 | * \param pValue The value of the property. |
1135 | * \param pForceSet If \c true, the value is forcibly set, if \c false the value is not set when it equals the default value. |
1136 | * \param pFlags The property flag. |
1137 | */ |
1138 | FbxProperty& StaticInit(FbxObject* pObject, const char* pName, const T& pValue, bool pForceSet, FbxPropertyFlags::EFlags pFlags=FbxPropertyFlags::eNone) |
1139 | { |
1140 | return StaticInit(pObject, pName, FbxGetDataTypeFromEnum(FbxTypeOf(*((T*)0))), pValue, pForceSet, pFlags); |
1141 | } |
1142 | |
1143 | /** Creates a property and initializes it using a specific value and flag. |
1144 | * \param pObject The object that contains this property. |
1145 | * \param pName The name of the property. |
1146 | * \param pDataType The property data type. |
1147 | * \param pValue The property value. |
1148 | * \param pForceSet If \c true, the value is forcibly set, if \c false the value is not set when it equals the default value. |
1149 | * \param pFlags The property flag. |
1150 | */ |
1151 | FbxProperty& StaticInit(FbxObject* pObject, const char* pName, const FbxDataType& pDataType, const T& pValue, bool pForceSet, FbxPropertyFlags::EFlags pFlags=FbxPropertyFlags::eNone) |
1152 | { |
1153 | bool lWasFound = false; |
1154 | *this = Create(pObject, pDataType, pName, "" , true, &lWasFound); |
1155 | if( pForceSet || !lWasFound ) |
1156 | { |
1157 | ModifyFlag(pFlags, true); // modify the flags before we set the value |
1158 | FbxProperty::Set(&pValue, FbxTypeOf(pValue), false); |
1159 | } |
1160 | ModifyFlag(FbxPropertyFlags::eStatic, true); |
1161 | return *this; |
1162 | } |
1163 | |
1164 | /** Creates a property and initializes it using a specific value and flag. |
1165 | * \param pCompound The parent property of this property. |
1166 | * \param pName The name of the property. |
1167 | * \param pDataType The property data type. |
1168 | * \param pValue The property value. |
1169 | * \param pForceSet If \c true, the value is forcibly set, if \c false the value is not set when it equals to the default value. |
1170 | * \param pFlags The property flag. |
1171 | */ |
1172 | FbxProperty& StaticInit(FbxProperty pCompound, const char* pName, const FbxDataType& pDataType, const T& pValue, bool pForceSet=true, FbxPropertyFlags::EFlags pFlags=FbxPropertyFlags::eNone) |
1173 | { |
1174 | bool lWasFound = false; |
1175 | *this = Create(pCompound, pDataType, pName, "" , true, &lWasFound); |
1176 | if( pForceSet || !lWasFound ) |
1177 | { |
1178 | ModifyFlag(pFlags, true); // modify the flags before we set the value |
1179 | FbxProperty::Set(&pValue, FbxTypeOf(pValue), false); |
1180 | } |
1181 | ModifyFlag(FbxPropertyFlags::eStatic, true); |
1182 | return *this; |
1183 | } |
1184 | //@} |
1185 | |
1186 | /** \name Value Management */ |
1187 | //@{ |
1188 | /** Assignment function |
1189 | * \param pValue The value assigned to this property. |
1190 | * \return This property. */ |
1191 | FbxPropertyT& Set(const T& pValue){ FbxProperty::Set(&pValue, FbxTypeOf(pValue)); return *this; } |
1192 | |
1193 | /** Retrieve function |
1194 | * \return The value of the property. */ |
1195 | T Get() const { T lValue; FbxProperty::Get(&lValue, FbxTypeOf(lValue)); return lValue; } |
1196 | |
1197 | /** Assignment operator |
1198 | * \param pValue The value of type T assigned to this property. |
1199 | * \return This property. */ |
1200 | FbxPropertyT& operator=(const T& pValue){ return Set(pValue); } |
1201 | |
1202 | /** Type cast operator |
1203 | * \return The value of the property of type T. */ |
1204 | operator T() const { return Get(); } |
1205 | //@} |
1206 | |
1207 | /** \name Animation Evaluation */ |
1208 | //@{ |
1209 | /** Evaluate the value of a property if it has animation and return the result. |
1210 | * \param pTime The time used for evaluate. |
1211 | * \param pForceEval Force the evaluator to refresh the evaluation state cache even if its already up-to-date. |
1212 | * \return The property value at the specified time. */ |
1213 | T EvaluateValue(const FbxTime& pTime=FBXSDK_TIME_INFINITE, bool pForceEval=false) |
1214 | { |
1215 | return GetAnimationEvaluator()-> template GetPropertyValue<T>(*this, pTime, pForceEval); |
1216 | } |
1217 | //@} |
1218 | |
1219 | /***************************************************************************************************************************** |
1220 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
1221 | *****************************************************************************************************************************/ |
1222 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
1223 | FbxPropertyT() : FbxProperty(){} |
1224 | FbxPropertyT(const FbxProperty& pProperty) : FbxProperty(pProperty){} |
1225 | ~FbxPropertyT(){} |
1226 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
1227 | }; |
1228 | |
1229 | /***************************************************************************************************************************** |
1230 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
1231 | *****************************************************************************************************************************/ |
1232 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
1233 | template <> class FbxPropertyT<FbxReference> : public FbxProperty |
1234 | { |
1235 | public: |
1236 | FbxPropertyT() : FbxProperty(){} |
1237 | FbxPropertyT(const FbxProperty& pProperty) : FbxProperty(pProperty){} |
1238 | ~FbxPropertyT(){} |
1239 | |
1240 | const FbxProperty& StaticInit(FbxObject* pObject, const char* pName, const FbxReference& pValue, bool pForceSet, FbxPropertyFlags::EFlags pFlags=FbxPropertyFlags::eNone) |
1241 | { |
1242 | return StaticInit(pObject, pName, FbxGetDataTypeFromEnum(FbxTypeOf(*((FbxReference*)0))), pValue, pForceSet, pFlags); |
1243 | } |
1244 | |
1245 | const FbxProperty& StaticInit(FbxObject* pObject, const char* pName, const FbxDataType& pDataType, const FbxReference& pValue, bool pForceSet, FbxPropertyFlags::EFlags pFlags=FbxPropertyFlags::eNone) |
1246 | { |
1247 | bool lWasFound = false; |
1248 | *this = Create(pObject, pDataType, pName, "" , true, &lWasFound); |
1249 | if( pForceSet || !lWasFound ) |
1250 | { |
1251 | ModifyFlag(pFlags, true); // modify the flags before we set the value |
1252 | Set(pValue); // since we will trigger callbacks in there! |
1253 | } |
1254 | ModifyFlag(FbxPropertyFlags::eStatic, true); |
1255 | return *this; |
1256 | } |
1257 | |
1258 | FbxReference Get() const |
1259 | { |
1260 | FbxProperty::NotifyGet(); |
1261 | return GetSrcObject(); |
1262 | } |
1263 | |
1264 | FbxPropertyT& Set(const FbxReference& pValue) |
1265 | { |
1266 | if( FbxProperty::NotifySetRequest() ) |
1267 | { |
1268 | DisconnectAllSrcObject(); |
1269 | if( ConnectSrcObject(pValue) ) |
1270 | { |
1271 | FbxProperty::SetValueInheritType(FbxPropertyFlags::eOverride); |
1272 | FbxProperty::NotifySet(); |
1273 | } |
1274 | } |
1275 | return *this; |
1276 | } |
1277 | |
1278 | operator FbxReference() const |
1279 | { |
1280 | return Get(); |
1281 | } |
1282 | |
1283 | FbxPropertyT& operator=(const FbxReference& pValue) |
1284 | { |
1285 | return Set(pValue); |
1286 | } |
1287 | }; |
1288 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
1289 | |
1290 | #include <fbxsdk/fbxsdk_nsend.h> |
1291 | |
1292 | #endif /* _FBXSDK_CORE_PROPERTY_H_ */ |
1293 | |