fbxio.h 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  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 fbxio.h
  9. #ifndef _FBXSDK_FILEIO_FBX_IO_H_
  10. #define _FBXSDK_FILEIO_FBX_IO_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/core/base/fbxstring.h>
  13. #include <fbxsdk/core/base/fbxtime.h>
  14. #include <fbxsdk/core/base/fbxstatus.h>
  15. #include <fbxsdk/fbxsdk_nsbegin.h>
  16. class FbxIO;
  17. class FbxReader;
  18. class FbxWriter;
  19. class FbxFile;
  20. class FbxStream;
  21. class FbxXRefManager;
  22. /**
  23. Defines the current FBX file version number in four digits. The first digit is the
  24. major version number a the last three digits are the minor version number (e.g. 7100 = 7.1).
  25. The following is the version history of FBX:
  26. \li Version 2000 - New KFCurve and embedded FBX, no FCurve/FCurve node storing.
  27. No more .takf file like in earlier version, no history.
  28. \li Version 2001 - Version incremented to support FbxTime save in native (integer, not double)
  29. format.
  30. \li Version 3000 - FiLMBOX 3.0 version, nothing changed in current class since version 2001.
  31. FBX SDK 3.0 and 3.6
  32. \li Version 3001 - FiLMBOX 3.0 encrypted version, only a trial. Encrypted files could only
  33. be written in debug versions. Cannot switch to a higher version number now because any
  34. file with a version number >= 3001 is read as encrypted.
  35. Hence, this value now only gives file type. (3000 or less -> binary, 3001 or more -> encrypted)
  36. FiLMBOX 3.2, FiLMBOX 3.5 and "Online" 3.51 have been released with version 3000.
  37. \li Version 4000 - MotionBuilder 4.0, new type in KFCurve tangents, supported in FiLMBOX 3.5
  38. but not by earlier versions. Version number is now stored in section footer.
  39. Before September 3rd 2002, the version number was always 3000 in main section footer.
  40. Now the main section footer has version number 4000. The minimum version number in footer of
  41. an extension section is 4000.
  42. \li Version 4001 - ASCII Header is 4.1. MotionBuilder 4.01, to fix FCurveNode problem with
  43. layer types in version 4000 the main section footer has version number 4001.
  44. Now the footer for extension sections has version number 4001.
  45. \li Version 4050 - ASCII Header is 4.5. MotionBuilder 4.1 or 4.5 before
  46. January 22nd 2003. This is because EvaluationProperties now have color. Now the main section footer
  47. has version number 4050.
  48. Now the footer for extension sections has version number 4050.
  49. \li Version 5000 - ASCII Header is not compatible anymore with MotionBuilder 4.0, 4.01 and 4.02 and FBX SDK 3.6 and 3.7
  50. MotionBuilder 4.03 and 4.1 or 4.5 from January 22nd 2003
  51. FBX SDK 3.6.1. New extended header to improve FBX file version management. Now the extended header and
  52. the main section footer have version number 5000. Now the footer for extension sections has version number 5000.
  53. \li Version 5800 - This was a temporary version while waiting for version 6000 renders the previous versions
  54. incompatible with MotionBuilder 6.0. For now, however, this format is needed to allow
  55. some tools/plugins (For example Maya) to correctly detect that the file has some features that are not
  56. completely backward compatible (For example: pivots defined with _pre/_post nodes which require a special
  57. processing). By incrementing only the minor version we do not compromise the integrity of the
  58. files.
  59. \li Version 6000 - Header version is now 6.0.
  60. Extended header now contain a creation time stamp
  61. that can be retrieve without parsing the main section of the file.
  62. A creator tag (string) is now stored in the Extended header. This contain the originator (MB/FBXSDK)
  63. of the file and the build number of the originator.
  64. First release of the file format using the KProperties to store/retrieve information.
  65. \li Version 6100 - Added support for multiple attributes (mainly multiple geometry) at the node level.
  66. The pointer to the node attribute have been replaced by a connection between the node and its attribute(s).
  67. \li Version 7000 -
  68. First version of the 7.0 series; most likely very short-lived, developed for Protein, before ADP.
  69. Supports reference cloning, external documents, blobs, unique IDs (per file), property templates.
  70. So many changes that it was decided to break from 6.0 to keep Motion Builder intact.
  71. \li Version 7099 - Temporary version for FBX 2011 alpha releases.
  72. \li Version 7100
  73. Official file version for FBX 2011, add support for animation to FBX 7.
  74. First version of FBX SDK with FBX 7 files as the default file format.
  75. \li Version 7200
  76. Added support for multiple blend shape deformers and In-Between blend-shapes on each geometry.
  77. Moved shape(FbxShape) to its own section other than as a part of geometry section.
  78. Add support to store blend shape deformer(FbxBlendShape), blend shape channel(FbxBlendShapeChannel),
  79. Substance(FbxProceduralTexture) and Lines(FbxLine).
  80. Add support to store 3 different smooth binding modes of FbxSkin, including classic linear, dual quaternion
  81. and blended mode of previous two modes.
  82. Added the CLAMP_PROGRESSIVE tangent mode.
  83. The KFCurve::KeyAttrDataFloat data array now stores as integer values (ASCII mode) to to eliminate float to int precision errors.
  84. FbxLayeredTexture now stores alphas for its sub textures.
  85. \li Version 7300
  86. Changed the way the CharacterPoses are written.
  87. Changed light property name HotSpot and ConeAngle to InnerAngle and OuterAngle
  88. \li Version 7400
  89. Normals, tangents and binormals save the 4th component into a separate array
  90. \li Version 7500
  91. Added support for large files (>2GB). NOTE: This breaks forward compatibility (i.e. older products won't be able to open these files!!)
  92. */
  93. //File version numbers
  94. #define FBX_FILE_VERSION_2000 2000 //FBX 2.0
  95. #define FBX_FILE_VERSION_2001 2001 //FBX 2.01
  96. #define FBX_FILE_VERSION_3000 3000 //FBX 3.0
  97. #define FBX_FILE_VERSION_3001 3001 //FBX 3.01
  98. #define FBX_FILE_VERSION_4000 4000 //FBX 4.0
  99. #define FBX_FILE_VERSION_4001 4001 //FBX 4.01
  100. #define FBX_FILE_VERSION_4050 4050 //FBX 4.5
  101. #define FBX_FILE_VERSION_5000 5000 //FBX 5.0
  102. #define FBX_FILE_VERSION_5800 5800 //FBX 5.8
  103. #define FBX_FILE_VERSION_6000 6000 //FBX 6.0
  104. #define FBX_FILE_VERSION_6100 6100 //FBX 6.1 (guarantee compatibility with Autodesk 2010 products)
  105. #define FBX_FILE_VERSION_7000 7000 //Compatible with 7.1, and taken as such
  106. #define FBX_FILE_VERSION_7099 7099 //Compatible with 7.1, and taken as such
  107. #define FBX_FILE_VERSION_7100 7100 //FBX 7.1 (guarantee compatibility with Autodesk 2011 products)
  108. #define FBX_FILE_VERSION_7200 7200 //FBX 7.2 (guarantee compatibility with Autodesk 2012 products)
  109. #define FBX_FILE_VERSION_7300 7300 //FBX 7.3 (guarantee compatibility with Autodesk 2013 products)
  110. #define FBX_FILE_VERSION_7400 7400 //FBX 7.4 (guarantee compatibility with Autodesk 2014/2015 products)
  111. #define FBX_FILE_VERSION_7500 7500 //FBX 7.5 (guarantee compatibility with Autodesk 2016 products)
  112. //File version compatibility strings
  113. #define FBX_53_MB55_COMPATIBLE "FBX53_MB55"
  114. #define FBX_60_COMPATIBLE "FBX60_MB60"
  115. #define FBX_2005_08_COMPATIBLE "FBX200508_MB70"
  116. #define FBX_2006_02_COMPATIBLE "FBX200602_MB75"
  117. #define FBX_2006_08_COMPATIBLE "FBX200608"
  118. #define FBX_2006_11_COMPATIBLE "FBX200611"
  119. #define FBX_2009_00_COMPATIBLE "FBX200900"
  120. #define FBX_2009_00_V7_COMPATIBLE "FBX200900v7"
  121. #define FBX_2010_00_COMPATIBLE "FBX201000"
  122. #define FBX_2011_00_COMPATIBLE "FBX201100"
  123. #define FBX_2012_00_COMPATIBLE "FBX201200"
  124. #define FBX_2013_00_COMPATIBLE "FBX201300"
  125. #define FBX_2014_00_COMPATIBLE "FBX201400"
  126. #define FBX_2016_00_COMPATIBLE "FBX201600"
  127. //Default file version number used when writing new FBX files
  128. #define FBX_DEFAULT_FILE_VERSION FBX_FILE_VERSION_7500
  129. #define FBX_DEFAULT_FILE_COMPATIBILITY FBX_2016_00_COMPATIBLE
  130. /** Convert the FBX file version string to an integral number for <= or >= tests purposes.
  131. * \param pFileVersion File version string.
  132. * Some examples:
  133. * \code
  134. * int version;
  135. * version = FileVersionStrToInt(FBX2012_00_COMPATIBLE); // version = 201200
  136. * version = FileVersionStrToInt(FBX60_COMPATIBLE); // version = 6000
  137. * version = FileVersionStrToInt("FBX200900"); // version = 200900
  138. * version = FileVersionStrToInt("Toto"); // version = 0
  139. * version = FileVersionStrToInt(""); // version = -1
  140. * \endcode
  141. * \returns the file version number or 0 if an unsupported string value is passed.
  142. */
  143. FBXSDK_DLL int FbxFileVersionStrToInt(const char* pFileVersion);
  144. /** \internal Used internally by readers to evaluate what is the current section */
  145. enum
  146. {
  147. FBX_NO_SECTION = -1, //!< indicate not in a valid section
  148. FBX_MAIN_SECTION, //!< indicate currently in the main section
  149. FBX_EXTENSION_SECTION_0 //!< indicate currently in the extention section 0
  150. };
  151. /** Render and resolution information.
  152. * \nosubgrouping
  153. */
  154. class FBXSDK_DLL FbxIODefaultRenderResolution
  155. {
  156. public:
  157. /** If the resolution data is ready. */
  158. bool mIsOK;
  159. /** camera name. */
  160. FbxString mCameraName;
  161. /** resolution mode. ex: "Fixed Resolution","Fixed Ratio","Fixed Width","Fixed Height","Window Size"*/
  162. FbxString mResolutionMode;
  163. /** resolution width. */
  164. double mResolutionW;
  165. /** resolution height. */
  166. double mResolutionH;
  167. /**
  168. * \name Constructors and Destructor
  169. */
  170. //@{
  171. //! Default constructor.
  172. FbxIODefaultRenderResolution();
  173. //@}
  174. /**
  175. * \name Member Access
  176. */
  177. //@{
  178. //! Reset values to default.
  179. void Reset();
  180. //@}
  181. };
  182. /** FBX header information used at beginning of the FBX file
  183. * to get or set important values like the file format version number (mFileVersion).
  184. * The file version number will be used to select a particular Reader or Writer.
  185. * \nosubgrouping */
  186. class FBXSDK_DLL FbxIOFileHeaderInfo
  187. {
  188. public:
  189. /**
  190. * \name Constructors and Destructor
  191. */
  192. //@{
  193. //! Default constructor.
  194. FbxIOFileHeaderInfo();
  195. //! Destructor.
  196. virtual ~FbxIOFileHeaderInfo();
  197. //@}
  198. /**
  199. * \name Public Member
  200. */
  201. //@{
  202. //! Reset values to default.
  203. virtual void Reset();
  204. /** A derived class can override this function to read additional information from the file header.
  205. * \return false in case of failure that should stop loading the file.
  206. */
  207. virtual bool ReadExtendedHeaderInformation(FbxIO*);
  208. //@}
  209. //! FbxIODefaultRenderResolution to handle default resolution values
  210. FbxIODefaultRenderResolution mDefaultRenderResolution;
  211. //!Read only properties (not used for file write)
  212. //@{
  213. /** File version ex; 5000, 6000, 6100, 7000, 7099, 7100
  214. * the major part is the first digit, the minor part, 3 other digits
  215. * ex: 7100 means version 7.1
  216. */
  217. int mFileVersion;
  218. /** Indicates whether a creation time stamp is preset */
  219. bool mCreationTimeStampPresent;
  220. /** Indicates whether the mCreationTimeStamp member variable contains the actual creation time of the file. */
  221. FbxLocalTime mCreationTimeStamp;
  222. /** Indicates who is the creator of the file
  223. * Ex: "FBX SDK/FBX Plugins version 2011.2"
  224. */
  225. FbxString mCreator;
  226. /** Indicates whether the file is created by a genuine Autodesk plug-in or not */
  227. bool mIOPlugin;
  228. /** The flag indicates that the header was created by a personal learning edition (PLE) of FBX. */
  229. bool mPLE;
  230. //@}
  231. };
  232. /** FbxIO represents an FBX file.
  233. * It is primarily used by FBX importers (FbxImporter) and exporter (FbxExporter)
  234. * when reading or writing data from or to a disk or memory.
  235. * Most users will not use the FbxIO class directly
  236. * but will use an instance of either FbxImporter or FbxExporter
  237. * to read or write FBX files.
  238. *
  239. * An FBX file may contain binary data or ASCII data.
  240. * A good way to learn the internal structure of a FBX file
  241. * is to open a FBX file saved in ASCII in a text editor.
  242. *
  243. * Ex: to read a FBX file content using FbxIO class directly
  244. * \code
  245. * // Create a FbxIO object with FbxIO::Create()
  246. * // Open the file with ProjectOpen( ... ) a NULL pointer can be passed for (FbxReader)* param
  247. * // ProjectOpen_xxx_Section() to open a particular section
  248. * int nbSec = FieldGetCount(); // to get the number of fields of the current section opened
  249. * for(int i=0; i < nbSec; i++) // read all fields
  250. * {
  251. * // check if the field is a block
  252. * if(FieldReadIsBlock()){ } ... Read sub fields recursively ... may contain other blocks and fields
  253. * else
  254. * {
  255. * FieldReadBegin(); // navigate on the field
  256. * char fieldType = FieldReadGetType(); // get the data type
  257. *
  258. * // According to the Field data type, call the appropriate read functions
  259. *
  260. * if(fieldType == 'S') FieldReadS(...) to read a string
  261. * else if(fieldType == 'B') FieldReadB(...) to read a bool
  262. * else if(fieldType == 'I') FieldReadI(...) to read a int
  263. * ...
  264. * FieldReadEnd(); // navigate to next field
  265. * }
  266. * }
  267. *
  268. * ProjectCloseSection() // close the section opened
  269. * // repeat for another section ...
  270. * // finally close the Project
  271. * ProjectClose(); // or delete the FbxIO object created.
  272. * \endcode
  273. */
  274. class FBXSDK_DLL FbxIO
  275. {
  276. public:
  277. /** \internal Exception-safe way of setting/resetting the xref manager in a FbxIO object.
  278. */
  279. struct FbxAutoResetXRefManager
  280. {
  281. FbxIO* mFbx;
  282. const FbxXRefManager* mXRefManager;
  283. /** Default constructor */
  284. FbxAutoResetXRefManager(FbxIO* pFbx, FbxXRefManager& pXRefManager)
  285. : mFbx(pFbx)
  286. , mXRefManager(NULL)
  287. {
  288. if( mFbx )
  289. {
  290. mXRefManager = mFbx->ProjectGetXRefManager();
  291. mFbx->ProjectSetXRefManager(&pXRefManager);
  292. }
  293. }
  294. /** Destructor */
  295. ~FbxAutoResetXRefManager()
  296. {
  297. if( mFbx )
  298. {
  299. mFbx->ProjectSetXRefManager(mXRefManager);
  300. }
  301. }
  302. };
  303. enum BinaryType
  304. {
  305. BinaryNormal, //<! Standard FBX file field alignment using 32bit values, used by all file format version 7.4.0 or lower
  306. BinaryLarge //<! New FBX file field alignment using 64bit values, used by all file format version 7.5.0 or higher
  307. };
  308. /** Creation function for this FbxIO class
  309. * \param pStatus The FbxStatus object to hold error codes.
  310. * \return a new FbxIO object pointer
  311. */
  312. static FbxIO* Create(BinaryType pBinaryType, FbxStatus& pStatus){ return FbxNew< FbxIO >(pBinaryType, pStatus); }
  313. /** Default constructor */
  314. FbxIO(BinaryType pBinaryType, FbxStatus& pStatus);
  315. /** Destructor */
  316. virtual ~FbxIO();
  317. /**
  318. * \name Project Global
  319. * The term "Project" here is an abstract name chosen to represent a group of data
  320. * ex: a file, a stream, a memory buffer, etc.
  321. */
  322. //@{
  323. /** Open a project already in Memory
  324. * \param pAddress
  325. * \param pMaxLength
  326. * \param pReader
  327. * \param pCheckCRC
  328. * \param pOpenMainSection
  329. * \param pFileHeaderInfo
  330. * \return \c true on success, \c false otherwise.
  331. */
  332. bool ProjectOpen(void* pAddress, FbxULong pMaxLength, FbxReader* pReader, bool pCheckCRC = false, bool pOpenMainSection = true, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  333. /** Open a project.
  334. * \param pName
  335. * \param pReader
  336. * \param pCheckCRC
  337. * \param pOpenMainSection
  338. * \param pFileHeaderInfo
  339. * \return \c true on success, \c false otherwise.
  340. */
  341. bool ProjectOpen(const char* pName, FbxReader* pReader, bool pCheckCRC = false, bool pOpenMainSection = true, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  342. /** Open a project.
  343. * \param pStream
  344. * \param pStreamData
  345. * \param pReader
  346. * \param pCheckCRC
  347. * \param pOpenMainSection
  348. * \param pFileHeaderInfo
  349. * \return \c true on success, \c false otherwise.
  350. */
  351. bool ProjectOpen(FbxStream* pStream, void* pStreamData, FbxReader* pReader, bool pCheckCRC = false, bool pOpenMainSection = true, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  352. /** Open project file without necessarily an .fbx extension.
  353. * \param pName
  354. * \param pReader
  355. * \param pCheckCRC
  356. * \param pOpenMainSection
  357. * \param pFileHeaderInfo
  358. * \return \c true on success, \c false otherwise.
  359. */
  360. bool ProjectOpenDirect(const char* pName, FbxReader* pReader, bool pCheckCRC = false, bool pOpenMainSection = true, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  361. /** Create a project in Memory
  362. * \param pAddress
  363. * \param pSize
  364. * \param pWriter
  365. * \param pBinary
  366. * \param pEncrypted
  367. * \param pFileHeaderInfo
  368. * \return \c true on success, \c false otherwise.
  369. */
  370. bool ProjectCreate(void* pAddress, FbxUInt pSize, FbxWriter* pWriter, bool pBinary, bool pEncrypted, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  371. /** Create a project.
  372. * \param pName
  373. * \param pWriter
  374. * \param pBinary
  375. * \param pEncrypted
  376. * \param pFileHeaderInfo
  377. * \return \c true on success, \c false otherwise.
  378. */
  379. bool ProjectCreate(const char* pName, FbxWriter* pWriter, bool pBinary, bool pEncrypted, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  380. /** Create a project.
  381. * \param pStream
  382. * \param pStreamData
  383. * \param pWriter
  384. * \param pBinary
  385. * \param pEncrypted
  386. * \param pFileHeaderInfo
  387. * \return \c true on success, \c false otherwise.
  388. */
  389. bool ProjectCreate(FbxStream* pStream, void* pStreamData, FbxWriter* pWriter, bool pBinary, bool pEncrypted, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  390. /** Create a project without necessary an .fbx extension.
  391. * \param pName
  392. * \param pWriter
  393. * \param pBinary
  394. * \param pEncrypted
  395. * \param pFileHeaderInfo
  396. * \return \c true on success, \c false otherwise.
  397. */
  398. bool ProjectCreateDirect(const char* pName, FbxWriter* pWriter, bool pBinary, bool pEncrypted, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  399. /** Create a project, without writing out the header (yet)
  400. * \param pName
  401. * \param pWriter
  402. * \param pVersion
  403. * \param pBinary
  404. * \param pEncrypted
  405. * \return \c true on success, \c false otherwise.
  406. */
  407. bool ProjectCreateEmpty(const char* pName, FbxWriter* pWriter, int pVersion, bool pBinary, bool pEncrypted);
  408. /** Create a project, without writing out the header (yet)
  409. * \param pStream
  410. * \param pStreamData
  411. * \param pWriter
  412. * \param pVersion
  413. * \param pBinary
  414. * \param pEncrypted
  415. * \return \c true on success, \c false otherwise.
  416. */
  417. bool ProjectCreateEmpty(FbxStream* pStream, void* pStreamData, FbxWriter* pWriter, int pVersion, bool pBinary, bool pEncrypted);
  418. /** Write FBX signature at the top of the file, prepare file for writing header information
  419. * \return \c true on success, \c false otherwise.
  420. */
  421. bool ProjectWrite_BeginFileHeader();
  422. /** Open up the 'extended header'
  423. * \return \c true on success, \c false otherwise.
  424. */
  425. bool ProjectWrite_BeginExtendedHeader();
  426. /** Write the contents of the extended header
  427. * \param pExtendedHeader
  428. * \return \c true on success, \c false otherwise.
  429. */
  430. bool ProjectWrite_WriteExtendedHeader(const FbxIOFileHeaderInfo* pExtendedHeader);
  431. /** Close the extended header
  432. * \return \c true on success, \c false otherwise.
  433. */
  434. bool ProjectWrite_EndExtendedHeader();
  435. /** Close up the header, prepare file for payload write.
  436. * \return \c true on success, \c false otherwise.
  437. */
  438. bool ProjectWrite_EndFileHeader();
  439. /** Close the project.
  440. * \param pData
  441. * \param pSize
  442. * \return \c true on success, \c false otherwise.
  443. */
  444. bool ProjectClose(void** pData=0, size_t* pSize=0);
  445. /** Provide the XRef Manager to use to create the .fbm folder.
  446. * \remarks If NULL is used, the old behavior (using the .fbx's folder) is used instead.
  447. */
  448. void ProjectSetXRefManager(const FbxXRefManager*);
  449. /** Get the XRef Manager to use.
  450. * \return NULL if no XRef manager has been set.
  451. */
  452. const FbxXRefManager* ProjectGetXRefManager() const;
  453. /** Select (and create) a folder to store embedded files (the .fbm
  454. * file folder). Takes into account the settings from the XRef Manager.
  455. * \param pXRefManager
  456. * \param pCreatedFolder
  457. * \param pUserDefinedFolder User defined "working folder"
  458. * \return \c true on success, \c false otherwise.
  459. * \remarks If this already been called successfully, uses the path
  460. * previously created.
  461. *
  462. * Client application is responsible for cleaning up this folder.
  463. *
  464. * This will be automatically called if ProjectSetXRefManager()
  465. * has been called before the .fbm folder needs to be created.
  466. */
  467. bool ProjectCreateEmbeddedFolder(const FbxXRefManager& pXRefManager, FbxString& pCreatedFolder, const char* pUserDefinedFolder = NULL);
  468. /** On store event, use this function to tell if we are embedding.
  469. * \param pValue
  470. */
  471. void SetEmbedded(bool pValue);
  472. /** Explicitly set the embedding extraction folder. If this is never called, the FBX SDK will determine the best folder to extract embedded files.
  473. * \param pExtractionFolder The file path name where the embedded files should be extracted.
  474. */
  475. void SetEmbeddingExtractionFolder(const char* pExtractionFolder);
  476. /** Retrieve the current folder destination where the embedded files will be extracted. This might not be initialized until file I/O is performed.
  477. */
  478. const char* GetEmbeddingExtractionFolder();
  479. /** Check if file is embedded or not.
  480. * \return \c true if file is embedded, false otherwise.
  481. */
  482. bool IsEmbedded() const;
  483. /** Check if file is binary or ASCII
  484. * \return \c true if file is binary, false otherwise.
  485. */
  486. bool IsBinary() const;
  487. /** Return if binary file is encrypted
  488. * \return \c true if file is encrypted, false otherwise.
  489. */
  490. bool IsEncrypted () const;
  491. /** Check CRC code. File must be open, binary and encrypted.
  492. * \return \c true if CRC code is valid or file is not open, binary and encrypted.
  493. */
  494. bool CheckCRC();
  495. /** Return the file version number
  496. * \return the file version number
  497. */
  498. FbxUInt32 GetFileVersionNumber() const;
  499. /** Set the cache size for accelerated IO
  500. * \param pCacheSize cache size to set (Kilo Byte)
  501. */
  502. void CacheSize(FbxUInt32 pCacheSize);
  503. /** Return the current cache size
  504. * \return the current cache size
  505. */
  506. FbxUInt32 CacheSize() const;
  507. //@}
  508. /**
  509. * \name FBX 7 Format specific functions.
  510. The FBX 7 format can compress internal arrays to make the file smaller.
  511. The writer may decide not to compress all arrays, or it may even decide
  512. not to compress anyway. Flags are written in the file to help the FBX7 reader
  513. to know if a decompression is required, on a per-array basis.
  514. The following functions address specific topics of the FBX 7 file format.
  515. */
  516. //@{
  517. //! \return Current state of the flag.
  518. bool Fbx7Support() const;
  519. /** Set the flag state to tell the parser to handle FBX7 files.
  520. * \param pSupport New flag state.
  521. */
  522. void Fbx7Support(bool pSupport);
  523. //! \return Current State of the flag.
  524. bool CompressArrays() const;
  525. /** Set the flag state.
  526. * \param pCompress New flag state.
  527. */
  528. void CompressArrays(bool pCompress);
  529. //! \return Current compression minimum size.
  530. int CompressMinimumSize() const;
  531. /** Set the compression minimum size.
  532. * \param pSize Threshold at which compression may embark.
  533. */
  534. void CompressMinimumSize(int pSize);
  535. //! \return Current compression level.
  536. int CompressLevel() const;
  537. /** Set the compression level.
  538. * \param pLevel Value of the desired compression.
  539. * \remarks The allowed range for pLevel is [0-9] where 0 equals no compression and
  540. * 9 is as-much-as-we-can.
  541. */
  542. void CompressLevel(int pLevel);
  543. //@}
  544. /**
  545. * \name Project related functions used to navigate on particular
  546. * sections.
  547. */
  548. //@{
  549. /** Open the main section of a project.
  550. * \return \c true on success, \c false otherwise.
  551. */
  552. bool ProjectOpenMainSection();
  553. /** Get the number of extension sections of a project.
  554. * \return the number of extension sections of a project.
  555. */
  556. int ProjectGetExtensionSectionCount() const;
  557. /** Open an extension section of a project.
  558. * \param pExtensionSectionIndex
  559. * \return \c true on success, \c false otherwise.
  560. */
  561. bool ProjectOpenExtensionSection(int pExtensionSectionIndex);
  562. /** Create an extension section in a project, not allowed in ASCII and encrypted modes.
  563. * \param pOverwriteLastExtensionSection
  564. * \return \c true on success, \c false otherwise.
  565. */
  566. bool ProjectCreateExtensionSection(bool pOverwriteLastExtensionSection = false);
  567. /** Close current section.
  568. */
  569. void ProjectCloseSection();
  570. /** Get current section.
  571. * \return the current section.
  572. */
  573. int ProjectGetCurrentSection() const;
  574. /** Get current section mode.
  575. * \return the current section mode.
  576. */
  577. int ProjectGetCurrentSectionMode() const;
  578. /** Get current section version.
  579. * \return the current section version.
  580. */
  581. int ProjectGetCurrentSectionVersion() const;
  582. /** Get the version number of a section.
  583. * \param pSection
  584. * \return the version number of a section.
  585. * \remarks For main section it can be either 1000, 2000, 2001, 3000, 3001, 4000, 4001 or 4050.
  586. * For the extension section it can be either 4000, 4001 or 4050.
  587. * Returns 0 if section number does not exist.
  588. */
  589. int ProjectGetSectionVersion(int pSection) const;
  590. /** Split a version number into major, minor and revision numbers.
  591. * \param pVersion Version number to split.
  592. * \param pMajor Integer to receive major version number.
  593. * \param pMinor Integer to receive minor version number.
  594. * \param pRevision Integer to receive revision version number.
  595. */
  596. static void ProjectConvertVersionNumber(int pVersion, int& pMajor, int& pMinor, int& pRevision);
  597. /** Check the password protection flag.
  598. * \return \c true if the current section has a password, \c false otherwise.
  599. */
  600. bool IsPasswordProtected() const;
  601. /** Set password protection flag to \c false if the argument matches the password stored in the section.
  602. * \param pPassword
  603. * \return \c true if the argument matches the password stored in the section, \c false otherwise.
  604. * \remarks This function only works in read mode.
  605. */
  606. bool CheckPassword(const char* pPassword);
  607. /** Encrypt and store password in a section.
  608. * \param pPassword
  609. * \return \c true on success, \c false otherwise.
  610. * \remarks This function only works in write mode and out of any enclosing block.
  611. * \remarks This function must not be called more than once per section.
  612. */
  613. bool WritePassword(const char* pPassword);
  614. //@}
  615. /**
  616. * \name Directory related functions used to get or set file path information.
  617. */
  618. //@{
  619. /** Get project file name.
  620. * \return project file name.
  621. */
  622. const char* GetFilename() const;
  623. /** Get project data directory name.
  624. * \param pAutoCreate
  625. * \return project data directory name.
  626. */
  627. FbxString GetDataDirectory(bool pAutoCreate = true);
  628. /** Get the current embedded folder used by this object.
  629. * \param pCreate Whether create the media or not if no such folder is found
  630. * \param pUserDefinedFolder User define working folder
  631. * \return the current embedded folder used by this object.
  632. * \remarks If ProjectCreateEmbeddedFolder has never been called this will
  633. * return an empty string, unless we're explicitly asked to
  634. * create it.
  635. */
  636. FbxString GetMediaDirectory(bool pCreate = false, const char* pUserDefinedFolder = NULL);
  637. /** Get the full path of the directory to extract the template file.
  638. * \param pTemplateName
  639. * \param pCreate
  640. * \return the full path of the directory to extract the template file.
  641. */
  642. FbxString GetContainerTemplateDirectory(const char* pTemplateName, bool pCreate);
  643. /** Get the path relative to project directory.
  644. * \param pPath
  645. * \return the path relative to project directory.
  646. */
  647. char* GetRelativePath(const char* pPath);
  648. /** Get the file path relative to project directory.
  649. * \param pFilePath
  650. * \return the file path relative to project directory.
  651. */
  652. char* GetRelativeFilePath(const char* pFilePath);
  653. /** Get the full path of path relative to project directory.
  654. * \param pRelativePath
  655. * \return the full path of path relative to project directory.
  656. */
  657. char* GetFullPath(const char* pRelativePath);
  658. /** Get the full file path of path relative to project directory.
  659. * \param pRelativeFilePath
  660. * \return the full file path of path relative to project directory.
  661. */
  662. char* GetFullFilePath(const char* pRelativeFilePath);
  663. /** Get the temporary project name.
  664. * \param pName
  665. * \return the temporary project name.
  666. */
  667. char* GetTmpProjectName(const char* pName) const;
  668. /** Swap from temporary project.
  669. * \param pName
  670. * \param pError
  671. * \param pErrorSize
  672. * \return \c true on success, \c false otherwise.
  673. */
  674. bool SwapFromTmpProject(const char* pName, char* pError=NULL, int pErrorSize=0);
  675. //@}
  676. /**
  677. * \name Read related functions used to get information of a field or a group of fields.
  678. * Can be used to get the field content data or to navigate from field to field.
  679. */
  680. //@{
  681. /** Reset the field read position.
  682. */
  683. void FieldReadResetPosition();
  684. /** Get the number of fields.
  685. * \return the number of fields.
  686. */
  687. int FieldGetCount() const;
  688. /** Get the name of field indexed pFieldIndex.
  689. * \param pFieldIndex
  690. * \return the name of field indexed pFieldIndex.
  691. */
  692. const char* FieldGetName(int pFieldIndex) const;
  693. /** Get number of instance field pFieldName has.
  694. * \param pFieldName
  695. * \return the number of instance field pFieldName has.
  696. */
  697. int FieldGetInstanceCount(const char* pFieldName) const;
  698. /** Start to read field instance referred by field indexed pFieldIndex, instance indexed pInstance.
  699. * \param pFieldIndex
  700. * \param pInstance
  701. * \return \c true on success, \c false otherwise.
  702. */
  703. bool FieldReadBegin(int pFieldIndex, int pInstance);
  704. /** Start to read field pFieldName.
  705. * \param pFieldName
  706. * \return \c true on success, \c false otherwise.
  707. */
  708. bool FieldReadBegin(const char* pFieldName);
  709. /** Start to read field instance referred field pFieldName, instance indexed pInstance.
  710. * \param pFieldName
  711. * \param pInstance
  712. * \return \c true on success, \c false otherwise.
  713. */
  714. bool FieldReadBegin(const char* pFieldName, int pInstance);
  715. //! Stop to read the current field.
  716. void FieldReadEnd();
  717. //! Return if current field is a block.
  718. bool FieldReadIsBlock();
  719. //! Start to read a field block.
  720. bool FieldReadBlockBegin();
  721. //! Stop to read a field block.
  722. void FieldReadBlockEnd();
  723. //! Return the number of read field.
  724. int FieldReadGetCount() const;
  725. //! Return the number of field remaining to be read.
  726. int FieldReadGetRemain() const;
  727. //! Return current field value type.
  728. char FieldReadGetType() const;
  729. //! Return current field value as a char.
  730. char FieldReadCH();
  731. /** Return field pFieldName's value as a char.
  732. * \param pFieldName
  733. * \param pDefault
  734. */
  735. char FieldReadCH(const char* pFieldName, char pDefault=0);
  736. //! Return current field value as a char pointer.
  737. const char* FieldReadC();
  738. /** Return field pFieldName's value as a char pointer.
  739. * \param pFieldName
  740. * \param pDefault
  741. */
  742. const char* FieldReadC(const char* pFieldName, const char* pDefault="");
  743. //! Return current field value as a string (a char pointer).
  744. const char* FieldReadS();
  745. /** Return field pFieldName's value as a char pointer.
  746. * \param pFieldName
  747. * \param pDefault
  748. */
  749. const char* FieldReadS(const char* pFieldName, const char* pDefault="");
  750. //! Return current field value as an bool.
  751. bool FieldReadB();
  752. /** Return field pFieldName's value as an integer.
  753. * \param pFieldName
  754. * \param pDefault
  755. */
  756. bool FieldReadB(const char* pFieldName, bool pDefault = false);
  757. //! Return current field value as an integer.
  758. int FieldReadI();
  759. /** Return field pFieldName's value as an integer.
  760. * \param pFieldName
  761. * \param pDefault
  762. */int FieldReadI(const char* pFieldName, int pDefault=0);
  763. //! Return current field value as an integer.
  764. FbxLongLong FieldReadLL();
  765. /** Return field pFieldName's value as an integer.
  766. * \param pFieldName
  767. * \param pDefault
  768. */
  769. FbxLongLong FieldReadLL(const char* pFieldName, FbxLongLong pDefault=0);
  770. //! Return current field value as a float.
  771. float FieldReadF();
  772. /** Return field pFieldName's value as a float.
  773. * \param pFieldName
  774. * \param pDefault
  775. */
  776. float FieldReadF(const char* pFieldName, float pDefault=0);
  777. //! Return current field value as a double.
  778. double FieldReadD();
  779. /** Return field pFieldName's value as a double.
  780. * \param pFieldName
  781. * \param pDefault
  782. */
  783. double FieldReadD(const char* pFieldName, double pDefault=0);
  784. /** Return field pFieldName's value as a time value.
  785. * \param pFieldName
  786. */
  787. FbxTime FieldReadT(const char* pFieldName);
  788. //! Return field pFieldName's value as a time value.
  789. FbxTime FieldReadT();
  790. /** Return field pFieldName's value as a timespan value.
  791. * \param pFieldName
  792. */
  793. FbxTimeSpan FieldReadTS(const char* pFieldName);
  794. //! Return field pFieldName's value as a timespan value.
  795. FbxTimeSpan FieldReadTS();
  796. /** Return current field value as a n floats array.
  797. * \param pValue
  798. * \param pn
  799. */
  800. void FieldReadFn(float* pValue, FbxUInt pn);
  801. /** Return current field value as a 3 floats array.
  802. * \param pValue
  803. */
  804. void FieldRead3F(float* pValue);
  805. /** Return current field value as a 4 floats array.
  806. * \param pValue
  807. */
  808. void FieldRead4F(float* pValue);
  809. /** Return field pFieldName's value as n floats array.
  810. * \param pFieldName
  811. * \param pValue
  812. * \param pDefault
  813. * \param pn
  814. */
  815. void FieldReadFn(const char* pFieldName, float* pValue, const float *pDefault, FbxUInt pn);
  816. /** Return field pFieldName's value as 4 floats array.
  817. * \param pFieldName
  818. * \param pValue
  819. * \param pDefault
  820. */
  821. void FieldRead3F(const char* pFieldName, float* pValue, const float* pDefault=NULL);
  822. /** Return field pFieldName's value as 3 floats array.
  823. * \param pFieldName
  824. * \param pValue
  825. * \param pDefault
  826. */
  827. void FieldRead4F(const char* pFieldName, float* pValue, const float* pDefault=NULL);
  828. /** Return current field value as a n doubles array.
  829. * \param pValue
  830. * \param pn
  831. */
  832. void FieldReadDn(double* pValue, FbxUInt pn);
  833. /** Return current field value as a 3 doubles array.
  834. * \param pValue
  835. */
  836. void FieldRead3D(double* pValue);
  837. /** Return current field value as a 4 doubles array.
  838. * \param pValue
  839. */
  840. void FieldRead4D(double* pValue);
  841. /** Return field pFieldName's value as n doubles array.
  842. * \param pFieldName
  843. * \param pValue
  844. * \param pDefault
  845. * \param pn
  846. */
  847. void FieldReadDn(const char* pFieldName, double* pValue, const double *pDefault, FbxUInt pn);
  848. /** Return field pFieldName's value as 4 doubles array.
  849. * \param pFieldName
  850. * \param pValue
  851. * \param pDefault
  852. */
  853. void FieldRead3D(const char* pFieldName, double* pValue, const double* pDefault=NULL);
  854. /** Return field pFieldName's value as 3 doubles array.
  855. * \param pFieldName
  856. * \param pValue
  857. * \param pDefault
  858. */
  859. void FieldRead4D(const char* pFieldName, double* pValue, const double* pDefault=NULL);
  860. /** Return current field value as raw data.
  861. * \param pByteSize
  862. */
  863. void* FieldReadR(int* pByteSize);
  864. /** Return field pFieldName's value as raw data.
  865. * \param pFieldName
  866. * \param pByteSize
  867. */
  868. void* FieldReadR(const char* pFieldName,int* pByteSize);
  869. /**
  870. * \name FBX SDK 2009.3 and later
  871. */
  872. //@{
  873. //! Return field pFieldName's value as byte.
  874. FbxChar FieldReadByte();
  875. /** Return field pFieldName's value as a byte value.
  876. * \param pFieldName
  877. * \param pDefault
  878. */
  879. FbxChar FieldReadByte(const char* pFieldName, FbxChar pDefault=0);
  880. //! Return field pFieldName's value as unsigned byte.
  881. FbxUChar FieldReadUByte();
  882. /** Return field pFieldName's value as an unsigned byte value.
  883. * \param pFieldName
  884. * \param pDefault
  885. */
  886. FbxUChar FieldReadUByte(const char* pFieldName, FbxUChar pDefault=0);
  887. //! Return field pFieldName's value as short.
  888. FbxShort FieldReadShort();
  889. /** Return field pFieldName's value as a short value.
  890. * \param pFieldName
  891. * \param pDefault
  892. */
  893. FbxShort FieldReadShort(const char* pFieldName, FbxShort pDefault=0);
  894. //! Return field pFieldName's value as unsigned short.
  895. FbxUShort FieldReadUShort();
  896. /** Return field pFieldName's value as an unsigned short value.
  897. * \param pFieldName
  898. * \param pDefault
  899. */
  900. FbxUShort FieldReadUShort(const char* pFieldName, FbxUShort pDefault=0);
  901. //! Return field pFieldName's value as unsigned integer.
  902. unsigned int FieldReadUI();
  903. /** Return field pFieldName's value as an unsigned int as a value.
  904. * \param pFieldName
  905. * \param pDefault
  906. */
  907. unsigned int FieldReadUI(const char* pFieldName, unsigned int pDefault=0);
  908. //! Return field pFieldName's value as 64 bit unsigned integer.
  909. FbxULongLong FieldReadULL();
  910. /** Return field pFieldName's value as an 64 bit unsigned int as a value.
  911. * \param pFieldName
  912. * \param pDefault
  913. */
  914. FbxULongLong FieldReadULL(const char* pFieldName, FbxULongLong pDefault=0);
  915. /** Read the whole array and return the pointer to it.
  916. * \param pCount Nb of items in the array.
  917. */
  918. const FbxChar* FieldReadArraySBytes( int &pCount );
  919. /** Read the whole array and return the pointer to it.
  920. * \param pCount Nb of items in the array.
  921. */
  922. const FbxShort* FieldReadArrayShort ( int &pCount );
  923. /** Read the whole array and return the pointer to it.
  924. * \param pCount Nb of items in the array.
  925. */
  926. const FbxUShort* FieldReadArrayUShort( int &pCount );
  927. /** Read the whole array and return the pointer to it.
  928. * \param pCount Nb of items in the array.
  929. */
  930. const unsigned int* FieldReadArrayUI ( int &pCount );
  931. /** Read the whole array and return the pointer to it.
  932. * \param pCount Nb of items in the array.
  933. */
  934. const FbxULongLong* FieldReadArrayULL ( int &pCount );
  935. /** Read the whole array and return the pointer to it.
  936. * \param pCount Nb of items in the array.
  937. */
  938. const FbxChar* FieldReadArray(int &pCount, const FbxChar*);
  939. /** Read the whole array and return the pointer to it.
  940. * \param pCount Nb of items in the array.
  941. */
  942. /** Read the whole array and return the pointer to it.
  943. * \param pCount Nb of items in the array.
  944. */
  945. const FbxShort* FieldReadArray(int &pCount, const FbxShort*);
  946. /** Read the whole array and return the pointer to it.
  947. * \param pCount Nb of items in the array.
  948. */
  949. const FbxUShort* FieldReadArray(int &pCount, const FbxUShort*);
  950. /** Read the whole array and return the pointer to it.
  951. * \param pCount Nb of items in the array.
  952. */
  953. const unsigned int* FieldReadArray(int &pCount, const unsigned int*);
  954. /** Read the whole array and return the pointer to it.
  955. * \param pCount Nb of items in the array.
  956. */
  957. const FbxULongLong* FieldReadArray(int &pCount, const FbxULongLong*);
  958. //@}
  959. /** Read field and copy it into a file.
  960. * \param pFileName Embedded file full path+name.
  961. *\param pRelativeFileName Relative path+name of the embedded file.
  962. * \param pEmbeddedMediaDirectory Directory of the embedded media.
  963. * \param pIsFileCreated Status of the extraction of the embedded data. Set to \c true if the embedded media is correctly extracted in the media directory.
  964. * \remarks Only works when file is binary. This function is not related to flag mEmbedded.
  965. * \return \c false if operation failed.
  966. */
  967. virtual bool FieldReadEmbeddedFile (FbxString& pFileName, FbxString& pRelativeFileName, const char* pEmbeddedMediaDirectory = "", bool *pIsFileCreated=NULL);
  968. /** Read the whole array and return the pointer to it.
  969. * \param pCount Nb of items in the array.
  970. */
  971. const double* FieldReadArrayD( int &pCount );
  972. /** Read the whole array and return the pointer to it.
  973. * \param pCount Nb of items in the array.
  974. */
  975. const float* FieldReadArrayF( int &pCount );
  976. /** Read the whole array and return the pointer to it.
  977. * \param pCount Nb of items in the array.
  978. */
  979. const int* FieldReadArrayI( int &pCount );
  980. /** Read the whole array and return the pointer to it.
  981. * \param pCount Nb of items in the array.
  982. */
  983. const FbxLongLong*FieldReadArrayLL(int &pCount );
  984. /** Read the whole array and return the pointer to it.
  985. * \param pCount Nb of items in the array.
  986. */
  987. const bool* FieldReadArrayB( int &pCount );
  988. /** Read the whole array and return the pointer to it.
  989. * \param pCount Nb of items in the array.
  990. */
  991. const FbxUChar* FieldReadArrayBytes( int &pCount );
  992. /** Read the whole array and return the pointer to it.
  993. * \param pCount Nb of items in the array.
  994. */
  995. const int* FieldReadArray(int& pCount, const int*);
  996. /** Read the whole array and return the pointer to it.
  997. * \param pCount Nb of items in the array.
  998. */
  999. const float* FieldReadArray(int& pCount, const float*);
  1000. /** Read the whole array and return the pointer to it.
  1001. * \param pCount Nb of items in the array.
  1002. */
  1003. const double* FieldReadArray(int& pCount, const double*);
  1004. /** Read the whole array and return the pointer to it.
  1005. * \param pCount Nb of items in the array.
  1006. */
  1007. const FbxLongLong* FieldReadArray(int& pCount, const FbxLongLong*);
  1008. /** Read the whole array and return the pointer to it.
  1009. * \param pCount Nb of items in the array.
  1010. */
  1011. const bool* FieldReadArray(int& pCount, const bool*);
  1012. /** Read the whole array and return the pointer to it.
  1013. * \param pCount Nb of items in the array.
  1014. */
  1015. const FbxUChar* FieldReadArray(int& pCount, const FbxUChar*);
  1016. //@}
  1017. /**
  1018. * \name Write related functions used to write information of a field or a group of fields.
  1019. * Can be used to write the field content data or to navigate from field to field.
  1020. */
  1021. //@{
  1022. /** Start to write a field called pFieldName.
  1023. * \param pFieldName
  1024. */
  1025. void FieldWriteBegin(const char* pFieldName);
  1026. //! Stop to write the current field.
  1027. void FieldWriteEnd();
  1028. //! Start to write a field block.
  1029. void FieldWriteBlockBegin();
  1030. /** Start to write an object reference field.
  1031. * \param pObjectType
  1032. * \param pName
  1033. * \param pSubType
  1034. */
  1035. void FieldWriteObjectBegin(const char* pObjectType, const char* pName, const char* pSubType=NULL);
  1036. //! Stop to write an object reference field.
  1037. void FieldWriteObjectEnd();
  1038. /** Start to write a field block in file pFileName.
  1039. * \param pFileName
  1040. * \remarks This function is disabled but kept accessible for the FBX SDK.
  1041. */
  1042. void FieldWriteBlockBegin(const char* pFileName);
  1043. //! Stop to write a block of field.
  1044. void FieldWriteBlockEnd ();
  1045. /** Write field value as a char.
  1046. * \param pValue
  1047. */
  1048. void FieldWriteCH(char pValue);
  1049. /** Write field pFieldName field with a char as a value.
  1050. * \param pFieldName
  1051. * \param pValue
  1052. */
  1053. void FieldWriteCH(const char* pFieldName, char pValue);
  1054. /** Write field value as char pointer pValue.
  1055. * \param pValue
  1056. */
  1057. void FieldWriteC(const char* pValue);
  1058. /** Write field pFieldName with a char pointer as a value.
  1059. * \param pFieldName
  1060. * \param pValue
  1061. */
  1062. void FieldWriteC(const char* pFieldName, const char* pValue);
  1063. /** Write field value as FbxString pValue.
  1064. * \param pValue
  1065. */
  1066. void FieldWriteS(const char* pValue);
  1067. /** Write field value as FbxString pValue.
  1068. * \param pValue
  1069. */
  1070. void FieldWriteS(const FbxString& pValue);
  1071. /** Write field pFieldName field with a FbxString as a value.
  1072. * \param pFieldName
  1073. * \param pValue
  1074. */
  1075. void FieldWriteS(const char* pFieldName, const char* pValue);
  1076. /** Write field pFieldName field with a FbxString as a value.
  1077. * \param pFieldName
  1078. * \param pValue
  1079. */
  1080. void FieldWriteS(const char* pFieldName, const FbxString& pValue);
  1081. /** Write field value as bool.
  1082. * \param pValue
  1083. */
  1084. void FieldWriteB(bool pValue);
  1085. /** Write field pFieldName field with a bool value.
  1086. * \param pFieldName
  1087. * \param pValue
  1088. */
  1089. void FieldWriteB(const char* pFieldName, bool pValue);
  1090. /** Write field value as integer.
  1091. * \param pValue
  1092. */
  1093. void FieldWriteI(int pValue);
  1094. /** Write field pFieldName field with an int as a value.
  1095. * \param pFieldName
  1096. * \param pValue
  1097. */
  1098. void FieldWriteI(const char* pFieldName, int pValue);
  1099. /** Write field value as 64 bit integer.
  1100. * \param pValue
  1101. */
  1102. void FieldWriteLL(FbxLongLong pValue);
  1103. /** Write field pFieldName field with an 64 bit int as a value.
  1104. * \param pFieldName
  1105. * \param pValue
  1106. */
  1107. void FieldWriteLL(const char* pFieldName, FbxLongLong pValue);
  1108. /** Write field value as float.
  1109. * \param pValue
  1110. * \remarks Only compatible with 1) MotionBuilder 4.0 and later 2) FBX SDK 3.6.1 and later.
  1111. */
  1112. void FieldWriteF(float pValue);
  1113. /** Write field pFieldName field with a float as a value.
  1114. * \param pFieldName
  1115. * \param pValue
  1116. * \remarks Only compatible with 1) MotionBuilder 4.0 and later 2) FBX SDK 3.6.1 and later.
  1117. */
  1118. void FieldWriteF(const char* pFieldName, float pValue);
  1119. /** Write field value as double.
  1120. * \param pValue
  1121. */
  1122. void FieldWriteD(double pValue);
  1123. /** Write field pFieldName field with a double as a value.
  1124. * \param pFieldName
  1125. * \param pValue
  1126. */
  1127. void FieldWriteD(const char* pFieldName, double pValue);
  1128. /** Write field value as time value.
  1129. * \param pTime
  1130. */
  1131. void FieldWriteT(FbxTime pTime);
  1132. /** Write field pFieldName field with a time as a value.
  1133. * \param pFieldName
  1134. * \param pValue
  1135. */
  1136. void FieldWriteT(const char* pFieldName,FbxTime pValue);
  1137. /** Write field value as timespan value.
  1138. * \param pTimeSpan
  1139. */
  1140. void FieldWriteTS(FbxTimeSpan pTimeSpan);
  1141. /** Write field pFieldName field with a timespan as a value.
  1142. * \param pFieldName
  1143. * \param pValue
  1144. */
  1145. void FieldWriteTS(const char* pFieldName,FbxTimeSpan pValue);
  1146. /** Write field value as an array of n floats (nF vector).
  1147. * \param pValue
  1148. * \param pn
  1149. */
  1150. void FieldWriteFn(const float* pValue, FbxUInt pn);
  1151. /** Write field pFieldName field with a array of n floats as a value.
  1152. * \param pFieldName
  1153. * \param pValue
  1154. * \param pn
  1155. */
  1156. void FieldWriteFn(const char* pFieldName, const float* pValue, FbxUInt pn);
  1157. /** Write field value as an array of 3 floats (3F vector).
  1158. * \param pValue
  1159. */
  1160. void FieldWrite3F(const float* pValue);
  1161. /** Write field pFieldName field with a array of 3 floats as a value.
  1162. * \param pFieldName
  1163. * \param pValue
  1164. */
  1165. void FieldWrite3F(const char* pFieldName, const float* pValue);
  1166. /** Write field value as an array of 4 floats (4F vector).
  1167. * \param pValue
  1168. */
  1169. void FieldWrite4F(const float* pValue);
  1170. /** Write field pFieldName field with a array of 4 floats as a value.
  1171. * \param pFieldName
  1172. * \param pValue
  1173. */
  1174. void FieldWrite4F(const char* pFieldName, const float* pValue);
  1175. /** Write field value as an array of n doubles (nD vector).
  1176. * \param pValue
  1177. * \param pn
  1178. */
  1179. void FieldWriteDn(const double* pValue, FbxUInt pn);
  1180. /** Write field pFieldName field with a array of n doubles as a value.
  1181. * \param pFieldName
  1182. * \param pValue
  1183. * \param pn
  1184. */
  1185. void FieldWriteDn(const char* pFieldName, const double* pValue, FbxUInt pn);
  1186. /** Write field value as an array of 3 doubles (3D vector).
  1187. * \param pValue
  1188. */
  1189. void FieldWrite3D(const double* pValue);
  1190. /** Write field pFieldName field with a array of 3 doubles as a value.
  1191. * \param pFieldName
  1192. * \param pValue
  1193. */
  1194. void FieldWrite3D(const char* pFieldName, const double* pValue);
  1195. /** Write field value as an array of 4 doubles (4D vector).
  1196. * \param pValue
  1197. */
  1198. void FieldWrite4D(const double* pValue);
  1199. /** Write field pFieldName field with a array of 4 doubles as a value.
  1200. * \param pFieldName
  1201. * \param pValue
  1202. */
  1203. void FieldWrite4D(const char* pFieldName, const double* pValue);
  1204. // The maximum number of value entries is, in theory, 2**32. In practice it should be a lot less than that.
  1205. // pSize is the number of values to write from each pointer location, and stride is how much we
  1206. // advance to get to the next value; if the stride is zero, values are tighly packed together.
  1207. // So in total we'll write n * pSize items.
  1208. /** Write array to file.
  1209. * \param n Nb of items in the array.
  1210. * \param pValue Pointer to the data.
  1211. * \param pSize Size of each item in the array.
  1212. * \param pStride Array stride.
  1213. */
  1214. void FieldWriteArrayD( int n, const double* pValue, int pSize = 1, int pStride = 0 );
  1215. /** Write array to file.
  1216. * \param n Nb of items in the array.
  1217. * \param pValue Pointer to the data.
  1218. * \param pSize Size of each item in the array.
  1219. * \param pStride Array stride.
  1220. */
  1221. void FieldWriteArrayF( int n, const float* pValue, int pSize = 1, int pStride = 0 );
  1222. /** Write array to file.
  1223. * \param n Nb of items in the array.
  1224. * \param pValue Pointer to the data.
  1225. * \param pSize Size of each item in the array.
  1226. * \param pStride Array stride.
  1227. */
  1228. void FieldWriteArrayI( int n, const int* pValue, int pSize = 1, int pStride = 0 );
  1229. /** Write array to file.
  1230. * \param n Nb of items in the array.
  1231. * \param pValue Pointer to the data.
  1232. * \param pSize Size of each item in the array.
  1233. * \param pStride Array stride.
  1234. */
  1235. void FieldWriteArrayLL(int n, const FbxLongLong* pValue, int pSize = 1, int pStride = 0 );
  1236. /** Write array to file.
  1237. * \param n Nb of items in the array.
  1238. * \param pValue Pointer to the data.
  1239. * \param pSize Size of each item in the array.
  1240. * \param pStride Array stride.
  1241. */
  1242. void FieldWriteArrayB( int n, const bool* pValue, int pSize = 1, int pStride = 0 );
  1243. /** Write array to file.
  1244. * \param n Nb of items in the array.
  1245. * \param pValue Pointer to the data.
  1246. * \param pSize Size of each item in the array.
  1247. * \param pStride Array stride.
  1248. */
  1249. void FieldWriteArrayBytes( int n, const FbxUChar* pValue, int pSize = 1, int pStride = 0 );
  1250. /** Write field value as a raw data.
  1251. * \param pRawData
  1252. * \param pByteSize
  1253. */
  1254. void FieldWriteR(const void* pRawData, int pByteSize);
  1255. /** Write field pFieldName field with raw data as a value.
  1256. * \param pFieldName
  1257. * \param pRawData
  1258. * \param pByteSize
  1259. */
  1260. void FieldWriteR(const char* pFieldName, const void* pRawData, int pByteSize);
  1261. /**
  1262. * \name FBX SDK 2009.3 and later
  1263. */
  1264. //@{
  1265. /** Write field value as byte.
  1266. * \param pValue
  1267. */
  1268. void FieldWriteByte(FbxChar pValue);
  1269. /** Write field pFieldName field with a byte value.
  1270. * \param pFieldName
  1271. * \param pValue
  1272. */
  1273. void FieldWriteByte(const char* pFieldName, FbxChar pValue);
  1274. /** Write field value as unsigned byte.
  1275. * \param pValue
  1276. */
  1277. void FieldWriteUByte(FbxUChar pValue);
  1278. /** Write field pFieldName field with an unsigned byte value.
  1279. * \param pFieldName
  1280. * \param pValue
  1281. */
  1282. void FieldWriteUByte(const char* pFieldName, FbxUChar pValue);
  1283. /** Write field value as short.
  1284. * \param pValue
  1285. */
  1286. void FieldWriteShort(FbxShort pValue);
  1287. /** Write field pFieldName field with a short value.
  1288. * \param pFieldName
  1289. * \param pValue
  1290. */
  1291. void FieldWriteShort(const char* pFieldName, FbxShort pValue);
  1292. /** Write field value as unsigned short.
  1293. * \param pValue
  1294. */
  1295. void FieldWriteUShort(FbxUShort pValue);
  1296. /** Write field pFieldName field with an unsigned short value.
  1297. * \param pFieldName
  1298. * \param pValue
  1299. */
  1300. void FieldWriteUShort(const char* pFieldName, FbxUShort pValue);
  1301. /** Write field value as an unsigned integer.
  1302. * \param pValue
  1303. */
  1304. void FieldWriteUI(unsigned int pValue);
  1305. /** Write field pFieldName field with an unsigned int as a value.
  1306. * \param pFieldName
  1307. * \param pValue
  1308. */
  1309. void FieldWriteUI(const char* pFieldName, unsigned int pValue);
  1310. /** Write field value as 64 bit unsigned integer.
  1311. * \param pValue
  1312. */
  1313. void FieldWriteULL(FbxULongLong pValue);
  1314. /** Write field pFieldName field with an 64 bit unsigned int as a value.
  1315. * \param pFieldName
  1316. * \param pValue
  1317. * \return void
  1318. */
  1319. void FieldWriteULL(const char* pFieldName, FbxULongLong pValue);
  1320. /** Write array to file.
  1321. * \param n Nb of items in the array.
  1322. * \param pValue Pointer to the data.
  1323. * \param pSize Size of each item in the array.
  1324. * \param pStride Array stride.
  1325. */
  1326. void FieldWriteArraySBytes( int n, const FbxChar* pValue, int pSize = 1, int pStride = 0 );
  1327. /** Write array to file.
  1328. * \param n Nb of items in the array.
  1329. * \param pValue Pointer to the data.
  1330. * \param pSize Size of each item in the array.
  1331. * \param pStride Array stride.
  1332. */
  1333. void FieldWriteArrayShort( int n, const FbxShort* pValue, int pSize = 1, int pStride = 0 );
  1334. /** Write array to file.
  1335. * \param n Nb of items in the array.
  1336. * \param pValue Pointer to the data.
  1337. * \param pSize Size of each item in the array.
  1338. * \param pStride Array stride.
  1339. */
  1340. void FieldWriteArrayUShort( int n, const FbxUShort* pValue, int pSize = 1, int pStride = 0 );
  1341. /** Write array to file.
  1342. * \param n Nb of items in the array.
  1343. * \param pValue Pointer to the data.
  1344. * \param pSize Size of each item in the array.
  1345. * \param pStride Array stride.
  1346. */
  1347. void FieldWriteArrayUI( int n, const unsigned int* pValue, int pSize = 1, int pStride = 0 );
  1348. /** Write array to file.
  1349. * \param n Nb of items in the array.
  1350. * \param pValue Pointer to the data.
  1351. * \param pSize Size of each item in the array.
  1352. * \param pStride Array stride.
  1353. */
  1354. void FieldWriteArrayULL(int n, const FbxULongLong* pValue, int pSize = 1, int pStride = 0 );
  1355. //@}
  1356. /** ASCII files may limit how big you can write your raw data, forcing you to break it down into chunks.
  1357. * \return int
  1358. */
  1359. int GetFieldRMaxChunkSize() const;
  1360. /** Write object reference pName in the current field.
  1361. * \param pName
  1362. */
  1363. void FieldWriteObjectReference(const char* pName);
  1364. /** Write object reference pName in field pFieldName.
  1365. * \param pFieldName
  1366. * \param pName
  1367. */
  1368. void FieldWriteObjectReference(const char* pFieldName, const char* pName);
  1369. /** Write field with file content as a value.
  1370. * \param pFileName
  1371. * \param pRelativeFileName
  1372. * \remarks Only works when file is binary. This function is not related to flag mEmbedded.
  1373. * \return \c false if operation failed.
  1374. */
  1375. bool FieldWriteEmbeddedFile (FbxString pFileName, FbxString pRelativeFileName);
  1376. /** Write comments, only effective in ASCII mode.
  1377. * \param pFieldName
  1378. */
  1379. void WriteComments(const char* pFieldName);
  1380. //@}
  1381. #ifdef _DEBUG
  1382. // Dump function for debugging purpose only
  1383. void StdoutDump();
  1384. #endif
  1385. /** Get if the embedded file is currently loaded
  1386. * \return true if loaded, false otherwise
  1387. * \remarks An embedded file is a file like a JPEG image used for texture or an AVI file for video.
  1388. * When files are embedded, the size of the FBX file can be very large since other files are embedded in it.
  1389. * FBX Version 6 and lower cannot embed files when saved in ASCII.
  1390. * FBX Version 7 and over can embed files even when saved in ASCII mode.
  1391. */
  1392. bool GetHaveLoadedEmbededFile() const;
  1393. /** Get the maximum byte count written
  1394. * \param pMemPtr The address of the memory file
  1395. * \param[out] pSize Stores the maximum byte count written
  1396. */
  1397. void GetMemoryFileInfo(void** pMemPtr, size_t& pSize) const;
  1398. /** Get a internal flag to manage pre FBX version 6 data format
  1399. * Used for backwards compatibility
  1400. */
  1401. bool IsBeforeVersion6() const;
  1402. /** Set a internal flag to manage pre FBX version 6 data format
  1403. * Used for backwards compatibility
  1404. */
  1405. void SetIsBeforeVersion6(bool pIsBeforeVersion6);
  1406. /*****************************************************************************************************************************
  1407. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  1408. *****************************************************************************************************************************/
  1409. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  1410. bool ProjectOpen (FbxFile * pFile, FbxReader* pReader, bool pCheckCRC = false, bool pOpenMainSection = true, FbxIOFileHeaderInfo* pFileHeaderInfo = NULL);
  1411. private:
  1412. // to resolve warning C4512: 'class' : assignment operator could not be generated
  1413. FbxIO& operator=(const FbxIO& pOther);
  1414. FbxStatus& mStatus;
  1415. struct InternalImpl;
  1416. struct InternalImpl32;
  1417. struct InternalImpl64;
  1418. InternalImpl* mImpl;
  1419. //! Project Global
  1420. void ProjectClear();
  1421. void ProjectReset();
  1422. bool ProjectReadHeader(bool pCheckASCIIHeader, bool pCheckCRC, bool pOpenMainSection, FbxIOFileHeaderInfo* pFileHeaderInfo);
  1423. bool ProjectReadExtendedHeader(FbxInt64& pExtendedHeaderEnd, FbxIOFileHeaderInfo* pFileHeaderInfo);
  1424. bool BinaryReadHeader();
  1425. bool BinaryReadSectionPosition();
  1426. bool ASCIIReadHeader();
  1427. bool ASCIIReadSectionPosition();
  1428. bool ProjectWriteHeader(FbxIOFileHeaderInfo* pFileHeaderInfo);
  1429. bool ProjectWriteExtendedHeader(FbxIOFileHeaderInfo* pFileHeaderInfo);
  1430. void BinaryWriteHeader();
  1431. void ASCIIWriteHeader();
  1432. void ReadEncryptionKey(char* pEncryptionKey);
  1433. void WriteEncryptionKey(char* pEncryptionKey);
  1434. //! Project Section
  1435. bool ProjectClearSection();
  1436. bool ProjectOpenSection(int pSection);
  1437. bool BinaryReadSectionHeader();
  1438. FbxInt64 BinaryReadSectionFooter(char* pSourceCheck);
  1439. bool BinaryReadExtensionCode(FbxInt64 pFollowingSectionStart, FbxInt64& pSectionStart, FbxUInt32& pSectionVersion);
  1440. void BinaryReadSectionPassword();
  1441. bool ProjectWriteSectionHeader();
  1442. void BinaryWriteSectionFooter();
  1443. bool BinaryWriteExtensionCode(FbxInt64 pSectionStart, FbxUInt32 pSectionVersion);
  1444. FbxString GetCreationTime() const;
  1445. void SetCreationTime(FbxString pCreationTime);
  1446. void CreateSourceCheck(char* lSourceCheck);
  1447. bool TestSourceCheck(char* pSourceCheck, char* pSourceCompany);
  1448. FbxString GetMangledCreationTime();
  1449. void EncryptSourceCheck(char* pSourceCheck, char* pEncryptionData);
  1450. void DecryptSourceCheck(char* pSourceCheck, const char* pEncryptionData);
  1451. void EncryptPasswordV1(FbxString pOriginalPassword, FbxString &pEncryptedPassword);
  1452. void DecryptPasswordV1(FbxString pEncryptedPassword, FbxString &pDecryptedPassword);
  1453. //! Read
  1454. void CheckValidityOfFieldName(const char* pFieldName);
  1455. void GetUnusedEmbeddedName(const FbxString& pDirectory, const FbxString& pName, FbxString& pResult, bool pCreateSubdirectory);
  1456. //! Get project media directory name
  1457. FbxString GetDirectory(bool pAutoCreate, const char* pExtension);
  1458. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  1459. };
  1460. #include <fbxsdk/fbxsdk_nsend.h>
  1461. #endif /* _FBXSDK_FILEIO_FBX_IO_H_ */