| 19 | { |
| 20 | |
| 21 | class PicoModelModule : |
| 22 | public RegisterableModule |
| 23 | { |
| 24 | public: |
| 25 | // RegisterableModule implementation |
| 26 | const std::string& getName() const |
| 27 | { |
| 28 | static std::string _name("PicoModelModule"); |
| 29 | return _name; |
| 30 | } |
| 31 | |
| 32 | const StringSet& getDependencies() const |
| 33 | { |
| 34 | static StringSet _dependencies; |
| 35 | |
| 36 | if (_dependencies.empty()) |
| 37 | { |
| 38 | _dependencies.insert(MODULE_MODELFORMATMANAGER); |
| 39 | } |
| 40 | |
| 41 | return _dependencies; |
| 42 | } |
| 43 | |
| 44 | void initialiseModule(const IApplicationContext& ctx) |
| 45 | { |
| 46 | PicoInit(); |
| 47 | PicoSetMallocFunc(malloc); |
| 48 | PicoSetFreeFunc(free); |
| 49 | PicoSetPrintFunc(PicoPrintFunc); |
| 50 | PicoSetLoadFileFunc(PicoLoadFileFunc); |
| 51 | PicoSetFreeFileFunc(PicoFreeFileFunc); |
| 52 | |
| 53 | // Register all importers available through picomodel |
| 54 | const picoModule_t** modules = PicoModuleList(0); |
| 55 | |
| 56 | while (*modules != nullptr) |
| 57 | { |
| 58 | const picoModule_t* module = *modules++; |
| 59 | |
| 60 | if (module->canload && module->load) |
| 61 | { |
| 62 | for (char* const* ext = module->defaultExts; *ext != 0; ++ext) |
| 63 | { |
| 64 | // greebo: File extension is expected to be UPPERCASE |
| 65 | std::string extension(*ext); |
| 66 | string::to_upper(extension); |
| 67 | |
| 68 | GlobalModelFormatManager().registerImporter( |
| 69 | std::make_shared<PicoModelLoader>(module, extension) |
| 70 | ); |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | GlobalModelFormatManager().registerImporter(std::make_shared<AseModelLoader>()); |
| 76 | } |
| 77 | |
| 78 | private: |