Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
|
CPP-API: The Importer class forms an C++ interface to the functionality of the Open Asset Import Library. More...
#include <Importer.hpp>
Public Member Functions | |
const aiScene * | ApplyCustomizedPostProcessing (BaseProcess *rootProcess, bool requestValidation) |
const aiScene * | ApplyPostProcessing (unsigned int pFlags) |
Apply post-processing to an already-imported scene. More... | |
void | FreeScene () |
Frees the current scene. More... | |
const char * | GetErrorString () const |
Returns an error description of an error that occurred in ReadFile(). More... | |
const std::exception_ptr & | GetException () const |
Returns an exception if one occurred during import. More... | |
void | GetExtensionList (aiString &szOut) const |
Get a full list of all file extensions supported by ASSIMP. More... | |
void | GetExtensionList (std::string &szOut) const |
Get a full list of all file extensions supported by ASSIMP. More... | |
BaseImporter * | GetImporter (const char *szExtension) const |
Find the importer corresponding to a specific file extension. More... | |
BaseImporter * | GetImporter (size_t index) const |
Find the importer corresponding to a specific index. More... | |
size_t | GetImporterCount () const |
Get the number of importers currently registered with Assimp. More... | |
size_t | GetImporterIndex (const char *szExtension) const |
Find the importer index corresponding to a specific file extension. More... | |
const aiImporterDesc * | GetImporterInfo (size_t index) const |
Get meta data for the importer corresponding to a specific index. More... | |
IOSystem * | GetIOHandler () const |
Retrieves the IO handler that is currently set. More... | |
void | GetMemoryRequirements (aiMemoryInfo &in) const |
Returns the storage allocated by ASSIMP to hold the scene data in memory. More... | |
aiScene * | GetOrphanedScene () |
Returns the scene loaded by the last successful call to ReadFile() and releases the scene from the ownership of the Importer instance. More... | |
ProgressHandler * | GetProgressHandler () const |
Retrieves the progress handler that is currently set. More... | |
bool | GetPropertyBool (const char *szName, bool bErrorReturn=false) const |
Get a boolean configuration property. More... | |
ai_real | GetPropertyFloat (const char *szName, ai_real fErrorReturn=10e10) const |
Get a floating-point configuration property. More... | |
int | GetPropertyInteger (const char *szName, int iErrorReturn=0xffffffff) const |
Get a configuration property. More... | |
aiMatrix4x4 | GetPropertyMatrix (const char *szName, const aiMatrix4x4 &sErrorReturn=aiMatrix4x4()) const |
Get a matrix configuration property. More... | |
void * | GetPropertyPointer (const char *szName, void *sErrorReturn=nullptr) const |
Get a pointer configuration property. More... | |
std::string | GetPropertyString (const char *szName, const std::string &sErrorReturn=std::string()) const |
Get a string configuration property. More... | |
const aiScene * | GetScene () const |
Returns the scene loaded by the last successful call to ReadFile() More... | |
Importer () | |
Constructor. More... | |
Importer (const Importer &other)=delete | |
Copy constructor. More... | |
bool | IsDefaultIOHandler () const |
Checks whether a default IO handler is active A default handler is active as long the application doesn't supply its own custom IO handler via SetIOHandler(). More... | |
bool | IsDefaultProgressHandler () const |
Checks whether a default progress handler is active A default handler is active as long the application doesn't supply its own custom progress handler via SetProgressHandler(). More... | |
bool | IsExtensionSupported (const char *szExtension) const |
Returns whether a given file extension is supported by ASSIMP. More... | |
bool | IsExtensionSupported (const std::string &szExtension) const |
Returns whether a given file extension is supported by ASSIMP. More... | |
Importer & | operator= (const Importer &)=delete |
Assignment operator has been deleted. More... | |
ImporterPimpl * | Pimpl () |
Private, do not use. More... | |
const ImporterPimpl * | Pimpl () const |
const aiScene * | ReadFile (const char *pFile, unsigned int pFlags) |
Reads the given file and returns its contents if successful. More... | |
const aiScene * | ReadFile (const std::string &pFile, unsigned int pFlags) |
Reads the given file and returns its contents if successful. More... | |
const aiScene * | ReadFileFromMemory (const void *pBuffer, size_t pLength, unsigned int pFlags, const char *pHint="") |
Reads the given file from a memory buffer and returns its contents if successful. More... | |
aiReturn | RegisterLoader (BaseImporter *pImp) |
Registers a new loader. More... | |
aiReturn | RegisterPPStep (BaseProcess *pImp) |
Registers a new post-process step. More... | |
void | SetExtraVerbose (bool bDo) |
Enables "extra verbose" mode. More... | |
void | SetIOHandler (IOSystem *pIOHandler) |
Supplies a custom IO handler to the importer to use to open and access files. More... | |
void | SetProgressHandler (ProgressHandler *pHandler) |
Supplies a custom progress handler to the importer. More... | |
bool | SetPropertyBool (const char *szName, bool value) |
Set a boolean configuration property. More... | |
bool | SetPropertyFloat (const char *szName, ai_real fValue) |
Set a floating-point configuration property. More... | |
bool | SetPropertyInteger (const char *szName, int iValue) |
Set an integer configuration property. More... | |
bool | SetPropertyMatrix (const char *szName, const aiMatrix4x4 &sValue) |
Set a matrix configuration property. More... | |
bool | SetPropertyPointer (const char *szName, void *sValue) |
Set a pointer configuration property. More... | |
bool | SetPropertyString (const char *szName, const std::string &sValue) |
Set a string configuration property. More... | |
aiReturn | UnregisterLoader (BaseImporter *pImp) |
Unregisters a loader. More... | |
aiReturn | UnregisterPPStep (BaseProcess *pImp) |
Unregisters a post-process step. More... | |
bool | ValidateFlags (unsigned int pFlags) const |
Check whether a given set of post-processing flags is supported. More... | |
~Importer () | |
Destructor. More... | |
Static Public Attributes | |
static const unsigned int | MaxLenHint = 200 |
The upper limit for hints. More... | |
Protected Attributes | |
ImporterPimpl * | pimpl |
CPP-API: The Importer class forms an C++ interface to the functionality of the Open Asset Import Library.
Create an object of this class and call ReadFile() to import a file. If the import succeeds, the function returns a pointer to the imported data. The data remains property of the object, it is intended to be accessed read-only. The imported data will be destroyed along with the Importer object. If the import fails, ReadFile() returns a nullptr pointer. In this case you can retrieve a human-readable error description be calling GetErrorString(). You can call ReadFile() multiple times with a single Importer instance. Actually, constructing Importer objects involves quite many allocations and may take some time, so it's better to reuse them as often as possible.
If you need the Importer to do custom file handling to access the files, implement IOSystem and IOStream and supply an instance of your custom IOSystem implementation by calling SetIOHandler() before calling ReadFile(). If you do not assign a custion IO handler, a default handler using the standard C++ IO logic will be used.
Assimp::Importer::Importer | ( | ) |
Constructor.
Creates an empty importer object.
Call ReadFile() to start the import process. The configuration property table is initially empty.
|
delete |
Copy constructor.
This copies the configuration properties of another Importer. If this Importer owns a scene it won't be copied. Call ReadFile() to start the import process.
Assimp::Importer::~Importer | ( | ) |
Destructor.
The object kept ownership of the imported data, which now will be destroyed along with the object.
const aiScene * Assimp::Importer::ApplyCustomizedPostProcessing | ( | BaseProcess * | rootProcess, |
bool | requestValidation | ||
) |
const aiScene * Assimp::Importer::ApplyPostProcessing | ( | unsigned int | pFlags | ) |
Apply post-processing to an already-imported scene.
This is strictly equivalent to calling ReadFile() with the same flags. However, you can use this separate function to inspect the imported scene first to fine-tune your post-processing setup.
pFlags | Provide a bitwise combination of the aiPostProcessSteps flags. |
void Assimp::Importer::FreeScene | ( | ) |
Frees the current scene.
The function does nothing if no scene has previously been read via ReadFile(). FreeScene() is called automatically by the destructor and ReadFile() itself.
const char * Assimp::Importer::GetErrorString | ( | ) | const |
Returns an error description of an error that occurred in ReadFile().
Returns an empty string if no error occurred.
const std::exception_ptr & Assimp::Importer::GetException | ( | ) | const |
Returns an exception if one occurred during import.
void Assimp::Importer::GetExtensionList | ( | aiString & | szOut | ) | const |
Get a full list of all file extensions supported by ASSIMP.
If a file extension is contained in the list this does of course not mean that ASSIMP is able to load all files with this extension — it simply means there is an importer loaded which claims to handle files with this file extension.
szOut | String to receive the extension list. Format of the list: "*.3ds;*.obj;*.dae". This is useful for use with the WinAPI call GetOpenFileName(Ex). |
|
inline |
Get a full list of all file extensions supported by ASSIMP.
This function is provided for backward compatibility. See the aiString version for detailed and up-to-date docs.
BaseImporter * Assimp::Importer::GetImporter | ( | const char * | szExtension | ) | const |
Find the importer corresponding to a specific file extension.
This is quite similar to IsExtensionSupported except a BaseImporter instance is returned.
szExtension | Extension to check for. The following formats are recognized (BAH being the file extension): "BAH" (comparison is case-insensitive), ".bah", "*.bah" (wild card and dot characters at the beginning of the extension are skipped). |
BaseImporter * Assimp::Importer::GetImporter | ( | size_t | index | ) | const |
Find the importer corresponding to a specific index.
index | Index to query, must be within [0,GetImporterCount()) |
size_t Assimp::Importer::GetImporterCount | ( | ) | const |
Get the number of importers currently registered with Assimp.
size_t Assimp::Importer::GetImporterIndex | ( | const char * | szExtension | ) | const |
Find the importer index corresponding to a specific file extension.
szExtension | Extension to check for. The following formats are recognized (BAH being the file extension): "BAH" (comparison is case-insensitive), ".bah", "*.bah" (wild card and dot characters at the beginning of the extension are skipped). |
const aiImporterDesc * Assimp::Importer::GetImporterInfo | ( | size_t | index | ) | const |
Get meta data for the importer corresponding to a specific index.
For the declaration of aiImporterDesc, include <assimp/importerdesc.h>.
index | Index to query, must be within [0,GetImporterCount()) |
IOSystem * Assimp::Importer::GetIOHandler | ( | ) | const |
Retrieves the IO handler that is currently set.
You can use IsDefaultIOHandler() to check whether the returned interface is the default IO handler provided by ASSIMP. The default handler is active as long the application doesn't supply its own custom IO handler via SetIOHandler().
void Assimp::Importer::GetMemoryRequirements | ( | aiMemoryInfo & | in | ) | const |
Returns the storage allocated by ASSIMP to hold the scene data in memory.
This refers to the currently loaded file, see ReadFile().
in | Data structure to be filled. |
aiScene * Assimp::Importer::GetOrphanedScene | ( | ) |
Returns the scene loaded by the last successful call to ReadFile() and releases the scene from the ownership of the Importer instance.
The application is now responsible for deleting the scene. Any further calls to GetScene() or GetOrphanedScene() will return nullptr - until a new scene has been loaded via ReadFile().
ProgressHandler * Assimp::Importer::GetProgressHandler | ( | ) | const |
Retrieves the progress handler that is currently set.
You can use IsDefaultProgressHandler() to check whether the returned interface is the default handler provided by ASSIMP. The default handler is active as long the application doesn't supply its own custom handler via SetProgressHandler().
|
inline |
Get a boolean configuration property.
Boolean properties are stored on the integer stack internally so it's possible to set them via SetPropertyBool and query them with GetPropertyBool and vice versa.
ai_real Assimp::Importer::GetPropertyFloat | ( | const char * | szName, |
ai_real | fErrorReturn = 10e10 |
||
) | const |
Get a floating-point configuration property.
int Assimp::Importer::GetPropertyInteger | ( | const char * | szName, |
int | iErrorReturn = 0xffffffff |
||
) | const |
Get a configuration property.
szName | Name of the property. All supported properties are defined in the aiConfig.g header (all constants share the prefix AI_CONFIG_XXX). |
iErrorReturn | Value that is returned if the property is not found. |
aiMatrix4x4 Assimp::Importer::GetPropertyMatrix | ( | const char * | szName, |
const aiMatrix4x4 & | sErrorReturn = aiMatrix4x4() |
||
) | const |
Get a matrix configuration property.
The return value remains valid until the property is modified.
void * Assimp::Importer::GetPropertyPointer | ( | const char * | szName, |
void * | sErrorReturn = nullptr |
||
) | const |
Get a pointer configuration property.
The return value remains valid until the property is modified.
std::string Assimp::Importer::GetPropertyString | ( | const char * | szName, |
const std::string & | sErrorReturn = std::string() |
||
) | const |
Get a string configuration property.
The return value remains valid until the property is modified.
const aiScene * Assimp::Importer::GetScene | ( | ) | const |
Returns the scene loaded by the last successful call to ReadFile()
bool Assimp::Importer::IsDefaultIOHandler | ( | ) | const |
Checks whether a default IO handler is active A default handler is active as long the application doesn't supply its own custom IO handler via SetIOHandler().
bool Assimp::Importer::IsDefaultProgressHandler | ( | ) | const |
Checks whether a default progress handler is active A default handler is active as long the application doesn't supply its own custom progress handler via SetProgressHandler().
bool Assimp::Importer::IsExtensionSupported | ( | const char * | szExtension | ) | const |
Returns whether a given file extension is supported by ASSIMP.
szExtension | Extension to be checked. Must include a trailing dot '.'. Example: ".3ds", ".md3". Cases-insensitive. |
|
inline |
Returns whether a given file extension is supported by ASSIMP.
This function is provided for backward compatibility. See the const char* version for detailed and up-to-date docs.
Assignment operator has been deleted.
|
inline |
Private, do not use.
|
inline |
const aiScene * Assimp::Importer::ReadFile | ( | const char * | pFile, |
unsigned int | pFlags | ||
) |
Reads the given file and returns its contents if successful.
If the call succeeds, the contents of the file are returned as a pointer to an aiScene object. The returned data is intended to be read-only, the importer object keeps ownership of the data and will destroy it upon destruction. If the import fails, nullptr is returned. A human-readable error description can be retrieved by calling GetErrorString(). The previous scene will be deleted during this call.
pFile | Path and filename to the file to be imported. |
pFlags | Optional post processing steps to be executed after a successful import. Provide a bitwise combination of the aiPostProcessSteps flags. If you wish to inspect the imported scene first in order to fine-tune your post-processing setup, consider to use ApplyPostProcessing(). |
AI_FORCE_INLINE const aiScene * Assimp::Importer::ReadFile | ( | const std::string & | pFile, |
unsigned int | pFlags | ||
) |
Reads the given file and returns its contents if successful.
class Importer
This function is provided for backward compatibility. See the const char* version for detailed docs.
const aiScene * Assimp::Importer::ReadFileFromMemory | ( | const void * | pBuffer, |
size_t | pLength, | ||
unsigned int | pFlags, | ||
const char * | pHint = "" |
||
) |
Reads the given file from a memory buffer and returns its contents if successful.
If the call succeeds, the contents of the file are returned as a pointer to an aiScene object. The returned data is intended to be read-only, the importer object keeps ownership of the data and will destroy it upon destruction. If the import fails, nullptr is returned. A human-readable error description can be retrieved by calling GetErrorString(). The previous scene will be deleted during this call. Calling this method doesn't affect the active IOSystem.
pBuffer | Pointer to the file data |
pLength | Length of pBuffer, in bytes |
pFlags | Optional post processing steps to be executed after a successful import. Provide a bitwise combination of the aiPostProcessSteps flags. If you wish to inspect the imported scene first in order to fine-tune your post-processing setup, consider to use ApplyPostProcessing(). |
pHint | An additional hint to the library. If this is a non empty string, the library looks for a loader to support the file extension specified by pHint and passes the file to the first matching loader. If this loader is unable to completely the request, the library continues and tries to determine the file format on its own, a task that may or may not be successful. Check the return value, and you'll know ... |
aiReturn Assimp::Importer::RegisterLoader | ( | BaseImporter * | pImp | ) |
Registers a new loader.
pImp | Importer to be added. The Importer instance takes ownership of the pointer, so it will be automatically deleted with the Importer instance. |
aiReturn Assimp::Importer::RegisterPPStep | ( | BaseProcess * | pImp | ) |
Registers a new post-process step.
At the moment, there's a small limitation: new post processing steps are added to end of the list, or in other words, executed last, after all built-in steps.
pImp | Post-process step to be added. The Importer instance takes ownership of the pointer, so it will be automatically deleted with the Importer instance. |
void Assimp::Importer::SetExtraVerbose | ( | bool | bDo | ) |
Enables "extra verbose" mode.
'Extra verbose' means the data structure is validated after every single post processing step to make sure everyone modifies the data structure in a well-defined manner. This is a debug feature and not intended for use in production environments.
void Assimp::Importer::SetIOHandler | ( | IOSystem * | pIOHandler | ) |
Supplies a custom IO handler to the importer to use to open and access files.
If you need the importer to use custom IO logic to access the files, you need to provide a custom implementation of IOSystem and IOFile to the importer. Then create an instance of your custom IOSystem implementation and supply it by this function.
The Importer takes ownership of the object and will destroy it afterwards. The previously assigned handler will be deleted. Pass nullptr to take again ownership of your IOSystem and reset Assimp to use its default implementation.
pIOHandler | The IO handler to be used in all file accesses of the Importer. |
void Assimp::Importer::SetProgressHandler | ( | ProgressHandler * | pHandler | ) |
Supplies a custom progress handler to the importer.
This interface exposes an #Update() callback, which is called more or less periodically (please don't sue us if it isn't as periodically as you'd like it to have ...). This can be used to implement progress bars and loading timeouts.
pHandler | Progress callback interface. Pass nullptr to disable progress reporting. |
|
inline |
Set a boolean configuration property.
Boolean properties are stored on the integer stack internally so it's possible to set them via SetPropertyBool and query them with GetPropertyBool and vice versa.
bool Assimp::Importer::SetPropertyFloat | ( | const char * | szName, |
ai_real | fValue | ||
) |
Set a floating-point configuration property.
bool Assimp::Importer::SetPropertyInteger | ( | const char * | szName, |
int | iValue | ||
) |
Set an integer configuration property.
szName | Name of the property. All supported properties are defined in the aiConfig.g header (all constants share the prefix AI_CONFIG_XXX and are simple strings). |
iValue | New value of the property |
bool Assimp::Importer::SetPropertyMatrix | ( | const char * | szName, |
const aiMatrix4x4 & | sValue | ||
) |
Set a matrix configuration property.
bool Assimp::Importer::SetPropertyPointer | ( | const char * | szName, |
void * | sValue | ||
) |
Set a pointer configuration property.
bool Assimp::Importer::SetPropertyString | ( | const char * | szName, |
const std::string & | sValue | ||
) |
Set a string configuration property.
aiReturn Assimp::Importer::UnregisterLoader | ( | BaseImporter * | pImp | ) |
aiReturn Assimp::Importer::UnregisterPPStep | ( | BaseProcess * | pImp | ) |
Unregisters a post-process step.
pImp | Step to be unregistered. |
bool Assimp::Importer::ValidateFlags | ( | unsigned int | pFlags | ) | const |
Check whether a given set of post-processing flags is supported.
Some flags are mutually exclusive, others are probably not available because your excluded them from your Assimp builds. Calling this function is recommended if you're unsure.
pFlags | Bitwise combination of the aiPostProcess flags. |
|
static |
The upper limit for hints.
|
protected |