fbxdocument.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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 fbxdocument.h
  9. #ifndef _FBXSDK_SCENE_DOCUMENT_H_
  10. #define _FBXSDK_SCENE_DOCUMENT_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/scene/fbxcollection.h>
  13. #include <fbxsdk/fbxsdk_nsbegin.h>
  14. class FbxStatus;
  15. class FbxTakeInfo;
  16. class FbxPeripheral;
  17. class FbxDocumentInfo;
  18. /** FbxDocument is a base class for FbxScene and FbxLibrary classes.
  19. * A document is a collection (FbxCollection) of objects (FbxObject), called the root member objects.
  20. * This is because these objects each form the root of an object graph. The manager (FbxManager) has access to all
  21. * documents, scenes and libraries.
  22. *
  23. * A document can be contained in another document, thus, a hierarchy of documents
  24. * can be built. The root of all documents is simply called the root document.
  25. *
  26. * A document manages animation stacks (FbxAnimStack). It also provides access to animation stack information (FbxTakeInfo).
  27. *
  28. * A document carries information in its FbxDocumentInfo.
  29. *
  30. * Documents manage peripherals to load and unload objects (see class FbxPeripheral),
  31. * as well as references to other objects or documents.
  32. *
  33. * Error management is also available.
  34. *
  35. * \nosubgrouping
  36. */
  37. class FBXSDK_DLL FbxDocument : public FbxCollection
  38. {
  39. FBXSDK_OBJECT_DECLARE(FbxDocument, FbxCollection);
  40. public:
  41. /**
  42. * \name Properties
  43. */
  44. //@{
  45. FbxPropertyT<FbxReference> Roots;
  46. //@}
  47. /**
  48. * \name Document Member Manager
  49. */
  50. //@{
  51. //! Remove document members and restore default settings.
  52. virtual void Clear();
  53. /** Add a member object and connect it to Roots.
  54. * \param pMember Object to add to the document.
  55. */
  56. inline void AddRootMember(FbxObject* pMember){ AddMember(pMember); Roots.ConnectSrcObject(pMember); }
  57. /** Remove a member object from the document.
  58. * \param pMember Object to remove from the document.
  59. */
  60. inline void RootRootRemoveMember(FbxObject* pMember){ RemoveMember(pMember); Roots.DisconnectSrcObject(pMember); }
  61. /** Find a member object in the document, that has the given type and name.
  62. * \param pName Member name. */
  63. template <class T> inline T* FindRootMember(char* pName){ return Roots.FindSrcObject<T>(pName); }
  64. //! Return the number of objects in the document.
  65. inline int GetRootMemberCount () const { return Roots.GetSrcObjectCount(); }
  66. /** Return the number of objects of class T in the document.
  67. * \return The number of objects of class T in the document. */
  68. template <class T> inline int GetRootMemberCount() const { return Roots.GetSrcObjectCount<T>(); }
  69. /** Return the number of objects of the document that satisfy the given criteria.
  70. * \param pCriteria Criteria for selecting objects.
  71. * \return The number of objects satisfying the given criteria.
  72. */
  73. int GetRootMemberCount(FbxCriteria pCriteria) const;
  74. /** Return the member of the document at given index.
  75. * \param pIndex Selection index.
  76. */
  77. inline FbxObject* GetRootMember(int pIndex=0) const { return Roots.GetSrcObject(pIndex); }
  78. /** Return the member of class T of the document at given index.
  79. * \param pIndex Selection index. */
  80. template <class T> inline T* GetRootMember(int pIndex=0) const { return Roots.GetSrcObject<T>(pIndex); }
  81. /** Return the document member which satisfies given criteria, for given index.
  82. * \param pCriteria Criteria for selecting objects.
  83. * \param pIndex Selection index.
  84. */
  85. FbxObject* GetRootMember(FbxCriteria pCriteria, int pIndex=0) const;
  86. /** Is an object part of the document.
  87. * \param pMember Queried object.
  88. * \return \c true if pMember is an object part of the document, \c false otherwise.
  89. */
  90. virtual bool IsRootMember(FbxObject* pMember) const;
  91. //@}
  92. /**
  93. * \name Document information
  94. */
  95. //@{
  96. /** Get the document information.
  97. * \return Pointer to the document information object.
  98. */
  99. FbxDocumentInfo* GetDocumentInfo() const;
  100. /** Set the document information.
  101. * \param pSceneInfo Pointer to the document information object.
  102. */
  103. void SetDocumentInfo(FbxDocumentInfo* pSceneInfo);
  104. //@}
  105. /**
  106. * \name Offloading management
  107. *
  108. * Documents manage peripherals to load and unload objects (see
  109. * class FbxPeripheral). A peripheral manipulates the content
  110. * of an object. For instance, a peripheral can load the connections
  111. * of an object on demand.
  112. *
  113. * The document does not own the peripheral therefore
  114. * it will not attempt to delete it at destruction time. Cloning
  115. * the document will share the pointer to the peripheral across
  116. * the cloned objects. The assignment operator has a similar behavior.
  117. */
  118. //@{
  119. /** Set the current peripheral to be used to load or unload objects from this document.
  120. * \param pPeripheral The peripheral to be set.
  121. */
  122. void SetPeripheral(FbxPeripheral* pPeripheral);
  123. /** Retrieve the current peripheral of the document.
  124. * \return Current peripheral.
  125. */
  126. virtual FbxPeripheral* GetPeripheral();
  127. /** Unload all the unloadable objects contained in the document using the currently set peripheral.
  128. * \param pStatus The FbxStatus object to hold error codes.
  129. * \return The number of objects that the document has been able to unload.
  130. */
  131. int UnloadContent(FbxStatus* pStatus = NULL);
  132. /** Load all the objects contained in the document with the data from the currently set peripheral.
  133. * \param pStatus The FbxStatus object to hold error codes.
  134. * \return The number of loaded objects.
  135. */
  136. int LoadContent(FbxStatus* pStatus = NULL);
  137. //@}
  138. /**
  139. * \name Referencing management
  140. */
  141. //@{
  142. /**
  143. * Fills an array of pointers to documents that reference objects in this document.
  144. *
  145. * \param pReferencingDocuments Array of pointers to documents.
  146. * \returns Number of documents that reference objects in this document.
  147. */
  148. int GetReferencingDocuments(FbxArray<FbxDocument*>& pReferencingDocuments) const;
  149. /**
  150. * Fills an array of pointers to objects in a given document (pFromDoc)
  151. * that reference objects in this document.
  152. *
  153. * \param pFromDoc Pointer to the document containing referencing objects.
  154. * \param pReferencingObjects Array of pointers to referencing objects.
  155. * \returns Number of objects that reference objects in this document.
  156. */
  157. int GetReferencingObjects(const FbxDocument* pFromDoc, FbxArray<FbxObject*>& pReferencingObjects) const;
  158. /**
  159. * Fills an array of pointers to documents that are referenced by objects in this document.
  160. *
  161. * \param pReferencedDocuments Array of pointers to documents.
  162. * \returns Number of documents that are referenced by objects in this document.
  163. */
  164. int GetReferencedDocuments(FbxArray<FbxDocument*>& pReferencedDocuments) const;
  165. /**
  166. * Fills an array of pointers to objects in a given document (pToDoc)
  167. * that are referenced by objects in this document.
  168. *
  169. * \param pToDoc Pointer to the document containing referenced objects.
  170. * \param pReferencedObjects Array of pointers to referenced objects.
  171. * \returns Number of objects that are referenced by objects in this document.
  172. */
  173. int GetReferencedObjects(const FbxDocument* pToDoc, FbxArray<FbxObject*>& pReferencedObjects) const;
  174. /**
  175. * Gets the path string to the root document, if the current document is contained in another document.
  176. \returns Path to the root document.
  177. */
  178. FbxString GetPathToRootDocument(void) const;
  179. /**
  180. * Gets the document path to the root document as an array of documents, if the current document is contained in another document.
  181. * \param pDocumentPath Array of FbxDocument to store the document path.
  182. * \param pFirstCall Recursive flag: always use pFirstCall = \c true.
  183. */
  184. void GetDocumentPathToRootDocument(FbxArray<FbxDocument*>& pDocumentPath, bool pFirstCall = true) const;
  185. /**
  186. * Tells if this document is a root document.
  187. \return \c false if the current document is contained in another document, \c true otherwise.
  188. */
  189. bool IsARootDocument(void) { return (NULL == GetDocument()); }
  190. //@}
  191. /**
  192. * \name Animation Stack Management
  193. * \remarks Animation stacks replaces the deprecated takes.
  194. */
  195. //@{
  196. /** Holds the name of the FbxAnimStack that the application uses for animation in this document.
  197. */
  198. FbxPropertyT<FbxString> ActiveAnimStackName;
  199. /** Adds a new animation stack object to this document.
  200. * In case of error, FbxDocument::GetLastErrorID() will return
  201. * \c eTakeError.
  202. * \param pName Animation stack name.
  203. * \param pStatus The FbxStatus object to hold error codes.
  204. * \return \c true if a new FbxAnimStack has been successfully created,
  205. * \c false if an error occurred or if the specified name defines
  206. * a FbxAnimStack that already exists in the document.
  207. */
  208. bool CreateAnimStack(const char* pName, FbxStatus* pStatus = NULL);
  209. /** Destroy the animation stack object identified by pName from this document.
  210. * \param pName Name of the animation stack to be deleted.
  211. * \return \c true if the FbxAnimStack has been destroyed and \c false otherwise.
  212. */
  213. bool RemoveAnimStack(const char* pName);
  214. /** Fill a string array with all existing animation stack names.
  215. * The array of string is cleared before it is used
  216. * \param pNameArray An array of string objects.
  217. */
  218. void FillAnimStackNameArray(FbxArray<FbxString*>& pNameArray);
  219. //@}
  220. /**
  221. * \name Animation Stack Information Management
  222. * \remark Although takes are deprecated, class FbxTakeInfo is not deprecated and
  223. * now contains animation stack information.
  224. */
  225. //@{
  226. /** Set information about an animation stack.
  227. * \param pTakeInfo Animation stack information. Field FbxTakeInfo::mName specifies
  228. * the targeted animation stack.
  229. * \return \c true if animation stack is found with this name, and if information is set.
  230. */
  231. bool SetTakeInfo(const FbxTakeInfo& pTakeInfo);
  232. /** Get information about an animation stack.
  233. * \param pTakeName Name of the targeted animation stack.
  234. * \return Animation stack information, or \c NULL if animation stack isn't found or
  235. * has no information set for this document.
  236. */
  237. FbxTakeInfo* GetTakeInfo(const FbxString& pTakeName) const;
  238. //@}
  239. /*****************************************************************************************************************************
  240. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  241. *****************************************************************************************************************************/
  242. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  243. virtual FbxObject& Copy(const FbxObject& pObject);
  244. virtual void Compact();
  245. void ConnectVideos();
  246. protected:
  247. virtual void Construct(const FbxObject* pFrom);
  248. virtual void ConstructProperties(bool pForceSet);
  249. virtual void Destruct(bool pRecursive);
  250. virtual bool ConnectNotify(const FbxConnectEvent& pEvent);
  251. virtual void SetDocument(FbxDocument* pDocument);
  252. bool FindTakeName(const FbxString& pTakeName);
  253. FbxArray<FbxTakeInfo*> mTakeInfoArray;
  254. private:
  255. FbxPeripheral* mPeripheral;
  256. FbxDocumentInfo* mDocumentInfo;
  257. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  258. };
  259. #include <fbxsdk/fbxsdk_nsend.h>
  260. #endif /* _FBXSDK_SCENE_DOCUMENT_H_ */