ImporterRegistry.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2021, 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/BaseImporter.h>
  40. #include <vector>
  41. #include <cstdlib>
  42. // ------------------------------------------------------------------------------------------------
  43. // Importers
  44. // (include_new_importers_here)
  45. // ------------------------------------------------------------------------------------------------
  46. #ifndef ASSIMP_BUILD_NO_X_IMPORTER
  47. #include "AssetLib/X/XFileImporter.h"
  48. #endif
  49. #ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
  50. #include "AssetLib/AMF/AMFImporter.hpp"
  51. #endif
  52. #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
  53. #include "AssetLib/3DS/3DSLoader.h"
  54. #endif
  55. #ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
  56. #include "AssetLib/MD3/MD3Loader.h"
  57. #endif
  58. #ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
  59. #include "AssetLib/MDL/MDLLoader.h"
  60. #endif
  61. #ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
  62. #include "AssetLib/MD2/MD2Loader.h"
  63. #endif
  64. #ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
  65. #include "AssetLib/Ply/PlyLoader.h"
  66. #endif
  67. #ifndef ASSIMP_BUILD_NO_ASE_IMPORTER
  68. #include "AssetLib/ASE/ASELoader.h"
  69. #endif
  70. #ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
  71. #include "AssetLib/Obj/ObjFileImporter.h"
  72. #endif
  73. #ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
  74. #include "AssetLib/HMP/HMPLoader.h"
  75. #endif
  76. #ifndef ASSIMP_BUILD_NO_SMD_IMPORTER
  77. #include "AssetLib/SMD/SMDLoader.h"
  78. #endif
  79. #ifndef ASSIMP_BUILD_NO_MDC_IMPORTER
  80. #include "AssetLib/MDC/MDCLoader.h"
  81. #endif
  82. #ifndef ASSIMP_BUILD_NO_MD5_IMPORTER
  83. #include "AssetLib/MD5/MD5Loader.h"
  84. #endif
  85. #ifndef ASSIMP_BUILD_NO_STL_IMPORTER
  86. #include "AssetLib/STL/STLLoader.h"
  87. #endif
  88. #ifndef ASSIMP_BUILD_NO_LWO_IMPORTER
  89. #include "AssetLib/LWO/LWOLoader.h"
  90. #endif
  91. #ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
  92. #include "AssetLib/DXF/DXFLoader.h"
  93. #endif
  94. #ifndef ASSIMP_BUILD_NO_NFF_IMPORTER
  95. #include "AssetLib/NFF/NFFLoader.h"
  96. #endif
  97. #ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
  98. #include "AssetLib/Raw/RawLoader.h"
  99. #endif
  100. #ifndef ASSIMP_BUILD_NO_SIB_IMPORTER
  101. #include "AssetLib/SIB/SIBImporter.h"
  102. #endif
  103. #ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
  104. #include "AssetLib/OFF/OFFLoader.h"
  105. #endif
  106. #ifndef ASSIMP_BUILD_NO_AC_IMPORTER
  107. #include "AssetLib/AC/ACLoader.h"
  108. #endif
  109. #ifndef ASSIMP_BUILD_NO_BVH_IMPORTER
  110. #include "AssetLib/BVH/BVHLoader.h"
  111. #endif
  112. #ifndef ASSIMP_BUILD_NO_IRRMESH_IMPORTER
  113. #include "AssetLib/Irr/IRRMeshLoader.h"
  114. #endif
  115. #ifndef ASSIMP_BUILD_NO_IRR_IMPORTER
  116. #include "AssetLib/Irr/IRRLoader.h"
  117. #endif
  118. #ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
  119. #include "AssetLib/Q3D/Q3DLoader.h"
  120. #endif
  121. #ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
  122. #include "AssetLib/B3D/B3DImporter.h"
  123. #endif
  124. #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
  125. #include "AssetLib/Collada/ColladaLoader.h"
  126. #endif
  127. #ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
  128. #include "AssetLib/Terragen/TerragenLoader.h"
  129. #endif
  130. #ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
  131. #include "AssetLib/CSM/CSMLoader.h"
  132. #endif
  133. #ifndef ASSIMP_BUILD_NO_3D_IMPORTER
  134. #include "AssetLib/Unreal/UnrealLoader.h"
  135. #endif
  136. #ifndef ASSIMP_BUILD_NO_LWS_IMPORTER
  137. #include "AssetLib/LWS/LWSLoader.h"
  138. #endif
  139. #ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
  140. #include "AssetLib/Ogre/OgreImporter.h"
  141. #endif
  142. #ifndef ASSIMP_BUILD_NO_OPENGEX_IMPORTER
  143. #include "AssetLib/OpenGEX/OpenGEXImporter.h"
  144. #endif
  145. #ifndef ASSIMP_BUILD_NO_MS3D_IMPORTER
  146. #include "AssetLib/MS3D/MS3DLoader.h"
  147. #endif
  148. #ifndef ASSIMP_BUILD_NO_COB_IMPORTER
  149. #include "AssetLib/COB/COBLoader.h"
  150. #endif
  151. #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
  152. #include "AssetLib/Blender/BlenderLoader.h"
  153. #endif
  154. #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
  155. #include "AssetLib/Q3BSP/Q3BSPFileImporter.h"
  156. #endif
  157. #ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
  158. #include "AssetLib/NDO/NDOLoader.h"
  159. #endif
  160. #ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
  161. #include "AssetLib/IFC/IFCLoader.h"
  162. #endif
  163. #ifndef ASSIMP_BUILD_NO_XGL_IMPORTER
  164. #include "AssetLib/XGL/XGLLoader.h"
  165. #endif
  166. #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
  167. #include "AssetLib/FBX/FBXImporter.h"
  168. #endif
  169. #ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
  170. #include "AssetLib/Assbin/AssbinLoader.h"
  171. #endif
  172. #if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
  173. #include "AssetLib/glTF/glTFImporter.h"
  174. #endif
  175. #if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
  176. #include "AssetLib/glTF2/glTF2Importer.h"
  177. #endif
  178. #ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
  179. #include "AssetLib/C4D/C4DImporter.h"
  180. #endif
  181. #ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
  182. #include "AssetLib/3MF/D3MFImporter.h"
  183. #endif
  184. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
  185. #include "AssetLib/X3D/X3DImporter.hpp"
  186. #endif
  187. #ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
  188. #include "AssetLib/MMD/MMDImporter.h"
  189. #endif
  190. #ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
  191. #include "AssetLib/M3D/M3DImporter.h"
  192. #endif
  193. namespace Assimp {
  194. // ------------------------------------------------------------------------------------------------
  195. void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
  196. // Some importers may be unimplemented or otherwise unsuitable for general use
  197. // in their current state. Devs can set ASSIMP_ENABLE_DEV_IMPORTERS in their
  198. // local environment to enable them, otherwise they're left out of the registry.
  199. const char *envStr = std::getenv("ASSIMP_ENABLE_DEV_IMPORTERS");
  200. bool devImportersEnabled = envStr && strcmp(envStr, "0");
  201. // Ensure no unused var warnings if all uses are #ifndef'd away below:
  202. (void)devImportersEnabled;
  203. // ----------------------------------------------------------------------------
  204. // Add an instance of each worker class here
  205. // (register_new_importers_here)
  206. // ----------------------------------------------------------------------------
  207. out.reserve(64);
  208. #if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
  209. out.push_back(new XFileImporter());
  210. #endif
  211. #if (!defined ASSIMP_BUILD_NO_OBJ_IMPORTER)
  212. out.push_back(new ObjFileImporter());
  213. #endif
  214. #ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
  215. out.push_back(new AMFImporter());
  216. #endif
  217. #if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
  218. out.push_back(new Discreet3DSImporter());
  219. #endif
  220. #if (!defined ASSIMP_BUILD_NO_M3D_IMPORTER)
  221. out.push_back(new M3DImporter());
  222. #endif
  223. #if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
  224. out.push_back(new MD3Importer());
  225. #endif
  226. #if (!defined ASSIMP_BUILD_NO_MD2_IMPORTER)
  227. out.push_back(new MD2Importer());
  228. #endif
  229. #if (!defined ASSIMP_BUILD_NO_PLY_IMPORTER)
  230. out.push_back(new PLYImporter());
  231. #endif
  232. #if (!defined ASSIMP_BUILD_NO_MDL_IMPORTER)
  233. out.push_back(new MDLImporter());
  234. #endif
  235. #if (!defined ASSIMP_BUILD_NO_ASE_IMPORTER)
  236. #if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
  237. out.push_back(new ASEImporter());
  238. #endif
  239. #endif
  240. #if (!defined ASSIMP_BUILD_NO_HMP_IMPORTER)
  241. out.push_back(new HMPImporter());
  242. #endif
  243. #if (!defined ASSIMP_BUILD_NO_SMD_IMPORTER)
  244. out.push_back(new SMDImporter());
  245. #endif
  246. #if (!defined ASSIMP_BUILD_NO_MDC_IMPORTER)
  247. out.push_back(new MDCImporter());
  248. #endif
  249. #if (!defined ASSIMP_BUILD_NO_MD5_IMPORTER)
  250. out.push_back(new MD5Importer());
  251. #endif
  252. #if (!defined ASSIMP_BUILD_NO_STL_IMPORTER)
  253. out.push_back(new STLImporter());
  254. #endif
  255. #if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER)
  256. out.push_back(new LWOImporter());
  257. #endif
  258. #if (!defined ASSIMP_BUILD_NO_DXF_IMPORTER)
  259. out.push_back(new DXFImporter());
  260. #endif
  261. #if (!defined ASSIMP_BUILD_NO_NFF_IMPORTER)
  262. out.push_back(new NFFImporter());
  263. #endif
  264. #if (!defined ASSIMP_BUILD_NO_RAW_IMPORTER)
  265. out.push_back(new RAWImporter());
  266. #endif
  267. #if (!defined ASSIMP_BUILD_NO_SIB_IMPORTER)
  268. out.push_back(new SIBImporter());
  269. #endif
  270. #if (!defined ASSIMP_BUILD_NO_OFF_IMPORTER)
  271. out.push_back(new OFFImporter());
  272. #endif
  273. #if (!defined ASSIMP_BUILD_NO_AC_IMPORTER)
  274. out.push_back(new AC3DImporter());
  275. #endif
  276. #if (!defined ASSIMP_BUILD_NO_BVH_IMPORTER)
  277. out.push_back(new BVHLoader());
  278. #endif
  279. #if (!defined ASSIMP_BUILD_NO_IRRMESH_IMPORTER)
  280. out.push_back(new IRRMeshImporter());
  281. #endif
  282. #if (!defined ASSIMP_BUILD_NO_IRR_IMPORTER)
  283. out.push_back(new IRRImporter());
  284. #endif
  285. #if (!defined ASSIMP_BUILD_NO_Q3D_IMPORTER)
  286. out.push_back(new Q3DImporter());
  287. #endif
  288. #if (!defined ASSIMP_BUILD_NO_B3D_IMPORTER)
  289. out.push_back(new B3DImporter());
  290. #endif
  291. #if (!defined ASSIMP_BUILD_NO_COLLADA_IMPORTER)
  292. out.push_back(new ColladaLoader());
  293. #endif
  294. #if (!defined ASSIMP_BUILD_NO_TERRAGEN_IMPORTER)
  295. out.push_back(new TerragenImporter());
  296. #endif
  297. #if (!defined ASSIMP_BUILD_NO_CSM_IMPORTER)
  298. out.push_back(new CSMImporter());
  299. #endif
  300. #if (!defined ASSIMP_BUILD_NO_3D_IMPORTER)
  301. out.push_back(new UnrealImporter());
  302. #endif
  303. #if (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
  304. out.push_back(new LWSImporter());
  305. #endif
  306. #if (!defined ASSIMP_BUILD_NO_OGRE_IMPORTER)
  307. out.push_back(new Ogre::OgreImporter());
  308. #endif
  309. #if (!defined ASSIMP_BUILD_NO_OPENGEX_IMPORTER)
  310. out.push_back(new OpenGEX::OpenGEXImporter());
  311. #endif
  312. #if (!defined ASSIMP_BUILD_NO_MS3D_IMPORTER)
  313. out.push_back(new MS3DImporter());
  314. #endif
  315. #if (!defined ASSIMP_BUILD_NO_COB_IMPORTER)
  316. out.push_back(new COBImporter());
  317. #endif
  318. #if (!defined ASSIMP_BUILD_NO_BLEND_IMPORTER)
  319. out.push_back(new BlenderImporter());
  320. #endif
  321. #if (!defined ASSIMP_BUILD_NO_Q3BSP_IMPORTER)
  322. out.push_back(new Q3BSPFileImporter());
  323. #endif
  324. #if (!defined ASSIMP_BUILD_NO_NDO_IMPORTER)
  325. out.push_back(new NDOImporter());
  326. #endif
  327. #if (!defined ASSIMP_BUILD_NO_IFC_IMPORTER)
  328. out.push_back(new IFCImporter());
  329. #endif
  330. #if (!defined ASSIMP_BUILD_NO_XGL_IMPORTER)
  331. out.push_back(new XGLImporter());
  332. #endif
  333. #if (!defined ASSIMP_BUILD_NO_FBX_IMPORTER)
  334. out.push_back(new FBXImporter());
  335. #endif
  336. #if (!defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER)
  337. out.push_back(new AssbinImporter());
  338. #endif
  339. #if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF1_IMPORTER)
  340. out.push_back(new glTFImporter());
  341. #endif
  342. #if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF2_IMPORTER)
  343. out.push_back(new glTF2Importer());
  344. #endif
  345. #if (!defined ASSIMP_BUILD_NO_C4D_IMPORTER)
  346. out.push_back(new C4DImporter());
  347. #endif
  348. #if (!defined ASSIMP_BUILD_NO_3MF_IMPORTER)
  349. out.push_back(new D3MFImporter());
  350. #endif
  351. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
  352. if (devImportersEnabled) { // https://github.com/assimp/assimp/issues/3647
  353. out.push_back(new X3DImporter());
  354. }
  355. #endif
  356. #ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
  357. out.push_back(new MMDImporter());
  358. #endif
  359. //#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER
  360. // out.push_back(new StepFile::StepFileImporter());
  361. //#endif
  362. }
  363. /** will delete all registered importers. */
  364. void DeleteImporterInstanceList(std::vector<BaseImporter *> &deleteList) {
  365. for (size_t i = 0; i < deleteList.size(); ++i) {
  366. delete deleteList[i];
  367. deleteList[i] = nullptr;
  368. } //for
  369. }
  370. } // namespace Assimp