fbxreaderfbx6.h 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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 fbxreaderfbx6.h
  9. #ifndef _FBXSDK_FILEIO_FBX_READER_FBX6_H_
  10. #define _FBXSDK_FILEIO_FBX_READER_FBX6_H_
  11. #include <fbxsdk.h>
  12. #include <fbxsdk/fbxsdk_nsbegin.h>
  13. class FbxAnimStack;
  14. class FbxAnimLayer;
  15. class Fbx6ObjectTypeInfo;
  16. class Fbx6TypeReadReferences;
  17. /** \brief Helper class to merge Class root property templates.
  18. * Add class id and object to the template and search object by
  19. * class id.
  20. */
  21. class Fbx6ClassTemplateMap
  22. {
  23. public:
  24. /** Constructor
  25. *
  26. */
  27. Fbx6ClassTemplateMap();
  28. /** Destructor
  29. *
  30. */
  31. ~Fbx6ClassTemplateMap();
  32. // Fbx6ClassTemplateMap will own this template object.
  33. /** Add the template object to template map
  34. * \param pId Class Id
  35. * \param pTemplateObject template object
  36. * \return if the object is successfully added return \c true, otherwise return \c false.
  37. */
  38. bool AddClassId( FbxClassId pId, FbxObject* pTemplateObject );
  39. /** Merge the properties of FbxObject with the object with the same class id
  40. * \param pObject The FbxObject to merge
  41. * \return if the object is merged return \c true, otherwise return \c false.
  42. */
  43. bool MergeWithTemplate( FbxObject* pObject ) const;
  44. /** Delete all FbxObject in template map
  45. *
  46. */
  47. void Clear();
  48. private:
  49. typedef FbxMap< FbxClassId, FbxObject*, FbxClassIdCompare > MapType;
  50. MapType mClassMap;
  51. /** Whether the property is modified
  52. * \param lProp The property to check
  53. * \return If the property has been modified return \c true, otherwise return \c false
  54. */
  55. bool HasModifiedFlags(FbxProperty lProp) const;
  56. inline FbxPropertyFlags::EFlags IndexToFlag( int i ) const { return static_cast<FbxPropertyFlags::EFlags>(1 << i); }
  57. };
  58. /** \brief This class is the FBX v6 reader.
  59. * The reader provide you the ability to read the global settings, objects and animation information from file.
  60. *
  61. */
  62. class FbxReaderFbx6 : public FbxReader
  63. {
  64. public:
  65. /** Constructor
  66. * \param pManager the FbxManager Object
  67. * \param pImporter the FbxImporter to import the SDK objects
  68. * \param pID id for current reader
  69. * \param pStatus the FbxStatus object to hold error codes
  70. */
  71. FbxReaderFbx6(FbxManager& pManager, FbxImporter& pImporter, int pID, FbxStatus& pStatus);
  72. /** Destructor
  73. *
  74. */
  75. virtual ~FbxReaderFbx6();
  76. /** Open file with certain EFileOpenSpecialFlags
  77. * \param pFileName name of the File to open
  78. * \param pFlags the EFileOpenSpecialFlags to open with
  79. * \return if the file is open successfully return true, otherwise return false
  80. */
  81. virtual bool FileOpen(char* pFileName, EFileOpenSpecialFlags pFlags);
  82. /** Open file with default flag
  83. * \param pFileName name of the File to open
  84. * \return if the file is open successfully return \c true, otherwise return \c false
  85. */
  86. virtual bool FileOpen(char* pFileName);
  87. /** Open file with FbxFile handle
  88. * \param pFile the FbxFile handle
  89. * \return if the file is open successfully return \c true, otherwise return \c false
  90. */
  91. virtual bool FileOpen(FbxFile * pFile);
  92. /** Open file from stream
  93. */
  94. virtual bool FileOpen(FbxStream * pStream, void* pStreamData);
  95. /** Close the file stream
  96. * \return if the file is closed successfully return \c true, otherwise return \c false
  97. */
  98. virtual bool FileClose();
  99. /** Check whether the file stream is open.
  100. * \return if the file stream is open return \c true, otherwise return \c false.
  101. */
  102. virtual bool IsFileOpen();
  103. /** \enum EImportMode File import mode.
  104. *
  105. */
  106. typedef enum
  107. {
  108. eASCII, /**< Plain text mode */
  109. eBINARY, /**< Binary mode */
  110. eENCRYPTED /**< Encrypted mode */
  111. } EImportMode;
  112. /** Get current Import mode
  113. * \return return the EImportMode value
  114. */
  115. EImportMode GetImportMode();
  116. /** Get file version
  117. * \param pMajor Major version
  118. * \param pMinor Minor version
  119. * \param pRevision Revision version
  120. */
  121. virtual void GetVersion(int& pMajor, int& pMinor, int& pRevision);
  122. /** Get axis system information from file
  123. * \param pAxisSystem axis system in file
  124. * \param pSystemUnits system unit in file
  125. * \return if either pAxisSystem or pSystemUnits is \c NULL return \c false, otherwise return \c true.
  126. */
  127. virtual bool GetAxisInfo(FbxAxisSystem* pAxisSystem, FbxSystemUnit* pSystemUnits);
  128. /** Get FBX file time mode read from GlobalSettings in FBX 6.n and FBX 7.n
  129. * \param pTimeMode ref to a FbxTime::EMode enum
  130. * \return \c true on success, \c false otherwise.
  131. * \remarks This function must be called after FbxImporter::Initialize().
  132. * Can be used for statistics (via GlobalSettings) before loading the whole scene from the file.
  133. */
  134. virtual bool GetFrameRate(FbxTime::EMode &pTimeMode);
  135. /** Get the statistics from file
  136. * \param pStats statistics in file
  137. * \return if fetching statistics is successfully return \c true, otherwise return \c false.
  138. */
  139. virtual bool GetStatistics(FbxStatistics* pStats);
  140. /** Get the file stream options
  141. * \param pParseFileAsNeeded Whether to parse file as read options
  142. * \return true on success, otherwise return false.
  143. */
  144. virtual bool GetReadOptions(bool pParseFileAsNeeded = true);
  145. /** Read file with stream options
  146. * \param pDocument FbxDocument to store the file data
  147. * \return if fetching statistics is successful return \c true, otherwise return \c false.
  148. */
  149. virtual bool Read(FbxDocument *pDocument);
  150. /** Get the file options
  151. * \param pFbx file object to read options
  152. * \param pParseFileAsNeeded Whether to parse file as read options
  153. * \return true on success, otherwise return false.
  154. */
  155. virtual bool GetReadOptions(FbxIO* pFbx, bool pParseFileAsNeeded = true);
  156. /** Read file with stream options
  157. * \param pDocument FbxDocument to store the file data
  158. * \param pFbx file object to read from
  159. * \return if reading the file is successful return \c true, otherwise return \c false.
  160. */
  161. virtual bool Read(FbxDocument *pDocument, FbxIO* pFbx);
  162. /** Read all the properties and flags
  163. * \param pParams settings to assign properties and flags
  164. */
  165. virtual void PluginReadParameters(FbxObject& pParams);
  166. /** Returns the scene info from the file.
  167. * \return The pointer to file scene info defined by this reader.
  168. */
  169. virtual FbxDocumentInfo* GetSceneInfo() { return mSceneInfo; }
  170. /** Returns the pointer to the list of TakeInfo from the file.
  171. * \return NULL
  172. */
  173. virtual FbxArray<FbxTakeInfo*>* GetTakeInfo() { return &mTakeInfo; }
  174. /** Pass a progress handler to the reader
  175. * \param pProgress FbxProgress to store the progress information.
  176. */
  177. virtual void SetProgressHandler(FbxProgress *pProgress);
  178. virtual void SetEmbeddingExtractionFolder(const char* pExtractFolder);
  179. virtual bool SupportsStreams() const { return true; }
  180. private:
  181. /** Read scene information
  182. * \return A pointer of document info. Return \c NULL if any error exist
  183. */
  184. FbxDocumentInfo* ReadSceneInfo();
  185. /** Read scene information by type
  186. * \param pType the type to read
  187. * \return A pointer of document info. Return \c NULL if any error exist
  188. */
  189. FbxDocumentInfo* ReadSceneInfo(FbxString& pType);
  190. /** Write scene information
  191. *
  192. */
  193. void WriteSceneInfo(FbxDocumentInfo*);
  194. /** Write thumbnail
  195. *
  196. */
  197. bool WriteThumbnail(FbxThumbnail*);
  198. /**
  199. * \name FBX File sections
  200. */
  201. //@{
  202. /** Create generic object and connect with FbxIO document
  203. * \param pDocument FbxDocument to connect with the generic object
  204. * \param pObjectType type of generic object
  205. * \param pObjectSubType Subtype of generic object
  206. * \param pObjectName Name of generic object
  207. * \param pFlags Object flag
  208. * \return A pointer of the generic object. Return \c NULL if creation fails.
  209. */
  210. FbxObject* CreateGenericObject(FbxDocument *pDocument, char* pObjectType, char* pObjectSubType, char* pObjectName, FbxObject::EObjectFlag pFlags=FbxObject::eSavable);
  211. /** Read description section and assign the document name
  212. * \param pDocument Document to read
  213. * \param pDocumentName Document name to assign
  214. * \return if reading description section is successful return \c true, otherwise return \c false.
  215. */
  216. bool ReadDescriptionSection(FbxDocument *pDocument, FbxString& pDocumentName);
  217. /** Read reference section and fill the external references
  218. * \param pDocument Document to read
  219. * \param pDocReferences External references to fill
  220. * \return if reading reference section is successful return \c true, otherwise return \c false.
  221. */
  222. bool ReadReferenceSection(FbxDocument *pDocument, Fbx6TypeReadReferences& pDocReferences);
  223. /** Read definition section and fill object type info array
  224. * \param pDocument Document to read
  225. * \param pObjectContent Object type info array to fill
  226. * \return if reading definition section is successful return \c true, otherwise return \c false.
  227. */
  228. bool ReadDefinitionSection(FbxDocument *pDocument, FbxArray<Fbx6ObjectTypeInfo*>& pObjectContent );
  229. /** Read object section and fill object type info array and external reference
  230. * \param pDocument Document to read
  231. * \param pObjectContent Object type info array to fill
  232. * \param pDocReferences External references to fill
  233. * \return if reading object section is successful return \c true, otherwise return \c false.
  234. */
  235. bool ReadObjectSection(FbxDocument *pDocument, FbxArray<Fbx6ObjectTypeInfo*>& pObjectContent, Fbx6TypeReadReferences& pDocReferences );
  236. /** Read object information from document
  237. * \param pDocument Document to read
  238. * \param pObjectType Object type to assign
  239. * \param pObjectSubType Object subtype to assign
  240. * \param pObjectName Object Name
  241. * \param pObjectUniqueId Object unique id
  242. * \param pReferencedObject Reference object
  243. * \param pDocReferences External reference
  244. * \return if reading object is successful return \c true, otherwise return \c false.
  245. */
  246. bool ReadObject(FbxDocument *pDocument, FbxString& pObjectType, FbxString& pObjectSubType, FbxString& pObjectName, FbxString& pObjectUniqueId, FbxObject* pReferencedObject, Fbx6TypeReadReferences& pDocReferences);
  247. /** Read the connection section from document
  248. * \param pDocument Document to read
  249. * \return if reading connection section is successful return \c true, otherwise return \c false.
  250. */
  251. bool ReadConnectionSection(FbxDocument *pDocument );
  252. //@}
  253. /**
  254. * \name Takes and animation
  255. */
  256. //@{
  257. /** Read animation from document
  258. * \param pDocument Document to read
  259. * \return if reading animation is successful return \c true, otherwise return \c false.
  260. */
  261. bool ReadDocumentAnimation(FbxDocument *pDocument);
  262. /** Read object animation from file object
  263. * \param pFileObject File object handle
  264. * \param pNode Fill this node with animation
  265. * \param pAnimStack Animation stack to read from
  266. * \param pExceptionFlag Exception flag
  267. */
  268. void ReadObjectAnimation(FbxIO& pFileObject, FbxObject* pNode, FbxAnimStack& pAnimStack, int pExceptionFlag);
  269. /** Read property animation from file object
  270. * \param pFileObject File object handle
  271. * \param pProp Fill the property with animation
  272. * \param pAnimStack Animation stack to read from
  273. */
  274. void ReadPropertyAnimation(FbxIO& pFileObject, FbxProperty* pProp, FbxAnimStack& pAnimStack);
  275. /** Read take animation from fbx scene
  276. * \param pScene Scene to read animation
  277. * \param pTakeInfo Take info to read from
  278. * \remarks This function will allocate the corresponding FbxAnimStack with the base animation layer.
  279. */
  280. bool ReadTakeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
  281. /** Read node animation from file
  282. * \param pFileObject File object to read
  283. * \param pScene Scene to read animation
  284. * \param pAnimStack The animation stack to read from
  285. * \param pTakeInfo Take info to read from
  286. */
  287. bool ReadNodeAnimation(FbxIO& pFileObject, FbxScene& pScene, FbxAnimStack& pAnimStack, FbxTakeInfo* pTakeInfo);
  288. /** Read layer information from file
  289. * \param pFileObject File object to read
  290. * \param pTakeInfo Take info to read from
  291. */
  292. void ReadLayers(FbxIO& pFileObject, FbxTakeInfo* pTakeInfo);
  293. /** Read time warps from file
  294. * \param pFileObject File object to read
  295. * \param pTimeWarpSet Time warp set to fill
  296. * \param pScene Scene holding the time warp curves.
  297. */
  298. void ReadTimeWarps(FbxIO& pFileObject, FbxMultiMap& pTimeWarpSet, FbxScene& pScene);
  299. /** Read thumbnail
  300. * \return A pointer of thumbnail. Return \c NULL if any error exist
  301. */
  302. FbxThumbnail* ReadThumbnail();
  303. /** Set time shift for node animation from take information
  304. * \param pScene Scene to read
  305. * \param pAnimStack The animation stack to modify
  306. * \param pTimeOffsetType A value from the FbxTakeInfo::EImportOffsetType enumeration that indicates the time shift offset type
  307. * \param pTimeOffset The time shift offset
  308. * \return if time shifting is successful return \c true, otherwise return \c false.
  309. */
  310. bool TimeShiftNodeAnimation(FbxScene& pScene, FbxAnimStack& pAnimStack, int pTimeOffsetType, FbxTime pTimeOffset);
  311. //@}
  312. /**
  313. * \name Camera switcher
  314. */
  315. //@{
  316. /** Read camera switcher from scene
  317. * \param pScene Scene to read from
  318. */
  319. void ReadCameraSwitcher(FbxScene& pScene);
  320. /** Fill camera switcher object with data
  321. * \param pCameraSwitcher Camera switcher to fill
  322. */
  323. bool ReadCameraSwitcher( FbxCameraSwitcher& pCameraSwitcher );
  324. /** Reorder camera switcher indices in the scene
  325. * \param pScene Scene to read from
  326. */
  327. void ReorderCameraSwitcherIndices(FbxScene& pScene);
  328. //@}
  329. /**
  330. * \name Global parameters
  331. */
  332. //@{
  333. /** Read global light settings from scene
  334. * \param pScene Scene to read from
  335. */
  336. void ReadGlobalLightSettings(FbxScene& pScene);
  337. /** Read global time settings from scene
  338. * \param pScene Scene to read from
  339. */
  340. void ReadGlobalTimeSettings(FbxScene& pScene);
  341. /** Read global camera settings from scene
  342. * \param pScene Scene to read from
  343. */
  344. void ReadGlobalCameraSettings(FbxScene& pScene);
  345. /** Read shadow plane from scene
  346. * \param pScene Scene to read from
  347. */
  348. void ReadShadowPlane(FbxScene& pScene);
  349. /** Read ambient color from scene
  350. * \param pScene Scene to read from
  351. */
  352. void ReadAmbientColor(FbxScene& pScene);
  353. /** Read fog option from scene
  354. * \param pScene Scene to read from
  355. */
  356. void ReadFogOption(FbxScene& pScene);
  357. //@}
  358. /**
  359. * \name Character
  360. */
  361. //@{
  362. /** Read character information from file
  363. * \param pCharacter Character object to fill
  364. * \param pInputType Unused.
  365. * \param pInputIndex Unused.
  366. */
  367. void ReadCharacter(FbxCharacter& pCharacter,int& pInputType, int& pInputIndex);
  368. /** Read character link group information from file by group id
  369. * \param pCharacter Character object to fill
  370. * \param pCharacterGroupId Group id to read character link
  371. */
  372. void ReadCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId);
  373. /** Read character link information from file by node id
  374. * \param pCharacter Character object to fill
  375. * \param pCharacterNodeId Character node id
  376. */
  377. void ReadCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId);
  378. /** Read character link formation in rotation space
  379. * \param pCharacterLink Character link object to fill
  380. */
  381. void ReadCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
  382. /** Read character pose from file
  383. * \param pCharacterPose Character pose to fill
  384. * \return if reading character pose is successful return \c true, otherwise return \c false.
  385. */
  386. bool ReadCharacterPose(FbxCharacterPose& pCharacterPose); // TBV
  387. //@}
  388. /**
  389. * \name Misc
  390. */
  391. //@{
  392. /** Read pose object from scene
  393. * \param pScene Scene to read from
  394. * \param pPose Pose object
  395. * \param pAsBindPose whether to treat the pose as BindPose
  396. * \return if reading pose is successful return \c true, otherwise return \c false.
  397. */
  398. bool ReadPose(FbxScene& pScene, FbxPose* pPose, bool pAsBindPose);
  399. /** Read media data from document
  400. * \param pDocument Document to read from
  401. * \param pEmbeddedMediaDirectory the directory path storing the embedded media
  402. * \return if reading media is successful return \c true, otherwise return \c false.
  403. */
  404. bool ReadMedia(FbxDocument *pDocument, const char* pEmbeddedMediaDirectory = "");
  405. /** Read global settings from file
  406. * \param pGlobalSettings global settings object to fill
  407. * \return if reading global settings is successful return \c true, otherwise return \c false.
  408. */
  409. bool ReadGlobalSettings(FbxGlobalSettings& pGlobalSettings);
  410. //@}
  411. /**
  412. * \name Objects
  413. */
  414. //@{
  415. /** Read node data from file
  416. * \param pNode Node object to fill data
  417. * \param pObjectSubType Subtype of object
  418. * \param pDocReferences External reference
  419. * \return if reading node data is successful return \c true, otherwise return \c false.
  420. */
  421. bool ReadNode ( FbxNode& pNode, FbxString& pObjectSubType, Fbx6TypeReadReferences& pDocReferences );
  422. /** Read properties and flags for fbx container
  423. * \param pContainer container to fill data
  424. * \return if reading data to container is successful return \c true, otherwise return \c false.
  425. */
  426. bool ReadContainer ( FbxContainer& pContainer );
  427. /** Read properties and flags for fbx generic node
  428. * \param pNode generic node to fill data
  429. * \return if reading data to generic node is successful return \c true, otherwise return \c false.
  430. */
  431. bool ReadGenericNode ( FbxGenericNode& pNode );
  432. /** Read shading information of node
  433. * \param pNode fbx node to fill shading information
  434. * \return if reading shading information to node is successful return \c true, otherwise return \c false.
  435. */
  436. bool ReadNodeShading ( FbxNode& pNode );
  437. /** Read back-face culling type for node
  438. * \param pNode fbx node
  439. * \return if reading culling type to node is successful return \c true, otherwise return \c false.
  440. */
  441. bool ReadNodeCullingType ( FbxNode& pNode ); // TBV, probablement passe tout en property
  442. /** Read target transform for node
  443. * \param pNode fbx node
  444. * \return if reading target transform to node is successful return \c true, otherwise return \c false.
  445. */
  446. bool ReadNodeTarget ( FbxNode& pNode );
  447. /** Read node attribute according to object subtype
  448. * \param pNode fbx node
  449. * \param pObjectSubType object subtype
  450. * \param pCreatedAttribute set to true if attribute exists
  451. * \param pDocReferences external reference to search
  452. * \return if reading node attribute is successful return \c true, otherwise return \c false.
  453. */
  454. bool ReadNodeAttribute ( FbxNode& pNode , FbxString& pObjectSubType, bool& pCreatedAttribute, Fbx6TypeReadReferences& pDocReferences);
  455. /** Read node attribute according to object subtype
  456. * \param pObjectSubType object subtype
  457. * \param pObjectName object name
  458. * \param pObjectUniqueId unique id of object
  459. * \param pReferencedObject pointer of reference object
  460. * \return A pointer of node attribute. Return \c NULL if the attribute does not exist
  461. */
  462. FbxNodeAttribute* ReadNodeAttribute( FbxString& pObjectSubType, FbxString& pObjectName, FbxString& pObjectUniqueId, FbxObject* pReferencedObject);
  463. /** Read node properties , flags and update the
  464. * node pivot and limits according to properties
  465. * \param pNode FBX node
  466. * \param pReadNodeAttributeProperties whether to
  467. * \return if reading node properties is successful return \c true, otherwise return \c false.
  468. */
  469. bool ReadNodeProperties ( FbxNode& pNode, bool pReadNodeAttributeProperties );
  470. /** Read layered texture from file
  471. * \param pTex Layered texture to fill
  472. * \return if reading layered texture is successful return \c true, otherwise return \c false.
  473. */
  474. bool ReadLayeredTexture ( FbxLayeredTexture& pTex );
  475. /** Read FBX links for geometry
  476. * \param pGeometry FBX geometry
  477. * \return if reading geometry links is successful return \c true, otherwise return \c false.
  478. */
  479. bool ReadGeometryLinks ( FbxGeometry& pGeometry );
  480. /** Read FBX shapes for geometry
  481. * \param pGeometry FBX geometry
  482. * \return if reading geometry shapes is successful return \c true, otherwise return \c false.
  483. */
  484. bool ReadGeometryShapes ( FbxGeometry& pGeometry );
  485. /** Read the null node from file
  486. * \param pNull Null node
  487. * \return if reading null node is successful return \c true, otherwise return \c false.
  488. */
  489. bool ReadNull ( FbxNull& pNull );
  490. /** Read the marker node from file
  491. * \param pMarker Marker node
  492. * \return if reading marker node is successful return \c true, otherwise return \c false.
  493. */
  494. bool ReadMarker ( FbxMarker& pMarker );
  495. /** Read the camera node from file
  496. * \param pCamera Camera node
  497. * \return if reading camera node is successful return \c true, otherwise return \c false.
  498. */
  499. bool ReadCamera ( FbxCamera& pCamera );
  500. /** Read the stereo camera node from file
  501. * \param pCameraStereo Stereo camera node
  502. * \return if reading stereo camera node is successful return \c true, otherwise return \c false.
  503. */
  504. bool ReadCameraStereo ( FbxCameraStereo& pCameraStereo );
  505. /** Read the precomp file from binary file
  506. * \param pCameraStereo Stereo camera node
  507. * \return if reading precomp file is successful return \c true, otherwise return \c false.
  508. */
  509. bool ReadCameraStereoPrecomp (FbxCameraStereo& pCameraStereo);
  510. /** Read the light node from file
  511. * \param pLight light node
  512. * \return if reading light node is successful return \c true, otherwise return \c false.
  513. */
  514. bool ReadLight ( FbxLight& pLight );
  515. /** Read the binding table node from file.
  516. * Create all the binding table entries and fill with embedded data
  517. * \param pTable binding table
  518. * \return if reading binding table is successful return \c true, otherwise return \c false.
  519. */
  520. bool ReadBindingTable ( FbxBindingTable& pTable );
  521. /** Read the binding operator from file
  522. * \param pOperator binding operator
  523. * \return if reading binding operator is successful return \c true, otherwise return \c false.
  524. */
  525. bool ReadBindingOperator ( FbxBindingOperator& pOperator );
  526. /** Read vertices, polygon indices, edges, layer elements, geometry links and shapes to mesh object
  527. * \param pMesh fbx mesh
  528. * \return if reading mesh object is successful return \c true, otherwise return \c false.
  529. */
  530. bool ReadMesh ( FbxMesh& pMesh );
  531. /** Read mesh smoothness factor from mesh
  532. * \param pMesh fbx mesh
  533. * \return if reading mesh smoothness is successful return \c true, otherwise return \c false.
  534. */
  535. bool ReadMeshSmoothness ( FbxMesh& pMesh );
  536. /** Read vertices of mesh object
  537. * \param pMesh fbx mesh
  538. * \return if reading mesh vertices is successful return \c true, otherwise return \c false.
  539. */
  540. bool ReadMeshVertices ( FbxMesh& pMesh );
  541. /** Read polygon indices of mesh object
  542. * \param pMesh fbx mesh
  543. * \return if reading polygon indices is successful return \c true, otherwise return \c false.
  544. */
  545. bool ReadMeshPolygonIndex ( FbxMesh& pMesh );
  546. /** Read edges of mesh object
  547. * \param pMesh fbx mesh
  548. * \return if reading mesh edges is successful return \c true, otherwise return \c false.
  549. */
  550. bool ReadMeshEdges ( FbxMesh& pMesh );
  551. //** Read FBX subdiv, base mesh, finest mesh, current subdiv level...
  552. //* \param pSubdiv fbx subdiv
  553. //* \param pObjectName Object Name
  554. //* \param pReferencedObject pointer of reference object
  555. //* \return if reading subdiv object is successful return \c true, otherwise return \c false.
  556. //*/
  557. //bool ReadSubdiv( FbxSubDiv& pSubdiv, FbxString& pObjectName, FbxObject* pReferencedObject);
  558. /** Read FBX subdiv, base mesh, finest mesh, current subdiv level...
  559. * \param pSubdiv fbx subdiv
  560. * \return if reading subdiv object is successful return \c true, otherwise return \c false.
  561. */
  562. bool ReadSubdiv( FbxSubDiv& pSubdiv);
  563. /** Read properties and flags for fbx document
  564. * \param pSubDocument fbx document
  565. * \return if reading document information is successful return \c true, otherwise return \c false.
  566. */
  567. bool ReadDocument ( FbxDocument& pSubDocument );
  568. /** Read properties and flags for fbx collection
  569. * \param pCollection fbx collection
  570. * \return if reading fbx collection is successful return \c true, otherwise return \c false.
  571. */
  572. bool ReadCollection ( FbxCollection& pCollection );
  573. /** Read properties and flags for fbx selection set
  574. * \param pSelectionSet fbx selection set
  575. * \return if reading fbx selection set is successful return \c true, otherwise return \c false.
  576. */
  577. bool ReadSelectionSet ( FbxSelectionSet& pSelectionSet);
  578. bool ReadSelectionNode (FbxSelectionNode& pSelectionNode);
  579. /** Read nurb data including surface types, nurb type, display type, steps, control points and UV.
  580. * \param pNurbs Nurb object
  581. * \return if reading nurb data is successful return \c true, otherwise return \c false.
  582. */
  583. bool ReadNurb ( FbxNurbs& pNurbs );
  584. /** Read nurb surface data including surface types, surface type, display type, steps, control points and UV vectors.
  585. * \param pNurbs Nurb surface object
  586. * \return if reading nurb surface data is successful return \c true, otherwise return \c false.
  587. */
  588. bool ReadNurbsSurface ( FbxNurbsSurface& pNurbs );
  589. /** Read patch data including patch type, dimension, display type, steps, UV cap and control points.
  590. * \param pPatch Patch object
  591. * \return if reading patch data is successful return \c true, otherwise return \c false.
  592. */
  593. bool ReadPatch ( FbxPatch& pPatch );
  594. /** Read patch type in string and return type in enum
  595. * \param pPatch Patch object
  596. * \return patch type in enum
  597. */
  598. int ReadPatchType ( FbxPatch& pPatch );
  599. /** Read nurb curve data including types, dimension, rational-ness, control points and knots.
  600. * \param pNurbsCurve Nurb curve
  601. * \return if reading nurb curve data is successful return \c true, otherwise return \c false.
  602. */
  603. bool ReadNurbsCurve ( FbxNurbsCurve& pNurbsCurve );
  604. /** Read trim Nurb surface objects with properties
  605. * \param pNurbs Trim nurb surface * \return if reading trim nurb surface is successful return \c true, otherwise return \c false.
  606. */
  607. bool ReadTrimNurbsSurface ( FbxTrimNurbsSurface& pNurbs );
  608. /** Read properties and flags of fbx boundary
  609. * \param pBoundary Fbx boundary object
  610. * \return if reading fbx boundary is successful return \c true, otherwise return \c false.
  611. */
  612. bool ReadBoundary ( FbxBoundary& pBoundary );
  613. /** Read shape object properties from file
  614. * \param pShape Fbx Shape
  615. * \param pGeometry Geometry contains the shape
  616. * \return if reading shape object properties is successful return \c true, otherwise return \c false.
  617. */
  618. bool ReadShape ( FbxShape& pShape, FbxGeometry& pGeometry);
  619. /** Read properties and flags of fbx implementation
  620. * \param pImplementation Fbx implementation
  621. * \return if reading fbx implementation is successful return \c true, otherwise return \c false.
  622. */
  623. bool ReadImplementation ( FbxImplementation& pImplementation );
  624. /** Read texture object data including name, UV transform, alpha and cropping.
  625. * \param pTexture Fbx texture object
  626. * \return if reading texture object is successful return \c true, otherwise return \c false.
  627. */
  628. bool ReadFileTexture (FbxFileTexture& pTexture);
  629. /** Read surface material from file
  630. * \param pName Material Name
  631. * \param pMaterialType Material type
  632. * \param pReferencedMaterial Reference material to clone from if it is not \c NULL
  633. * \return A pointer of read surface material
  634. */
  635. FbxSurfaceMaterial* ReadSurfaceMaterial(const char* pName, const char* pMaterialType, FbxSurfaceMaterial* pReferencedMaterial);
  636. /** Read video object from file
  637. * \param pVideo Fbx video object
  638. * \return if reading video object is successful return \c true, otherwise return \c false.
  639. */
  640. bool ReadVideo (FbxVideo& pVideo);
  641. /** Read thumbnail object from file
  642. * \param pThumbnail Fbx thumbnail
  643. * \return if reading thumbnail is successful return \c true, otherwise return \c false.
  644. */
  645. bool ReadThumbnail (FbxThumbnail& pThumbnail);
  646. //@}
  647. /**
  648. * \name Layer elements
  649. */
  650. //@{
  651. /** Read all layer elements for geometry
  652. * \param pGeometry geometry to fill
  653. * \return if reading all layer elements is successful return \c true, otherwise return \c false.
  654. */
  655. bool ReadLayerElements (FbxGeometry& pGeometry);
  656. /** Read material layer elements for geometry
  657. * \param pGeometry geometry to fill
  658. * \param pElementsMaterial material layer element array
  659. * \return if reading material layer elements is successful return \c true, otherwise return \c false.
  660. */
  661. bool ReadLayerElementsMaterial (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsMaterial);
  662. /** Read normal layer elements for geometry
  663. * \param pGeometry geometry to fill
  664. * \param pElementsNormal normal layer element array
  665. * \return if reading normal layer elements is successful return \c true, otherwise return \c false.
  666. */
  667. bool ReadLayerElementsNormal (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsNormal);
  668. /** Read Tangent layer elements for geometry
  669. * \param pGeometry geometry to fill
  670. * \param pElementsTangent Tangent layer element array
  671. * \return if reading Tangent layer elements is successful return \c true, otherwise return \c false.
  672. */
  673. bool ReadLayerElementsTangent (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsTangent);
  674. /** Read Binormal layer elements for geometry
  675. * \param pGeometry geometry to fill
  676. * \param pElementsBinormal Binormal layer element array
  677. * \return if reading Binormal layer elements is successful return \c true, otherwise return \c false.
  678. */
  679. bool ReadLayerElementsBinormal (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsBinormal);
  680. /** Read vertex color layer elements for geometry
  681. * \param pGeometry geometry to fill
  682. * \param pElementsVertexColor vertex color layer element array
  683. * \return if reading vertex color layer elements is successful return \c true, otherwise return \c false.
  684. */
  685. bool ReadLayerElementsVertexColor (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsVertexColor);
  686. /** Read texture layer elements for geometry
  687. * \param pGeometry geometry to fill
  688. * \param pElementsTexture texture layer element array
  689. * \param pTextureType the type of elements to read
  690. * \return if reading texture layer elements is successful return \c true, otherwise return \c false.
  691. */
  692. bool ReadLayerElementsTexture (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsTexture, FbxLayerElement::EType pTextureType);
  693. /** Read UV layer elements for geometry
  694. * \param pGeometry geometry to fill
  695. * \param pElementsUV UV layer element array
  696. * \param pTextureType the type of elements to read
  697. * \return if reading UV layer elements is successful return \c true, otherwise return \c false.
  698. */
  699. bool ReadLayerElementsChannelUV (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsUV, FbxLayerElement::EType pTextureType);
  700. /** Read polygon group layer elements for geometry
  701. * \param pGeometry geometry to fill
  702. * \param pElementsPolygonGroup polygon group layer element array
  703. * \return if reading polygon group layer elements is successful return \c true, otherwise return \c false.
  704. */
  705. bool ReadLayerElementsPolygonGroup (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsPolygonGroup);
  706. /** Read smoothing layer elements for geometry
  707. * \param pGeometry geometry to fill
  708. * \param pElementsSmoothing Smoothing group layer element array
  709. * \return if reading smoothing layer elements is successful return \c true, otherwise return \c false.
  710. */
  711. bool ReadLayerElementsSmoothing (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsSmoothing);
  712. /** Read user data layer elements for geometry
  713. * \param pGeometry geometry to fill
  714. * \param pElementsUserData User data layer element array
  715. * \return if reading user data layer elements is successful return \c true, otherwise return \c false.
  716. */
  717. bool ReadLayerElementsUserData (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsUserData);
  718. /** Read visibility layer elements for geometry
  719. * \param pGeometry geometry to fill
  720. * \param pElementsVisibility visibility layer element array
  721. * \return if reading visibility layer elements is successful return \c true, otherwise return \c false.
  722. */
  723. bool ReadLayerElementsVisibility (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsVisibility);
  724. /** Read edge crease layer elements for geometry
  725. * \param pGeometry geometry to fill
  726. * \param pElementsEdgeCrease edge crease layer element array
  727. * \return if reading edge crease layer elements is successful return \c true, otherwise return \c false.
  728. */
  729. bool ReadLayerElementEdgeCrease (FbxGeometry*pGeometry, FbxArray<FbxLayerElement*>& pElementsEdgeCrease);
  730. /** Read vertex crease layer elements for geometry
  731. * \param pGeometry geometry to fill
  732. * \param pElementsVertexCrease vertex crease layer element array
  733. * \return if reading vertex crease layer elements is successful return \c true, otherwise return \c false.
  734. */
  735. bool ReadLayerElementVertexCrease (FbxGeometry*pGeometry, FbxArray<FbxLayerElement*>& pElementsVertexCrease);
  736. /** Read hole layer elements for geometry
  737. * \param pGeometry geometry to fill
  738. * \param pElementsHole hole layer element array
  739. * \return if reading hole layer elements is successful return \c true, otherwise return \c false.
  740. */
  741. bool ReadLayerElementHole (FbxGeometry*pGeometry, FbxArray<FbxLayerElement*>& pElementsHole);
  742. //@}
  743. /**
  744. * \name Geometry weighted maps
  745. */
  746. //@{
  747. /** Read geometry weight map from file
  748. * \param pGeometryWeightedMap geometry weighted
  749. * \return if reading geometry weight map is successful return \c true, otherwise return \c false.
  750. */
  751. bool ReadGeometryWeightedMap(FbxGeometryWeightedMap& pGeometryWeightedMap);
  752. //@}
  753. /**
  754. * \name Deformers / Constraints
  755. */
  756. //@{
  757. /** Read link object from file
  758. * \param pLink fbx link object
  759. * \return if reading link object is successful return \c true, otherwise return \c false.
  760. */
  761. bool ReadLink(FbxCluster& pLink);
  762. /** Read SDK skin from file
  763. * \param pSkin SDK skin object
  764. * \return if reading skin object is successful return \c true, otherwise return \c false.
  765. */
  766. bool ReadSkin(FbxSkin& pSkin);
  767. /** Read properties and flags for vertex cache deformer from file
  768. * \param pDeformer fbx vertex cache deformer
  769. * \return if reading vertex cache deformer is successful return \c true, otherwise return \c false.
  770. */
  771. bool ReadVertexCacheDeformer(FbxVertexCacheDeformer& pDeformer);
  772. /** Read cluster object data from file
  773. * \param pCluster fbx cluster object
  774. * \return if reading cluster object is successful return \c true, otherwise return \c false.
  775. */
  776. bool ReadCluster(FbxCluster& pCluster);
  777. /** Read constraint object from file
  778. * \param pPosition fbx constraint object
  779. * \return if reading constraint object is successful return \c true, otherwise return \c false.
  780. */
  781. bool ReadConstraint(FbxConstraint& pPosition);
  782. //@}
  783. // Cache
  784. /** Read fbx cache file
  785. * \param pCache fbx cache
  786. * \return if reading cache data is successful return \c true, otherwise return \c false.
  787. */
  788. bool ReadCache(FbxCache& pCache);
  789. /**
  790. * \name Post-processing / utility functions
  791. */
  792. //@{
  793. /** Make sure the Camera's background textures are properly connected
  794. * \param pScene fbx scene
  795. * \remarks This function only applies when it detects older file versions in
  796. * which the background texture is connected directly to the object instead of
  797. * the corresponding property.
  798. */
  799. bool ResolveCameraBackgrounds(FbxScene& pScene);
  800. /** Remove duplicate textures in the same scene
  801. * \param pScene fbx scene
  802. */
  803. void RemoveDuplicateTextures(FbxScene& pScene);
  804. /** Replace textures in the geometry
  805. * \param pTextureDuplicate texture array
  806. * \param pTextureReplacement texture array to replace
  807. * \param pGeometry geometry owns these textures
  808. * \param pTextureType layer element type
  809. */
  810. void ReplaceTextures(FbxArray<FbxTexture*> const& pTextureDuplicate,
  811. FbxArray<FbxTexture*> const& pTextureReplacement,
  812. FbxGeometry* pGeometry, FbxLayerElement::EType pTextureType);
  813. /** Remove duplicated materials in the same scene
  814. * \param pScene FBX scene
  815. */
  816. void RemoveDuplicateMaterials(FbxScene& pScene);
  817. /** convert camera name for naming convention
  818. * \param pCameraName original camera name
  819. * \return new name for the camera
  820. */
  821. FbxString ConvertCameraName(FbxString pCameraName);
  822. /** Search string in a string array
  823. * \param pString the string to search
  824. * \param pStringArray string array
  825. * \return return the index of the array if the string is found, otherwise return \c -1
  826. */
  827. int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
  828. /** Read password from string
  829. * \param pPassword password in string
  830. * \return if the password is valid return \c true, otherwise return \c false
  831. */
  832. bool ReadPassword(FbxString pPassword);
  833. /** Publish properties
  834. * \param pObject fbx object
  835. */
  836. void PublishProperties(FbxObject& pObject);
  837. /** Read properties for fbx object from file object
  838. * \param pFbxObject fbx object
  839. * \param pFbxFileObject fbx file object
  840. * \param pReadNodeAttributeProperties whether to read properties for node attributes
  841. */
  842. bool ReadProperties(FbxObject *pFbxObject, FbxIO *pFbxFileObject, bool pReadNodeAttributeProperties=true);
  843. /** Read properties and flags for fbx object from file object
  844. * \param pFbxObject fbx object
  845. * \param pFbxFileObject fbx file object
  846. * \param pReadNodeAttributeProperties whether to read properties for node attributes
  847. * \return if reading properties and flags is successful return \c true, otherwise return \c false.
  848. */
  849. bool ReadPropertiesAndFlags(FbxObject *pFbxObject, FbxIO *pFbxFileObject, bool pReadNodeAttributeProperties=true);
  850. /** Read flags for fbx object from file object
  851. * \param pFbxObject object to set flags
  852. * \param pFbxFileObject file to read
  853. * \return if reading flags is successful return \c true, otherwise return \c false.
  854. */
  855. bool ReadFlags(FbxObject *pFbxObject, FbxIO* pFbxFileObject);
  856. /** Rebuild trim regions indices from the boundary connections
  857. * \param pScene Fbx scene
  858. */
  859. void RebuildTrimRegions(FbxScene& pScene) const;
  860. /** Rebuild subdivision object from subdiv-mesh connections
  861. * \param pScene Fbx scene
  862. */
  863. void SetSubdivision(FbxScene& pScene) const;
  864. /** Convert shape deform property to DeformPercent property of FbxBlendShapeChannel
  865. * \param pScene Fbx scene
  866. */
  867. void ConvertShapeDeformProperty(FbxScene& pScene) const;
  868. /** Rebuild layered texture alphas from sub texture connections.
  869. * \param pScene Fbx scene
  870. */
  871. void RebuildLayeredTextureAlphas(FbxScene& pScene) const;
  872. //---------------- in progress -------------------------------
  873. void ReadOptionsInMainSection();
  874. void ReadTakeOptions();
  875. bool ReadOptionsInExtensionSection(int& pSectionIndex);
  876. bool WriteOptionsInExtensionSection(bool pOverwriteLastExtensionSection=false);
  877. //--------------- end in progress ----------------------------
  878. /** Read global settings, axis system, system unit from main section of file
  879. *
  880. */
  881. void ReadGlobalSettingsInMainSection();
  882. /** Read statistic data from definition section
  883. *
  884. */
  885. void ReadDefinitionSectionForStats();
  886. //@}
  887. private:
  888. FbxReaderFbx6& operator=(FbxReaderFbx6 const&) { return *this; }
  889. FbxIO* mFileObject;
  890. FbxImporter& mImporter;
  891. FbxCharPtrSet mNodeArrayName;
  892. FbxObjectStringMap mObjectMap;
  893. bool mParseGlobalSettings;
  894. FbxAxisSystem mAxisSystem;
  895. FbxSystemUnit mSystemUnit;
  896. FbxTime::EMode mFrameRate;
  897. bool mRetrieveStats;
  898. FbxStatistics* mDefinitionsStatistics;
  899. FbxArray<FbxTakeInfo *> mTakeInfo;
  900. FbxDocumentInfo* mSceneInfo;
  901. FbxAnimLayer* mAnimLayer;
  902. FbxMultiMap mNickToKFCurveNodeTimeWarpsSet;
  903. FbxMultiMap* mNickToAnimCurveTimeWarpsSet;
  904. Fbx6ClassTemplateMap mClassTemplateMap;
  905. FbxProgress* mProgress;
  906. bool mProgressPause;
  907. };
  908. #include <fbxsdk/fbxsdk_nsend.h>
  909. #endif /* _FBXSDK_FILEIO_FBX_READER_FBX6_H_ */