1 | /* |
2 | --------------------------------------------------------------------------- |
3 | Open Asset Import Library (assimp) |
4 | --------------------------------------------------------------------------- |
5 | |
6 | Copyright (c) 2006-2019, assimp team |
7 | |
8 | |
9 | |
10 | All rights reserved. |
11 | |
12 | Redistribution and use of this software in source and binary forms, |
13 | with or without modification, are permitted provided that the following |
14 | conditions are met: |
15 | |
16 | * Redistributions of source code must retain the above |
17 | copyright notice, this list of conditions and the |
18 | following disclaimer. |
19 | |
20 | * Redistributions in binary form must reproduce the above |
21 | copyright notice, this list of conditions and the |
22 | following disclaimer in the documentation and/or other |
23 | materials provided with the distribution. |
24 | |
25 | * Neither the name of the assimp team, nor the names of its |
26 | contributors may be used to endorse or promote products |
27 | derived from this software without specific prior |
28 | written permission of the assimp team. |
29 | |
30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
41 | --------------------------------------------------------------------------- |
42 | */ |
43 | |
44 | /** @file Importer.hpp |
45 | * @brief Defines the C++-API to the Open Asset Import Library. |
46 | */ |
47 | #pragma once |
48 | #ifndef AI_ASSIMP_HPP_INC |
49 | #define AI_ASSIMP_HPP_INC |
50 | |
51 | #ifndef __cplusplus |
52 | # error This header requires C++ to be used. Use assimp.h for plain C. |
53 | #endif // __cplusplus |
54 | |
55 | // Public ASSIMP data structures |
56 | #include <assimp/types.h> |
57 | |
58 | namespace Assimp { |
59 | // ======================================================================= |
60 | // Public interface to Assimp |
61 | class Importer; |
62 | class IOStream; |
63 | class IOSystem; |
64 | class ProgressHandler; |
65 | |
66 | // ======================================================================= |
67 | // Plugin development |
68 | // |
69 | // Include the following headers for the declarations: |
70 | // BaseImporter.h |
71 | // BaseProcess.h |
72 | class BaseImporter; |
73 | class BaseProcess; |
74 | class SharedPostProcessInfo; |
75 | class BatchLoader; |
76 | |
77 | // ======================================================================= |
78 | // Holy stuff, only for members of the high council of the Jedi. |
79 | class ImporterPimpl; |
80 | } //! namespace Assimp |
81 | |
82 | #define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff |
83 | |
84 | struct aiScene; |
85 | |
86 | // importerdesc.h |
87 | struct aiImporterDesc; |
88 | |
89 | /** @namespace Assimp Assimp's CPP-API and all internal APIs */ |
90 | namespace Assimp { |
91 | |
92 | // ---------------------------------------------------------------------------------- |
93 | /** CPP-API: The Importer class forms an C++ interface to the functionality of the |
94 | * Open Asset Import Library. |
95 | * |
96 | * Create an object of this class and call ReadFile() to import a file. |
97 | * If the import succeeds, the function returns a pointer to the imported data. |
98 | * The data remains property of the object, it is intended to be accessed |
99 | * read-only. The imported data will be destroyed along with the Importer |
100 | * object. If the import fails, ReadFile() returns a NULL pointer. In this |
101 | * case you can retrieve a human-readable error description be calling |
102 | * GetErrorString(). You can call ReadFile() multiple times with a single Importer |
103 | * instance. Actually, constructing Importer objects involves quite many |
104 | * allocations and may take some time, so it's better to reuse them as often as |
105 | * possible. |
106 | * |
107 | * If you need the Importer to do custom file handling to access the files, |
108 | * implement IOSystem and IOStream and supply an instance of your custom |
109 | * IOSystem implementation by calling SetIOHandler() before calling ReadFile(). |
110 | * If you do not assign a custion IO handler, a default handler using the |
111 | * standard C++ IO logic will be used. |
112 | * |
113 | * @note One Importer instance is not thread-safe. If you use multiple |
114 | * threads for loading, each thread should maintain its own Importer instance. |
115 | */ |
116 | class ASSIMP_API Importer { |
117 | public: |
118 | /** |
119 | * @brief The upper limit for hints. |
120 | */ |
121 | static const unsigned int MaxLenHint = 200; |
122 | |
123 | public: |
124 | |
125 | // ------------------------------------------------------------------- |
126 | /** Constructor. Creates an empty importer object. |
127 | * |
128 | * Call ReadFile() to start the import process. The configuration |
129 | * property table is initially empty. |
130 | */ |
131 | Importer(); |
132 | |
133 | // ------------------------------------------------------------------- |
134 | /** Copy constructor. |
135 | * |
136 | * This copies the configuration properties of another Importer. |
137 | * If this Importer owns a scene it won't be copied. |
138 | * Call ReadFile() to start the import process. |
139 | */ |
140 | Importer(const Importer& other)=delete; |
141 | |
142 | // ------------------------------------------------------------------- |
143 | /** Assignment operator has been deleted |
144 | */ |
145 | Importer &operator=(const Importer &) = delete; |
146 | |
147 | // ------------------------------------------------------------------- |
148 | /** Destructor. The object kept ownership of the imported data, |
149 | * which now will be destroyed along with the object. |
150 | */ |
151 | ~Importer(); |
152 | |
153 | |
154 | // ------------------------------------------------------------------- |
155 | /** Registers a new loader. |
156 | * |
157 | * @param pImp Importer to be added. The Importer instance takes |
158 | * ownership of the pointer, so it will be automatically deleted |
159 | * with the Importer instance. |
160 | * @return AI_SUCCESS if the loader has been added. The registration |
161 | * fails if there is already a loader for a specific file extension. |
162 | */ |
163 | aiReturn RegisterLoader(BaseImporter* pImp); |
164 | |
165 | // ------------------------------------------------------------------- |
166 | /** Unregisters a loader. |
167 | * |
168 | * @param pImp Importer to be unregistered. |
169 | * @return AI_SUCCESS if the loader has been removed. The function |
170 | * fails if the loader is currently in use (this could happen |
171 | * if the #Importer instance is used by more than one thread) or |
172 | * if it has not yet been registered. |
173 | */ |
174 | aiReturn UnregisterLoader(BaseImporter* pImp); |
175 | |
176 | // ------------------------------------------------------------------- |
177 | /** Registers a new post-process step. |
178 | * |
179 | * At the moment, there's a small limitation: new post processing |
180 | * steps are added to end of the list, or in other words, executed |
181 | * last, after all built-in steps. |
182 | * @param pImp Post-process step to be added. The Importer instance |
183 | * takes ownership of the pointer, so it will be automatically |
184 | * deleted with the Importer instance. |
185 | * @return AI_SUCCESS if the step has been added correctly. |
186 | */ |
187 | aiReturn RegisterPPStep(BaseProcess* pImp); |
188 | |
189 | // ------------------------------------------------------------------- |
190 | /** Unregisters a post-process step. |
191 | * |
192 | * @param pImp Step to be unregistered. |
193 | * @return AI_SUCCESS if the step has been removed. The function |
194 | * fails if the step is currently in use (this could happen |
195 | * if the #Importer instance is used by more than one thread) or |
196 | * if it has not yet been registered. |
197 | */ |
198 | aiReturn UnregisterPPStep(BaseProcess* pImp); |
199 | |
200 | // ------------------------------------------------------------------- |
201 | /** Set an integer configuration property. |
202 | * @param szName Name of the property. All supported properties |
203 | * are defined in the aiConfig.g header (all constants share the |
204 | * prefix AI_CONFIG_XXX and are simple strings). |
205 | * @param iValue New value of the property |
206 | * @return true if the property was set before. The new value replaces |
207 | * the previous value in this case. |
208 | * @note Property of different types (float, int, string ..) are kept |
209 | * on different stacks, so calling SetPropertyInteger() for a |
210 | * floating-point property has no effect - the loader will call |
211 | * GetPropertyFloat() to read the property, but it won't be there. |
212 | */ |
213 | bool SetPropertyInteger(const char* szName, int iValue); |
214 | |
215 | // ------------------------------------------------------------------- |
216 | /** Set a boolean configuration property. Boolean properties |
217 | * are stored on the integer stack internally so it's possible |
218 | * to set them via #SetPropertyBool and query them with |
219 | * #GetPropertyBool and vice versa. |
220 | * @see SetPropertyInteger() |
221 | */ |
222 | bool SetPropertyBool(const char* szName, bool value) { |
223 | return SetPropertyInteger(szName,iValue: value); |
224 | } |
225 | |
226 | // ------------------------------------------------------------------- |
227 | /** Set a floating-point configuration property. |
228 | * @see SetPropertyInteger() |
229 | */ |
230 | bool SetPropertyFloat(const char* szName, ai_real fValue); |
231 | |
232 | // ------------------------------------------------------------------- |
233 | /** Set a string configuration property. |
234 | * @see SetPropertyInteger() |
235 | */ |
236 | bool SetPropertyString(const char* szName, const std::string& sValue); |
237 | |
238 | // ------------------------------------------------------------------- |
239 | /** Set a matrix configuration property. |
240 | * @see SetPropertyInteger() |
241 | */ |
242 | bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); |
243 | |
244 | // ------------------------------------------------------------------- |
245 | /** Get a configuration property. |
246 | * @param szName Name of the property. All supported properties |
247 | * are defined in the aiConfig.g header (all constants share the |
248 | * prefix AI_CONFIG_XXX). |
249 | * @param iErrorReturn Value that is returned if the property |
250 | * is not found. |
251 | * @return Current value of the property |
252 | * @note Property of different types (float, int, string ..) are kept |
253 | * on different lists, so calling SetPropertyInteger() for a |
254 | * floating-point property has no effect - the loader will call |
255 | * GetPropertyFloat() to read the property, but it won't be there. |
256 | */ |
257 | int GetPropertyInteger(const char* szName, |
258 | int iErrorReturn = 0xffffffff) const; |
259 | |
260 | // ------------------------------------------------------------------- |
261 | /** Get a boolean configuration property. Boolean properties |
262 | * are stored on the integer stack internally so it's possible |
263 | * to set them via #SetPropertyBool and query them with |
264 | * #GetPropertyBool and vice versa. |
265 | * @see GetPropertyInteger() |
266 | */ |
267 | bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const { |
268 | return GetPropertyInteger(szName,iErrorReturn: bErrorReturn)!=0; |
269 | } |
270 | |
271 | // ------------------------------------------------------------------- |
272 | /** Get a floating-point configuration property |
273 | * @see GetPropertyInteger() |
274 | */ |
275 | ai_real GetPropertyFloat(const char* szName, |
276 | ai_real fErrorReturn = 10e10) const; |
277 | |
278 | // ------------------------------------------------------------------- |
279 | /** Get a string configuration property |
280 | * |
281 | * The return value remains valid until the property is modified. |
282 | * @see GetPropertyInteger() |
283 | */ |
284 | const std::string GetPropertyString(const char* szName, |
285 | const std::string& sErrorReturn = "" ) const; |
286 | |
287 | // ------------------------------------------------------------------- |
288 | /** Get a matrix configuration property |
289 | * |
290 | * The return value remains valid until the property is modified. |
291 | * @see GetPropertyInteger() |
292 | */ |
293 | const aiMatrix4x4 GetPropertyMatrix(const char* szName, |
294 | const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const; |
295 | |
296 | // ------------------------------------------------------------------- |
297 | /** Supplies a custom IO handler to the importer to use to open and |
298 | * access files. If you need the importer to use custom IO logic to |
299 | * access the files, you need to provide a custom implementation of |
300 | * IOSystem and IOFile to the importer. Then create an instance of |
301 | * your custom IOSystem implementation and supply it by this function. |
302 | * |
303 | * The Importer takes ownership of the object and will destroy it |
304 | * afterwards. The previously assigned handler will be deleted. |
305 | * Pass NULL to take again ownership of your IOSystem and reset Assimp |
306 | * to use its default implementation. |
307 | * |
308 | * @param pIOHandler The IO handler to be used in all file accesses |
309 | * of the Importer. |
310 | */ |
311 | void SetIOHandler( IOSystem* pIOHandler); |
312 | |
313 | // ------------------------------------------------------------------- |
314 | /** Retrieves the IO handler that is currently set. |
315 | * You can use #IsDefaultIOHandler() to check whether the returned |
316 | * interface is the default IO handler provided by ASSIMP. The default |
317 | * handler is active as long the application doesn't supply its own |
318 | * custom IO handler via #SetIOHandler(). |
319 | * @return A valid IOSystem interface, never NULL. |
320 | */ |
321 | IOSystem* GetIOHandler() const; |
322 | |
323 | // ------------------------------------------------------------------- |
324 | /** Checks whether a default IO handler is active |
325 | * A default handler is active as long the application doesn't |
326 | * supply its own custom IO handler via #SetIOHandler(). |
327 | * @return true by default |
328 | */ |
329 | bool IsDefaultIOHandler() const; |
330 | |
331 | // ------------------------------------------------------------------- |
332 | /** Supplies a custom progress handler to the importer. This |
333 | * interface exposes an #Update() callback, which is called |
334 | * more or less periodically (please don't sue us if it |
335 | * isn't as periodically as you'd like it to have ...). |
336 | * This can be used to implement progress bars and loading |
337 | * timeouts. |
338 | * @param pHandler Progress callback interface. Pass NULL to |
339 | * disable progress reporting. |
340 | * @note Progress handlers can be used to abort the loading |
341 | * at almost any time.*/ |
342 | void SetProgressHandler ( ProgressHandler* pHandler ); |
343 | |
344 | // ------------------------------------------------------------------- |
345 | /** Retrieves the progress handler that is currently set. |
346 | * You can use #IsDefaultProgressHandler() to check whether the returned |
347 | * interface is the default handler provided by ASSIMP. The default |
348 | * handler is active as long the application doesn't supply its own |
349 | * custom handler via #SetProgressHandler(). |
350 | * @return A valid ProgressHandler interface, never NULL. |
351 | */ |
352 | ProgressHandler* GetProgressHandler() const; |
353 | |
354 | // ------------------------------------------------------------------- |
355 | /** Checks whether a default progress handler is active |
356 | * A default handler is active as long the application doesn't |
357 | * supply its own custom progress handler via #SetProgressHandler(). |
358 | * @return true by default |
359 | */ |
360 | bool IsDefaultProgressHandler() const; |
361 | |
362 | // ------------------------------------------------------------------- |
363 | /** @brief Check whether a given set of post-processing flags |
364 | * is supported. |
365 | * |
366 | * Some flags are mutually exclusive, others are probably |
367 | * not available because your excluded them from your |
368 | * Assimp builds. Calling this function is recommended if |
369 | * you're unsure. |
370 | * |
371 | * @param pFlags Bitwise combination of the aiPostProcess flags. |
372 | * @return true if this flag combination is fine. |
373 | */ |
374 | bool ValidateFlags(unsigned int pFlags) const; |
375 | |
376 | // ------------------------------------------------------------------- |
377 | /** Reads the given file and returns its contents if successful. |
378 | * |
379 | * If the call succeeds, the contents of the file are returned as a |
380 | * pointer to an aiScene object. The returned data is intended to be |
381 | * read-only, the importer object keeps ownership of the data and will |
382 | * destroy it upon destruction. If the import fails, NULL is returned. |
383 | * A human-readable error description can be retrieved by calling |
384 | * GetErrorString(). The previous scene will be deleted during this call. |
385 | * @param pFile Path and filename to the file to be imported. |
386 | * @param pFlags Optional post processing steps to be executed after |
387 | * a successful import. Provide a bitwise combination of the |
388 | * #aiPostProcessSteps flags. If you wish to inspect the imported |
389 | * scene first in order to fine-tune your post-processing setup, |
390 | * consider to use #ApplyPostProcessing(). |
391 | * @return A pointer to the imported data, NULL if the import failed. |
392 | * The pointer to the scene remains in possession of the Importer |
393 | * instance. Use GetOrphanedScene() to take ownership of it. |
394 | * |
395 | * @note Assimp is able to determine the file format of a file |
396 | * automatically. |
397 | */ |
398 | const aiScene* ReadFile( |
399 | const char* pFile, |
400 | unsigned int pFlags); |
401 | |
402 | // ------------------------------------------------------------------- |
403 | /** Reads the given file from a memory buffer and returns its |
404 | * contents if successful. |
405 | * |
406 | * If the call succeeds, the contents of the file are returned as a |
407 | * pointer to an aiScene object. The returned data is intended to be |
408 | * read-only, the importer object keeps ownership of the data and will |
409 | * destroy it upon destruction. If the import fails, NULL is returned. |
410 | * A human-readable error description can be retrieved by calling |
411 | * GetErrorString(). The previous scene will be deleted during this call. |
412 | * Calling this method doesn't affect the active IOSystem. |
413 | * @param pBuffer Pointer to the file data |
414 | * @param pLength Length of pBuffer, in bytes |
415 | * @param pFlags Optional post processing steps to be executed after |
416 | * a successful import. Provide a bitwise combination of the |
417 | * #aiPostProcessSteps flags. If you wish to inspect the imported |
418 | * scene first in order to fine-tune your post-processing setup, |
419 | * consider to use #ApplyPostProcessing(). |
420 | * @param pHint An additional hint to the library. If this is a non |
421 | * empty string, the library looks for a loader to support |
422 | * the file extension specified by pHint and passes the file to |
423 | * the first matching loader. If this loader is unable to completely |
424 | * the request, the library continues and tries to determine the |
425 | * file format on its own, a task that may or may not be successful. |
426 | * Check the return value, and you'll know ... |
427 | * @return A pointer to the imported data, NULL if the import failed. |
428 | * The pointer to the scene remains in possession of the Importer |
429 | * instance. Use GetOrphanedScene() to take ownership of it. |
430 | * |
431 | * @note This is a straightforward way to decode models from memory |
432 | * buffers, but it doesn't handle model formats that spread their |
433 | * data across multiple files or even directories. Examples include |
434 | * OBJ or MD3, which outsource parts of their material info into |
435 | * external scripts. If you need full functionality, provide |
436 | * a custom IOSystem to make Assimp find these files and use |
437 | * the regular ReadFile() API. |
438 | */ |
439 | const aiScene* ReadFileFromMemory( |
440 | const void* pBuffer, |
441 | size_t pLength, |
442 | unsigned int pFlags, |
443 | const char* pHint = "" ); |
444 | |
445 | // ------------------------------------------------------------------- |
446 | /** Apply post-processing to an already-imported scene. |
447 | * |
448 | * This is strictly equivalent to calling #ReadFile() with the same |
449 | * flags. However, you can use this separate function to inspect |
450 | * the imported scene first to fine-tune your post-processing setup. |
451 | * @param pFlags Provide a bitwise combination of the |
452 | * #aiPostProcessSteps flags. |
453 | * @return A pointer to the post-processed data. This is still the |
454 | * same as the pointer returned by #ReadFile(). However, if |
455 | * post-processing fails, the scene could now be NULL. |
456 | * That's quite a rare case, post processing steps are not really |
457 | * designed to 'fail'. To be exact, the #aiProcess_ValidateDS |
458 | * flag is currently the only post processing step which can actually |
459 | * cause the scene to be reset to NULL. |
460 | * |
461 | * @note The method does nothing if no scene is currently bound |
462 | * to the #Importer instance. */ |
463 | const aiScene* ApplyPostProcessing(unsigned int pFlags); |
464 | |
465 | const aiScene* ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ); |
466 | |
467 | // ------------------------------------------------------------------- |
468 | /** @brief Reads the given file and returns its contents if successful. |
469 | * |
470 | * This function is provided for backward compatibility. |
471 | * See the const char* version for detailed docs. |
472 | * @see ReadFile(const char*, pFlags) */ |
473 | const aiScene* ReadFile( |
474 | const std::string& pFile, |
475 | unsigned int pFlags); |
476 | |
477 | // ------------------------------------------------------------------- |
478 | /** Frees the current scene. |
479 | * |
480 | * The function does nothing if no scene has previously been |
481 | * read via ReadFile(). FreeScene() is called automatically by the |
482 | * destructor and ReadFile() itself. */ |
483 | void FreeScene( ); |
484 | |
485 | // ------------------------------------------------------------------- |
486 | /** Returns an error description of an error that occurred in ReadFile(). |
487 | * |
488 | * Returns an empty string if no error occurred. |
489 | * @return A description of the last error, an empty string if no |
490 | * error occurred. The string is never NULL. |
491 | * |
492 | * @note The returned function remains valid until one of the |
493 | * following methods is called: #ReadFile(), #FreeScene(). */ |
494 | const char* GetErrorString() const; |
495 | |
496 | // ------------------------------------------------------------------- |
497 | /** Returns the scene loaded by the last successful call to ReadFile() |
498 | * |
499 | * @return Current scene or NULL if there is currently no scene loaded */ |
500 | const aiScene* GetScene() const; |
501 | |
502 | // ------------------------------------------------------------------- |
503 | /** Returns the scene loaded by the last successful call to ReadFile() |
504 | * and releases the scene from the ownership of the Importer |
505 | * instance. The application is now responsible for deleting the |
506 | * scene. Any further calls to GetScene() or GetOrphanedScene() |
507 | * will return NULL - until a new scene has been loaded via ReadFile(). |
508 | * |
509 | * @return Current scene or NULL if there is currently no scene loaded |
510 | * @note Use this method with maximal caution, and only if you have to. |
511 | * By design, aiScene's are exclusively maintained, allocated and |
512 | * deallocated by Assimp and no one else. The reasoning behind this |
513 | * is the golden rule that deallocations should always be done |
514 | * by the module that did the original allocation because heaps |
515 | * are not necessarily shared. GetOrphanedScene() enforces you |
516 | * to delete the returned scene by yourself, but this will only |
517 | * be fine if and only if you're using the same heap as assimp. |
518 | * On Windows, it's typically fine provided everything is linked |
519 | * against the multithreaded-dll version of the runtime library. |
520 | * It will work as well for static linkage with Assimp.*/ |
521 | aiScene* GetOrphanedScene(); |
522 | |
523 | // ------------------------------------------------------------------- |
524 | /** Returns whether a given file extension is supported by ASSIMP. |
525 | * |
526 | * @param szExtension Extension to be checked. |
527 | * Must include a trailing dot '.'. Example: ".3ds", ".md3". |
528 | * Cases-insensitive. |
529 | * @return true if the extension is supported, false otherwise */ |
530 | bool IsExtensionSupported(const char* szExtension) const; |
531 | |
532 | // ------------------------------------------------------------------- |
533 | /** @brief Returns whether a given file extension is supported by ASSIMP. |
534 | * |
535 | * This function is provided for backward compatibility. |
536 | * See the const char* version for detailed and up-to-date docs. |
537 | * @see IsExtensionSupported(const char*) */ |
538 | inline bool IsExtensionSupported(const std::string& szExtension) const; |
539 | |
540 | // ------------------------------------------------------------------- |
541 | /** Get a full list of all file extensions supported by ASSIMP. |
542 | * |
543 | * If a file extension is contained in the list this does of course not |
544 | * mean that ASSIMP is able to load all files with this extension --- |
545 | * it simply means there is an importer loaded which claims to handle |
546 | * files with this file extension. |
547 | * @param szOut String to receive the extension list. |
548 | * Format of the list: "*.3ds;*.obj;*.dae". This is useful for |
549 | * use with the WinAPI call GetOpenFileName(Ex). */ |
550 | void GetExtensionList(aiString& szOut) const; |
551 | |
552 | // ------------------------------------------------------------------- |
553 | /** @brief Get a full list of all file extensions supported by ASSIMP. |
554 | * |
555 | * This function is provided for backward compatibility. |
556 | * See the aiString version for detailed and up-to-date docs. |
557 | * @see GetExtensionList(aiString&)*/ |
558 | inline void GetExtensionList(std::string& szOut) const; |
559 | |
560 | // ------------------------------------------------------------------- |
561 | /** Get the number of importers currently registered with Assimp. */ |
562 | size_t GetImporterCount() const; |
563 | |
564 | // ------------------------------------------------------------------- |
565 | /** Get meta data for the importer corresponding to a specific index.. |
566 | * |
567 | * For the declaration of #aiImporterDesc, include <assimp/importerdesc.h>. |
568 | * @param index Index to query, must be within [0,GetImporterCount()) |
569 | * @return Importer meta data structure, NULL if the index does not |
570 | * exist or if the importer doesn't offer meta information ( |
571 | * importers may do this at the cost of being hated by their peers).*/ |
572 | const aiImporterDesc* GetImporterInfo(size_t index) const; |
573 | |
574 | // ------------------------------------------------------------------- |
575 | /** Find the importer corresponding to a specific index. |
576 | * |
577 | * @param index Index to query, must be within [0,GetImporterCount()) |
578 | * @return Importer instance. NULL if the index does not |
579 | * exist. */ |
580 | BaseImporter* GetImporter(size_t index) const; |
581 | |
582 | // ------------------------------------------------------------------- |
583 | /** Find the importer corresponding to a specific file extension. |
584 | * |
585 | * This is quite similar to #IsExtensionSupported except a |
586 | * BaseImporter instance is returned. |
587 | * @param szExtension Extension to check for. The following formats |
588 | * are recognized (BAH being the file extension): "BAH" (comparison |
589 | * is case-insensitive), ".bah", "*.bah" (wild card and dot |
590 | * characters at the beginning of the extension are skipped). |
591 | * @return NULL if no importer is found*/ |
592 | BaseImporter* GetImporter (const char* szExtension) const; |
593 | |
594 | // ------------------------------------------------------------------- |
595 | /** Find the importer index corresponding to a specific file extension. |
596 | * |
597 | * @param szExtension Extension to check for. The following formats |
598 | * are recognized (BAH being the file extension): "BAH" (comparison |
599 | * is case-insensitive), ".bah", "*.bah" (wild card and dot |
600 | * characters at the beginning of the extension are skipped). |
601 | * @return (size_t)-1 if no importer is found */ |
602 | size_t GetImporterIndex (const char* szExtension) const; |
603 | |
604 | // ------------------------------------------------------------------- |
605 | /** Returns the storage allocated by ASSIMP to hold the scene data |
606 | * in memory. |
607 | * |
608 | * This refers to the currently loaded file, see #ReadFile(). |
609 | * @param in Data structure to be filled. |
610 | * @note The returned memory statistics refer to the actual |
611 | * size of the use data of the aiScene. Heap-related overhead |
612 | * is (naturally) not included.*/ |
613 | void GetMemoryRequirements(aiMemoryInfo& in) const; |
614 | |
615 | // ------------------------------------------------------------------- |
616 | /** Enables "extra verbose" mode. |
617 | * |
618 | * 'Extra verbose' means the data structure is validated after *every* |
619 | * single post processing step to make sure everyone modifies the data |
620 | * structure in a well-defined manner. This is a debug feature and not |
621 | * intended for use in production environments. */ |
622 | void (bool bDo); |
623 | |
624 | // ------------------------------------------------------------------- |
625 | /** Private, do not use. */ |
626 | ImporterPimpl* Pimpl() { return pimpl; } |
627 | const ImporterPimpl* Pimpl() const { return pimpl; } |
628 | |
629 | protected: |
630 | |
631 | // Just because we don't want you to know how we're hacking around. |
632 | ImporterPimpl* pimpl; |
633 | }; //! class Importer |
634 | |
635 | |
636 | // ---------------------------------------------------------------------------- |
637 | // For compatibility, the interface of some functions taking a std::string was |
638 | // changed to const char* to avoid crashes between binary incompatible STL |
639 | // versions. This code her is inlined, so it shouldn't cause any problems. |
640 | // ---------------------------------------------------------------------------- |
641 | |
642 | // ---------------------------------------------------------------------------- |
643 | AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){ |
644 | return ReadFile(pFile: pFile.c_str(),pFlags); |
645 | } |
646 | // ---------------------------------------------------------------------------- |
647 | AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const { |
648 | aiString s; |
649 | GetExtensionList(szOut&: s); |
650 | szOut = s.data; |
651 | } |
652 | // ---------------------------------------------------------------------------- |
653 | AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const { |
654 | return IsExtensionSupported(szExtension: szExtension.c_str()); |
655 | } |
656 | |
657 | } // !namespace Assimp |
658 | |
659 | #endif // AI_ASSIMP_HPP_INC |
660 | |