fbxiosettings.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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 fbxiosettings.h
  9. #ifndef _FBXSDK_FILEIO_IO_SETTINGS_H_
  10. #define _FBXSDK_FILEIO_IO_SETTINGS_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/core/fbxobject.h>
  13. #include <fbxsdk/fileio/fbxiosettingspath.h>
  14. #include <fbxsdk/fbxsdk_nsbegin.h>
  15. //Undefine the macro mkdir, since it conflict with function mkdir in Qt\4.2.3\src\corelib\io\qdir.h
  16. #if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(mkdir)
  17. #undef mkdir
  18. #endif
  19. #define IOSVisible true
  20. #define IOSHidden false
  21. #define IOSSavable true
  22. #define IOSNotSavable false
  23. #define IOSEnabled true
  24. #define IOSDisabled false
  25. #define IOSBinary 0
  26. #define IOSASCII 1
  27. class FbxManager;
  28. class FbxIOSettings;
  29. /*****************************************************************************************************************************
  30. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  31. *****************************************************************************************************************************/
  32. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  33. class FbxIOPropInfo
  34. {
  35. public:
  36. FbxIOPropInfo();
  37. ~FbxIOPropInfo();
  38. void* UIWidget; // UI widget for showing the property
  39. void* cbValueChanged; // call back when value changed
  40. void* cbDirty; // call back when value changed
  41. FbxStringList labels; // list of labels in many languages
  42. };
  43. class FBXSDK_DLL FbxIOInfo
  44. {
  45. public:
  46. enum EImpExp {eImport, eExport};
  47. FbxIOInfo();
  48. void Reset(EImpExp pImpExp);
  49. void SetTimeMode(FbxTime::EMode pTimeMode, double pCustomFrameRate = 0.0);
  50. FbxTime::EMode GetTimeMode(){ return mTimeMode; }
  51. FbxTime GetFramePeriod();
  52. void SetASFScene(FbxObject* pASFScene, bool pASFSceneOwned = false);
  53. FbxObject* GetASFScene(){ return mASFScene; }
  54. void Set_IOS(FbxIOSettings* pIOS){ios = pIOS;}
  55. void SetImportExportMode(EImpExp pImpExp){mImpExp = pImpExp;}
  56. private:
  57. FbxTime::EMode mTimeMode;
  58. FbxObject* mASFScene;
  59. EImpExp mImpExp;
  60. FbxIOSettings* ios;
  61. };
  62. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  63. /** FbxIOSettings is a collection of properties, arranged as a tree, that
  64. * can be used by FBX file readers and writers to represent import and export
  65. * options.
  66. * It is primarily used by FBX importers (FbxImporter) and FBX exporter (FbxExporter)
  67. * when reading or writing data from or to a disk.
  68. * The FBX plugins of some Autodesk products expose a UI representing the content of those options
  69. * to let users see and choose options when an import or export operation is about to be done.
  70. * The tree of options is extensible.
  71. *
  72. * Options can be saved or loaded from an XML file using the functions:
  73. * ReadXMLFile(), WriteXMLFile(), WriteXmlPropToFile(). This functionality can be useful
  74. * for plugins that use preset files.
  75. *
  76. * An instance of FbxIOSettings must be created to be used before an import/export operation.
  77. * When a new FbxIOSettings instance is created, all options are created with default values.
  78. * The new instance of FbxIOSettings can be passed to the FbxManager,
  79. * this way that instance will be used by all import/export operations.
  80. *
  81. * Ex: to set an instance of FbxIOSettings to the FbxManager
  82. *
  83. * \code
  84. * // First create a new instance of FbxIOSettings
  85. * FbxIOSettings * ios = FbxIOSettings::Create((FbxManager *) mManager, IOSROOT);
  86. * // then set the FbxManager
  87. * mManager->SetIOSettings(ios);
  88. * \endcode
  89. *
  90. * It's also possible for a developer to create another instance
  91. * of FbxIOSettings, set particular options and use it for import/export operation.
  92. *
  93. * Ex: to set an instance of FbxIOSettings to a FbxImporter/FbxExporter
  94. * \code
  95. * mImporter->SetIOSettings(ios); / mExporter->SetIOSettings(ios);
  96. * \endcode
  97. *
  98. * A schematic view of the FbxIOSettings tree :
  99. *
  100. * \verbatim
  101. OPTION_GROUP_ROOT (IOSROOT)
  102. |
  103. |
  104. ________________________________________
  105. | |
  106. -OPTION_GROUP_EXPORT (IOSN_EXPORT) -OPTION_GROUP_IMPORT (IOSN_IMPORT)
  107. | |
  108. -OPTION_GROUP_A -OPTION_GROUP_A
  109. | | | |
  110. | -OPTION_A | -OPTION_A
  111. | -OPTION_B | -OPTION_B
  112. | |
  113. -OPTION_GROUP_B -OPTION_GROUP_B
  114. | | | |
  115. | -OPTION_GROUP_A | -OPTION_GROUP_A
  116. | | | | | |
  117. | | -OPTION_A | | -OPTION_A
  118. | | -OPTION_B | | -OPTION_B
  119. | | | |
  120. | -OPTION_GROUP_B | -OPTION_GROUP_B
  121. | | | |
  122. | -OPTION_A | -OPTION_A
  123. | -OPTION_B | -OPTION_B
  124. | |
  125. -OPTION_GROUP_C -OPTION_GROUP_C
  126. | |
  127. -OPTION_A -OPTION_A
  128. \endverbatim
  129. *
  130. * Any group of options can contain sub options, or group of sub options.
  131. * To access an option value, we must pass the full path to the Get/Set functions
  132. * Ex:
  133. * \code
  134. * ios->GetBoolProp("Import|IncludeGrp|Animation", true); // the root node name is not required
  135. * \endcode
  136. *
  137. * All options path are defined in the file kfbxiosettingspath.h to ease the access of any options.
  138. * Then "Import|IncludeGrp|Animation" == IMP_ANIMATION since IMP_ANIMATION is defined in kfbxiosettingspath.h
  139. * All options defined path start with "IMP_" for import branch or "EXP_" for export branch.
  140. *
  141. * We strongly encourage to use the defined path in kfbxiosettingspath.h, this way if the parent group of an option is changed
  142. * the change occur only in kfbxiosettingspath.h not in the code elsewhere.
  143. *
  144. * Ex: to get the boolean import "Animation" option
  145. * \code
  146. * bool anim = ios->GetBoolProp(IMP_ANIMATION, true); // will return true if not found, since we pass true as second param
  147. * \endcode
  148. *
  149. * Ex: to set the boolean import "Animation" option to false
  150. * \code
  151. * ios->SetBoolProp(IMP_ANIMATION, false);
  152. * \endcode
  153. *
  154. * Ex: to create a new option group under the "Import" branch
  155. * \code
  156. * // get the parent "Import" property
  157. * FbxProperty import_Group = ios->GetProperty( IOSN_IMPORT ); // IOSN_IMPORT is defined as "Import" in kfbxiosettingspath.h
  158. * if(import_Group.IsValid()) // check if we have found the IOSN_IMPORT parent option
  159. * {
  160. * // add a new group of options "myOptionGroup"
  161. * FbxProperty myOptionGrp = ios->AddPropertyGroup(import_Group, "myOptionGroup", FbxStringDT, "My Option Group UI Label");
  162. * }
  163. * \endcode
  164. *
  165. * Ex: to create a new boolean option under the "myOptionGroup"
  166. * \code
  167. * FbxProperty myOptionGrp = ios->GetProperty( "Import|myOptionGroup" ); // can also use IOSN_IMPORT|"myOptionGroup"
  168. * if(myOptionGrp.IsValid()) // check if we have found the "myOptionGroup"
  169. * {
  170. * bool defaultValue = true;
  171. * FbxProperty myOption = ios->AddProperty(myOptionGrp, "myOptionName", FbxBoolDT, "My Option UI label" , &defaultValue, eFbxBool);
  172. * }
  173. * \endcode
  174. *
  175. * Ex: to set some flags to myOption
  176. * \code
  177. * FbxProperty myOption = ios->GetProperty( "Import|myOptionGroup|myOptionName" );
  178. * if(myOption.IsValid())
  179. * {
  180. * myOPtion.ModifyFlag(FbxPropertyFlags::eUIHidden, true); // to make that option not visible to the UI
  181. * myOPtion.ModifyFlag(FbxPropertyFlags::eNotSavable, true); // to avoid the read/save of that option in XML file
  182. * }
  183. * \endcode
  184. */
  185. class FBXSDK_DLL FbxIOSettings : public FbxObject
  186. {
  187. FBXSDK_OBJECT_DECLARE(FbxIOSettings, FbxObject);
  188. public:
  189. //! Supported languages enumeration list
  190. enum ELanguage
  191. {
  192. eENU, //!< 409 English - United States
  193. eDEU, //!< 407 German - Germany
  194. eFRA, //!< 40c French - France
  195. eJPN, //!< 411 Japanese - Japan
  196. eKOR, //!< 412 Korean(Extended Wansung) - Korea
  197. eCHS, //!< 804 Chinese - PRC
  198. eLanguageCount //!< Total language count
  199. };
  200. /** Add a property group under the root prop to be a direct child of IOSROOT
  201. * \param pName
  202. * \param pDataType
  203. * \param pLabel
  204. * \return a new FbxProperty created
  205. */
  206. FbxProperty AddPropertyGroup(const char* pName, const FbxDataType& pDataType=FbxDataType(), const char* pLabel="");
  207. /** Add a property group under another parent property
  208. * \param pParentProperty
  209. * \param pName
  210. * \param pDataType
  211. * \param pLabel (optional, used by the UI as widget label)
  212. * \param pVisible (used by the UI to show or not that property)
  213. * \param pSavable (to enable a read & write to an XML file)
  214. * \param pEnabled (used by the widget UI to show enabled or disabled)
  215. * \return a new FbxProperty created
  216. */
  217. FbxProperty AddPropertyGroup(const FbxProperty& pParentProperty, const char* pName, const FbxDataType& pDataType = FbxDataType(),
  218. const char* pLabel = "", bool pVisible = true, bool pSavable = true, bool pEnabled = true );
  219. /** Add a property under another parent property with a value to set
  220. * \param pParentProperty
  221. * \param pName
  222. * \param pDataType
  223. * \param pLabel (optional, used by the UI as widget label)
  224. * \param pValue
  225. * \param pVisible (used by the UI to show or not that property)
  226. * \param pSavable (to enable a read & write to an XML file)
  227. * \param pEnabled (used by the widget UI to show enabled or disabled)
  228. * \return a new FbxProperty created
  229. */
  230. FbxProperty AddProperty(const FbxProperty& pParentProperty, const char* pName, const FbxDataType& pDataType = FbxDataType(),
  231. const char* pLabel = "", const void* pValue = NULL, bool pVisible = true,
  232. bool pSavable = true, bool pEnabled = true );
  233. /** Add a property under another parent property with a value to set and a min max values
  234. * \param pParentProperty
  235. * \param pName
  236. * \param pDataType
  237. * \param pLabel (optional, used by the UI as widget label)
  238. * \param pValue
  239. * \param pMinValue
  240. * \param pMaxValue
  241. * \param pVisible (used by the UI to show or not that property)
  242. * \param pSavable (to enable a read & write to an XML file)
  243. * \param pEnabled (used by the widget UI to show enabled or disabled)
  244. * \return a new FbxProperty created
  245. * \remarks Normally used with numeric properties Ex: integer, float, double, etc.
  246. */
  247. FbxProperty AddPropertyMinMax(const FbxProperty& pParentProperty, const char* pName, const FbxDataType& pDataType = FbxDataType(),
  248. const char* pLabel = "", const void* pValue = NULL, const double* pMinValue = NULL, const double* pMaxValue = NULL,
  249. bool pVisible = true, bool pSavable = true, bool pEnabled = true );
  250. /** Get a property using the full path in the tree ex: "Export|IncludeGrp|Animation"
  251. * \param pName
  252. * \return a FbxProperty found
  253. * \remarks We strongly encourage to use the defined path in kfbxiosettingspath.h
  254. * ex: EXP_ANIMATION == "Export|IncludeGrp|Animation"
  255. */
  256. FbxProperty GetProperty(const char* pName) const;
  257. /** Get a property using a short path found under the parent property.
  258. * \param pParentProperty
  259. * \param pName
  260. * \return a FbxProperty found
  261. * \remarks This is a faster way to access a property when the parent is known
  262. */
  263. FbxProperty GetProperty(const FbxProperty& pParentProperty, const char* pName) const;
  264. /** Get a bool property value using the full path
  265. * \param pName
  266. * \param pDefValue Value returned if the property is not found
  267. * \return true or false
  268. */
  269. bool GetBoolProp(const char* pName, bool pDefValue) const;
  270. /** set a bool property value using the full path
  271. * \param pName
  272. * \param pValue
  273. */
  274. void SetBoolProp(const char* pName, bool pValue);
  275. /** Get a double property value using the full path
  276. * \param pName
  277. * \param pDefValue Value returned if the property is not found
  278. * \return a double
  279. */
  280. double GetDoubleProp(const char* pName, double pDefValue) const;
  281. /** Set a double property using the full path
  282. * \param pName
  283. * \param pValue
  284. */
  285. void SetDoubleProp(const char* pName, double pValue);
  286. /** Get a int property value using the full path
  287. * \param pName
  288. * \param pDefValue Value returned if the property is not found
  289. * \return a int
  290. */
  291. int GetIntProp(const char* pName, int pDefValue) const;
  292. /** Set a int property value using the full path
  293. * \param pName
  294. * \param pValue
  295. */
  296. void SetIntProp(const char* pName, int pValue);
  297. /** Get a FbxTime property value using the full path
  298. * \param pName
  299. * \param pDefValue Value returned if the property is not found
  300. */
  301. FbxTime GetTimeProp(const char* pName, FbxTime pDefValue) const;
  302. /** Set a FbxTime property value using the full path
  303. * \param pName
  304. * \param pValue
  305. * \return a FbxTime
  306. */
  307. void SetTimeProp(const char* pName, FbxTime pValue);
  308. /** \name Enum Properties
  309. * An enum property is a list of FbxString and integer pairs.
  310. * A current index value is available to get the selected pair
  311. * of FbxString+integer
  312. *
  313. * Ex: Content of an enum property
  314. * \code
  315. * 0 -> (14, "Bird")
  316. * 1 -> (17, "Horse")
  317. * 2 -> (93, "Cat")
  318. * 3 -> (45, "Dog")
  319. * \endcode
  320. *
  321. * If current index is 2: the current int value is 93,
  322. * and the current FbxString value is "Cat"
  323. */
  324. //@{
  325. /** Get the FbxString at current index of an enum property using the full path.
  326. * \param pName
  327. * \param pDefValue Value returned if the property is not found
  328. * \return a FbxString
  329. */
  330. FbxString GetEnumProp(const char* pName, FbxString pDefValue) const;
  331. /** Get the integer at current index of an enum property using the full path.
  332. * \param pName
  333. * \param pDefValue Value returned if the property is not found
  334. * \return a int
  335. */
  336. int GetEnumProp(const char* pName, int pDefValue) const;
  337. /** Get the index of a FbxString from the enum property using the full path.
  338. * \param pName
  339. * \param pValue Return -1 if the FbxString is not found
  340. * \return a int
  341. */
  342. int GetEnumIndex(const char* pName, FbxString pValue) const;
  343. /** Set the current index using an existing FbxString of an enum property using the full path.
  344. * \param pName
  345. * \param pValue
  346. * \remarks The current index will not change if the FbxString is not found
  347. */
  348. void SetEnumProp(const char* pName, FbxString pValue);
  349. /** Set the current index of an enum property using the full path.
  350. * \param pName
  351. * \param pValue
  352. * \remarks The current index will not change if the pValue is out of bound
  353. */
  354. void SetEnumProp(const char* pName, int pValue);
  355. /** Remove a pair of FbxString+integer from an enum property.
  356. * \param pName
  357. * \param pValue The FbxString to find
  358. * \remarks The first FbxString found from 0 index will be removed only even
  359. * if the same FbxString exist in other index, if the current index was on the FbxString found
  360. * the current index will be set to 0
  361. */
  362. void RemoveEnumPropValue(const char* pName, FbxString pValue);
  363. /** Empty all the FbxString+integer pair of the enum property
  364. * \param pName
  365. */
  366. void EmptyEnumProp(const char* pName);
  367. /** Check if a FbxString is present in the enum property.
  368. * \param &pProp a ref to an enum prop
  369. * \param &enumString ref to a FbxString to find
  370. * \return \c true if found, \c false otherwise.
  371. */
  372. bool IsEnumExist(FbxProperty& pProp, const FbxString& enumString) const;
  373. /** Get the enum index of a FbxString
  374. * \param &pProp a ref to an enum prop
  375. * \param &enumString ref to string to find
  376. * \param pNoCase To match case sensitive or not
  377. * \return the index found or -1 if not found
  378. */
  379. int GetEnumIndex(FbxProperty& pProp, const FbxString& enumString, bool pNoCase = false) const;
  380. //@}
  381. /** Set a specific flag value on a property using the full path
  382. * \param pName
  383. * \param propFlag
  384. * \param pValue
  385. * \return Always true
  386. */
  387. bool SetFlag(const char* pName, FbxPropertyFlags::EFlags propFlag, bool pValue);
  388. /** Get a FbxString property value using the full path.
  389. * \param pName
  390. * \param pDefValue Value returned if the property is not found
  391. * \return The FbxString value
  392. */
  393. FbxString GetStringProp(const char* pName, FbxString pDefValue) const;
  394. /** Set a FbxString property value using the full path
  395. * \param pName
  396. * \param pValue
  397. */
  398. void SetStringProp(const char* pName, FbxString pValue);
  399. /** \name XML Serialization Functions */
  400. //@{
  401. /** Load the settings values from an XML file.
  402. * \param path The path of the XML file.
  403. * \return \c True on success, \c false otherwise.
  404. */
  405. virtual bool ReadXMLFile(const FbxString& path);
  406. /** Write the settings values to an XML file.
  407. * \param path The path of the XML file.
  408. * \return \c True on success, \c false otherwise.
  409. * \remarks The flag of the property must be FbxPropertyFlags::eNotSavable == false
  410. */
  411. virtual bool WriteXMLFile(const FbxString& path);
  412. /** Write the settings values to an XML file.
  413. * \param pFullPath The path of the XML file.
  414. * \param propPath a prop Path
  415. * \return \c True on success, \c false otherwise.
  416. * \remarks To save only a branch of the settings ex: Import branch only
  417. */
  418. bool WriteXmlPropToFile(const FbxString& pFullPath, const FbxString& propPath);
  419. //@}
  420. /*****************************************************************************************************************************
  421. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  422. *****************************************************************************************************************************/
  423. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  424. FbxIOPropInfo* GetPropInfo(FbxProperty &pProp);
  425. ELanguage UILanguage;
  426. FbxString GetLanguageLabel(FbxProperty& pProp);
  427. void SetLanguageLabel(FbxProperty& pProp, FbxString& pLabel);
  428. ELanguage Get_Max_Runtime_Language(FbxString pRegLocation);
  429. FbxIOInfo impInfo;
  430. FbxIOInfo expInfo;
  431. static FbxString GetUserMyDocumentDir();
  432. void SetPropVisible(FbxProperty& pProp, bool pWithChildren, bool pVisible);
  433. // Read an XML file from MyDocument dir
  434. bool ReadXmlPropFromMyDocument(const FbxString& subDir, const FbxString& filename);
  435. // Write property branch to an XML file in MyDocument dir
  436. bool WriteXmlPropToMyDocument(const FbxString& subDir, const FbxString& filename, const FbxString& propPath);
  437. static const char* GetFileMergeDescription(int pIndex);
  438. enum ELoadMode
  439. {
  440. eCreate, /*!< Add to scene(duplicate the ones with the same name) */
  441. eMerge, /*!< Add to scene and update animation */
  442. eExclusiveMerge /*!< Update animation */
  443. };
  444. enum EQuaternionMode { eAsQuaternion, eAsEuler, eResample };
  445. enum EObjectDerivation { eByLayer, eByEntity, eByBlock };
  446. enum ESysUnits
  447. {
  448. eUnitsUser,
  449. eUnitsInches,
  450. eUnitsFeet,
  451. eUnitYards,
  452. eUnitsMiles,
  453. eUnitsMillimeters,
  454. eUnitsCentimeters,
  455. eUnitsMeters,
  456. eUnitsKilometers
  457. };
  458. enum ESysFrameRate
  459. {
  460. eFrameRateUser,
  461. eFrameRateHours,
  462. eFrameRateMinutes,
  463. eFrameRateSeconds,
  464. eFrameRateMilliseconds,
  465. eFrameRateGames15,
  466. eFrameRateFilm24,
  467. eFrameRatePAL25,
  468. eFrameRateNTSC30,
  469. eFrameRateShowScan48,
  470. eFrameRatePALField50,
  471. eFrameRateNTSCField60
  472. };
  473. // Max
  474. enum EEnveloppeSystem
  475. {
  476. eSkinModifier,
  477. ePhysic,
  478. eBonePro,
  479. eEnveloppeSystemCount
  480. };
  481. // Max
  482. enum EGeometryType
  483. {
  484. eTriangle,
  485. eSimplifiedPoly,
  486. ePolygon,
  487. eNurbs,
  488. ePatch,
  489. eGeometryTypeCount
  490. };
  491. // Maya IK type
  492. enum EIKType
  493. {
  494. eNone,
  495. eFBIK,
  496. eHumanIK
  497. };
  498. protected:
  499. virtual void Construct(const FbxObject* pFrom);
  500. virtual void ConstructProperties(bool pForceSet);
  501. virtual void Destruct(bool pRecursive);
  502. private:
  503. void AddNewPropInfo(FbxProperty& pProp);
  504. void DeletePropInfo(FbxProperty& pProp);
  505. void DeleteAllPropInfo(FbxProperty& pProp);
  506. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  507. };
  508. #include <fbxsdk/fbxsdk_nsend.h>
  509. #endif /* _FBXSDK_FILEIO_IO_SETTINGS_H_ */