ImporterRegistry.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2024, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file ImporterRegistry.cpp
  35. Central registry for all importers available. Do not edit this file
  36. directly (unless you are adding new loaders), instead use the
  37. corresponding preprocessor flag to selectively disable formats.
  38. */
  39. #include <assimp/anim.h>
  40. #include <assimp/BaseImporter.h>
  41. #include <vector>
  42. #include <cstdlib>
  43. // ------------------------------------------------------------------------------------------------
  44. // Importers
  45. // (include_new_importers_here)
  46. // ------------------------------------------------------------------------------------------------
  47. #if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
  48. #include "AssetLib/USD/USDLoader.h"
  49. #endif
  50. #ifndef ASSIMP_BUILD_NO_X_IMPORTER
  51. #include "AssetLib/X/XFileImporter.h"
  52. #endif
  53. #ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
  54. #include "AssetLib/AMF/AMFImporter.hpp"
  55. #endif
  56. #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
  57. #include "AssetLib/3DS/3DSLoader.h"
  58. #endif
  59. #ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
  60. #include "AssetLib/MD3/MD3Loader.h"
  61. #endif
  62. #ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
  63. #include "AssetLib/MDL/MDLLoader.h"
  64. #endif
  65. #ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
  66. #include "AssetLib/MD2/MD2Loader.h"
  67. #endif
  68. #ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
  69. #include "AssetLib/Ply/PlyLoader.h"
  70. #endif
  71. #ifndef ASSIMP_BUILD_NO_ASE_IMPORTER
  72. #include "AssetLib/ASE/ASELoader.h"
  73. #endif
  74. #ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
  75. #include "AssetLib/Obj/ObjFileImporter.h"
  76. #endif
  77. #ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
  78. #include "AssetLib/HMP/HMPLoader.h"
  79. #endif
  80. #ifndef ASSIMP_BUILD_NO_SMD_IMPORTER
  81. #include "AssetLib/SMD/SMDLoader.h"
  82. #endif
  83. #ifndef ASSIMP_BUILD_NO_MDC_IMPORTER
  84. #include "AssetLib/MDC/MDCLoader.h"
  85. #endif
  86. #ifndef ASSIMP_BUILD_NO_MD5_IMPORTER
  87. #include "AssetLib/MD5/MD5Loader.h"
  88. #endif
  89. #ifndef ASSIMP_BUILD_NO_STL_IMPORTER
  90. #include "AssetLib/STL/STLLoader.h"
  91. #endif
  92. #ifndef ASSIMP_BUILD_NO_LWO_IMPORTER
  93. #include "AssetLib/LWO/LWOLoader.h"
  94. #endif
  95. #ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
  96. #include "AssetLib/DXF/DXFLoader.h"
  97. #endif
  98. #ifndef ASSIMP_BUILD_NO_NFF_IMPORTER
  99. #include "AssetLib/NFF/NFFLoader.h"
  100. #endif
  101. #ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
  102. #include "AssetLib/Raw/RawLoader.h"
  103. #endif
  104. #ifndef ASSIMP_BUILD_NO_SIB_IMPORTER
  105. #include "AssetLib/SIB/SIBImporter.h"
  106. #endif
  107. #ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
  108. #include "AssetLib/OFF/OFFLoader.h"
  109. #endif
  110. #ifndef ASSIMP_BUILD_NO_AC_IMPORTER
  111. #include "AssetLib/AC/ACLoader.h"
  112. #endif
  113. #ifndef ASSIMP_BUILD_NO_BVH_IMPORTER
  114. #include "AssetLib/BVH/BVHLoader.h"
  115. #endif
  116. #ifndef ASSIMP_BUILD_NO_IRRMESH_IMPORTER
  117. #include "AssetLib/Irr/IRRMeshLoader.h"
  118. #endif
  119. #ifndef ASSIMP_BUILD_NO_IRR_IMPORTER
  120. #include "AssetLib/Irr/IRRLoader.h"
  121. #endif
  122. #ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
  123. #include "AssetLib/Q3D/Q3DLoader.h"
  124. #endif
  125. #ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
  126. #include "AssetLib/B3D/B3DImporter.h"
  127. #endif
  128. #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
  129. #include "AssetLib/Collada/ColladaLoader.h"
  130. #endif
  131. #ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
  132. #include "AssetLib/Terragen/TerragenLoader.h"
  133. #endif
  134. #ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
  135. #include "AssetLib/CSM/CSMLoader.h"
  136. #endif
  137. #ifndef ASSIMP_BUILD_NO_3D_IMPORTER
  138. #include "AssetLib/Unreal/UnrealLoader.h"
  139. #endif
  140. #ifndef ASSIMP_BUILD_NO_LWS_IMPORTER
  141. #include "AssetLib/LWS/LWSLoader.h"
  142. #endif
  143. #ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
  144. #include "AssetLib/Ogre/OgreImporter.h"
  145. #endif
  146. #ifndef ASSIMP_BUILD_NO_OPENGEX_IMPORTER
  147. #include "AssetLib/OpenGEX/OpenGEXImporter.h"
  148. #endif
  149. #ifndef ASSIMP_BUILD_NO_MS3D_IMPORTER
  150. #include "AssetLib/MS3D/MS3DLoader.h"
  151. #endif
  152. #ifndef ASSIMP_BUILD_NO_COB_IMPORTER
  153. #include "AssetLib/COB/COBLoader.h"
  154. #endif
  155. #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
  156. #include "AssetLib/Blender/BlenderLoader.h"
  157. #endif
  158. #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
  159. #include "AssetLib/Q3BSP/Q3BSPFileImporter.h"
  160. #endif
  161. #ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
  162. #include "AssetLib/NDO/NDOLoader.h"
  163. #endif
  164. #ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
  165. #include "AssetLib/IFC/IFCLoader.h"
  166. #endif
  167. #ifndef ASSIMP_BUILD_NO_XGL_IMPORTER
  168. #include "AssetLib/XGL/XGLLoader.h"
  169. #endif
  170. #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
  171. #include "AssetLib/FBX/FBXImporter.h"
  172. #endif
  173. #ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
  174. #include "AssetLib/Assbin/AssbinLoader.h"
  175. #endif
  176. #if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
  177. #include "AssetLib/glTF/glTFImporter.h"
  178. #endif
  179. #if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
  180. #include "AssetLib/glTF2/glTF2Importer.h"
  181. #endif
  182. #ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
  183. #include "AssetLib/C4D/C4DImporter.h"
  184. #endif
  185. #ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
  186. #include "AssetLib/3MF/D3MFImporter.h"
  187. #endif
  188. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
  189. #include "AssetLib/X3D/X3DImporter.hpp"
  190. #endif
  191. #ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
  192. #include "AssetLib/MMD/MMDImporter.h"
  193. #endif
  194. #ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
  195. #include "AssetLib/M3D/M3DImporter.h"
  196. #endif
  197. #ifndef ASSIMP_BUILD_NO_IQM_IMPORTER
  198. #include "AssetLib/IQM/IQMImporter.h"
  199. #endif
  200. namespace Assimp {
  201. // ------------------------------------------------------------------------------------------------
  202. void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
  203. // Some importers may be unimplemented or otherwise unsuitable for general use
  204. // in their current state. Devs can set ASSIMP_ENABLE_DEV_IMPORTERS in their
  205. // local environment to enable them, otherwise they're left out of the registry.
  206. #if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
  207. // not supported under uwp
  208. const char *envStr = std::getenv("ASSIMP_ENABLE_DEV_IMPORTERS");
  209. #else
  210. const char *envStr = { "0" };
  211. #endif
  212. bool devImportersEnabled = envStr && strcmp(envStr, "0");
  213. // Ensure no unused var warnings if all uses are #ifndef'd away below:
  214. (void)devImportersEnabled;
  215. // ----------------------------------------------------------------------------
  216. // Add an instance of each worker class here
  217. // (register_new_importers_here)
  218. // ----------------------------------------------------------------------------
  219. out.reserve(64);
  220. #if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
  221. out.push_back(new USDImporter());
  222. #endif
  223. #if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
  224. out.push_back(new XFileImporter());
  225. #endif
  226. #if (!defined ASSIMP_BUILD_NO_OBJ_IMPORTER)
  227. out.push_back(new ObjFileImporter());
  228. #endif
  229. #ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
  230. out.push_back(new AMFImporter());
  231. #endif
  232. #if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
  233. out.push_back(new Discreet3DSImporter());
  234. #endif
  235. #if (!defined ASSIMP_BUILD_NO_M3D_IMPORTER)
  236. out.push_back(new M3DImporter());
  237. #endif
  238. #if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
  239. out.push_back(new MD3Importer());
  240. #endif
  241. #if (!defined ASSIMP_BUILD_NO_MD2_IMPORTER)
  242. out.push_back(new MD2Importer());
  243. #endif
  244. #if (!defined ASSIMP_BUILD_NO_PLY_IMPORTER)
  245. out.push_back(new PLYImporter());
  246. #endif
  247. #if (!defined ASSIMP_BUILD_NO_MDL_IMPORTER)
  248. out.push_back(new MDLImporter());
  249. #endif
  250. #if (!defined ASSIMP_BUILD_NO_ASE_IMPORTER)
  251. #if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
  252. out.push_back(new ASEImporter());
  253. #endif
  254. #endif
  255. #if (!defined ASSIMP_BUILD_NO_HMP_IMPORTER)
  256. out.push_back(new HMPImporter());
  257. #endif
  258. #if (!defined ASSIMP_BUILD_NO_SMD_IMPORTER)
  259. out.push_back(new SMDImporter());
  260. #endif
  261. #if (!defined ASSIMP_BUILD_NO_MDC_IMPORTER)
  262. out.push_back(new MDCImporter());
  263. #endif
  264. #if (!defined ASSIMP_BUILD_NO_MD5_IMPORTER)
  265. out.push_back(new MD5Importer());
  266. #endif
  267. #if (!defined ASSIMP_BUILD_NO_STL_IMPORTER)
  268. out.push_back(new STLImporter());
  269. #endif
  270. #if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER)
  271. out.push_back(new LWOImporter());
  272. #endif
  273. #if (!defined ASSIMP_BUILD_NO_DXF_IMPORTER)
  274. out.push_back(new DXFImporter());
  275. #endif
  276. #if (!defined ASSIMP_BUILD_NO_NFF_IMPORTER)
  277. out.push_back(new NFFImporter());
  278. #endif
  279. #if (!defined ASSIMP_BUILD_NO_RAW_IMPORTER)
  280. out.push_back(new RAWImporter());
  281. #endif
  282. #if (!defined ASSIMP_BUILD_NO_SIB_IMPORTER)
  283. out.push_back(new SIBImporter());
  284. #endif
  285. #if (!defined ASSIMP_BUILD_NO_OFF_IMPORTER)
  286. out.push_back(new OFFImporter());
  287. #endif
  288. #if (!defined ASSIMP_BUILD_NO_AC_IMPORTER)
  289. out.push_back(new AC3DImporter());
  290. #endif
  291. #if (!defined ASSIMP_BUILD_NO_BVH_IMPORTER)
  292. out.push_back(new BVHLoader());
  293. #endif
  294. #if (!defined ASSIMP_BUILD_NO_IRRMESH_IMPORTER)
  295. out.push_back(new IRRMeshImporter());
  296. #endif
  297. #if (!defined ASSIMP_BUILD_NO_IRR_IMPORTER)
  298. out.push_back(new IRRImporter());
  299. #endif
  300. #if (!defined ASSIMP_BUILD_NO_Q3D_IMPORTER)
  301. out.push_back(new Q3DImporter());
  302. #endif
  303. #if (!defined ASSIMP_BUILD_NO_B3D_IMPORTER)
  304. out.push_back(new B3DImporter());
  305. #endif
  306. #if (!defined ASSIMP_BUILD_NO_COLLADA_IMPORTER)
  307. out.push_back(new ColladaLoader());
  308. #endif
  309. #if (!defined ASSIMP_BUILD_NO_TERRAGEN_IMPORTER)
  310. out.push_back(new TerragenImporter());
  311. #endif
  312. #if (!defined ASSIMP_BUILD_NO_CSM_IMPORTER)
  313. out.push_back(new CSMImporter());
  314. #endif
  315. #if (!defined ASSIMP_BUILD_NO_3D_IMPORTER)
  316. out.push_back(new UnrealImporter());
  317. #endif
  318. #if (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
  319. out.push_back(new LWSImporter());
  320. #endif
  321. #if (!defined ASSIMP_BUILD_NO_OGRE_IMPORTER)
  322. out.push_back(new Ogre::OgreImporter());
  323. #endif
  324. #if (!defined ASSIMP_BUILD_NO_OPENGEX_IMPORTER)
  325. out.push_back(new OpenGEX::OpenGEXImporter());
  326. #endif
  327. #if (!defined ASSIMP_BUILD_NO_MS3D_IMPORTER)
  328. out.push_back(new MS3DImporter());
  329. #endif
  330. #if (!defined ASSIMP_BUILD_NO_COB_IMPORTER)
  331. out.push_back(new COBImporter());
  332. #endif
  333. #if (!defined ASSIMP_BUILD_NO_BLEND_IMPORTER)
  334. out.push_back(new BlenderImporter());
  335. #endif
  336. #if (!defined ASSIMP_BUILD_NO_Q3BSP_IMPORTER)
  337. out.push_back(new Q3BSPFileImporter());
  338. #endif
  339. #if (!defined ASSIMP_BUILD_NO_NDO_IMPORTER)
  340. out.push_back(new NDOImporter());
  341. #endif
  342. #if (!defined ASSIMP_BUILD_NO_IFC_IMPORTER)
  343. out.push_back(new IFCImporter());
  344. #endif
  345. #if (!defined ASSIMP_BUILD_NO_XGL_IMPORTER)
  346. out.push_back(new XGLImporter());
  347. #endif
  348. #if (!defined ASSIMP_BUILD_NO_FBX_IMPORTER)
  349. out.push_back(new FBXImporter());
  350. #endif
  351. #if (!defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER)
  352. out.push_back(new AssbinImporter());
  353. #endif
  354. #if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF1_IMPORTER)
  355. out.push_back(new glTFImporter());
  356. #endif
  357. #if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF2_IMPORTER)
  358. out.push_back(new glTF2Importer());
  359. #endif
  360. #if (!defined ASSIMP_BUILD_NO_C4D_IMPORTER)
  361. out.push_back(new C4DImporter());
  362. #endif
  363. #if (!defined ASSIMP_BUILD_NO_3MF_IMPORTER)
  364. out.push_back(new D3MFImporter());
  365. #endif
  366. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
  367. out.push_back(new X3DImporter());
  368. #endif
  369. #ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
  370. out.push_back(new MMDImporter());
  371. #endif
  372. #ifndef ASSIMP_BUILD_NO_IQM_IMPORTER
  373. out.push_back(new IQMImporter());
  374. #endif
  375. }
  376. /** will delete all registered importers. */
  377. void DeleteImporterInstanceList(std::vector<BaseImporter *> &deleteList) {
  378. for (size_t i = 0; i < deleteList.size(); ++i) {
  379. delete deleteList[i];
  380. deleteList[i] = nullptr;
  381. } //for
  382. }
  383. } // namespace Assimp