Importer Class Reference

Description

Module responsible for importing various asset types and converting them to types usable by the engine.

Inherits Module< Importer >.

Methods

HResource import (const Path &inputFilePath, SPtr< const ImportOptions > importOptions=nullptr, const String &UUID=StringUtil::BLANK)
 Imports a resource at the specified location, and returns the loaded data. More...
 
template<class T >
ResourceHandle< T > import (const Path &inputFilePath, SPtr< const ImportOptions > importOptions=nullptr, const String &UUID=StringUtil::BLANK)
 Imports a resource at the specified location, and returns the loaded data. More...
 
Vector< SubResourceimportAll (const Path &inputFilePath, SPtr< const ImportOptions > importOptions=nullptr)
 Imports a resource at the specified location, and returns the loaded data. More...
 
void reimport (HResource &existingResource, const Path &inputFilePath, SPtr< const ImportOptions > importOptions=nullptr)
 Imports a resource and replaces the contents of the provided existing resource with new imported data. More...
 
SPtr< ImportOptionscreateImportOptions (const Path &inputFilePath)
 Automatically detects the importer needed for the provided file and returns valid type of import options for that importer. More...
 
template<class T >
SPtr< T > createImportOptions (const Path &inputFilePath)
 Automatically detects the importer needed for the provided file and returns valid type of import options for that importer. More...
 
bool supportsFileType (const WString &extension) const
 Checks if we can import a file with the specified extension. More...
 
bool supportsFileType (const UINT8 *magicNumber, UINT32 magicNumSize) const
 Checks if we can import a file with the specified magic number. More...
 
Internal
void _registerAssetImporter (SpecificImporter *importer)
 Registers a new asset importer for a specific set of extensions (as determined by the implementation). More...
 
Vector< SubResourceRaw_importAllRaw (const Path &inputFilePath, SPtr< const ImportOptions > importOptions=nullptr)
 Alternative to importAll() which doesn't create resource handles, but instead returns raw resource pointers. More...
 

Additional Inherited Members

- Static methods inherited from Module< Importer >
static Importerinstance ()
 Returns a reference to the module instance. More...
 
static ImporterinstancePtr ()
 Returns a pointer to the module instance. More...
 
static void startUp (Args &&...args)
 Constructs and starts the module using the specified parameters. More...
 
static void startUp (Args &&...args)
 Constructs and starts a specialized type of the module. More...
 
static void shutDown ()
 Shuts down this module and frees any resources it is using. More...
 
static bool isStarted ()
 Query if the module has been started. More...
 

Method documentation

Vector<SubResourceRaw> _importAllRaw ( const Path inputFilePath,
SPtr< const ImportOptions importOptions = nullptr 
)

Alternative to importAll() which doesn't create resource handles, but instead returns raw resource pointers.

void _registerAssetImporter ( SpecificImporter importer)

Registers a new asset importer for a specific set of extensions (as determined by the implementation).

If an asset importer for one or multiple extensions already exists, it is removed and replaced with this one.

Parameters
[in]importerThe importer that is able to handle import of certain type of files.
Note
This method should only be called by asset importers themselves on startup. Importer takes ownership of the provided pointer and will release it. Assumes it is allocated using the general allocator.
SPtr<ImportOptions> createImportOptions ( const Path inputFilePath)

Automatically detects the importer needed for the provided file and returns valid type of import options for that importer.

Parameters
[in]inputFilePathPathname of the input file.
Returns
The new import options. Null is returned if the file path is not valid, or if a valid importer cannot be found for the specified file.
Note
You will need to type cast the importer options to a valid type, taking into consideration exact importer you expect to be used for this file type. If you don't use a proper import options type, an exception will be thrown during import.
SPtr<T> createImportOptions ( const Path inputFilePath)

Automatically detects the importer needed for the provided file and returns valid type of import options for that importer.

Parameters
[in]inputFilePathPathname of the input file.
Returns
The new import options. Null is returned if the file path is not valid, or if a valid importer cannot be found for the specified file.
Note
You will need to type cast the importer options to a valid type, taking into consideration exact importer you expect to be used for this file type. If you don't use a proper import options type, an exception will be thrown during import.
HResource import ( const Path inputFilePath,
SPtr< const ImportOptions importOptions = nullptr,
const String UUID = StringUtil::BLANK 
)

Imports a resource at the specified location, and returns the loaded data.

If file contains more than one resource only the primary resource is imported (for example an FBX a mesh would be imported, but animations ignored).

Parameters
[in]inputFilePathPathname of the input file.
[in]importOptions(optional) Options for controlling the import. Caller must ensure import options actually match the type of the importer used for the file type.
[in]UUIDSpecific UUID to assign to the resource. If not specified a randomly generated UUID will be assigned.
Returns
Imported resource.
See also
createImportOptions
ResourceHandle<T> import ( const Path inputFilePath,
SPtr< const ImportOptions importOptions = nullptr,
const String UUID = StringUtil::BLANK 
)

Imports a resource at the specified location, and returns the loaded data.

If file contains more than one resource only the primary resource is imported (for example an FBX a mesh would be imported, but animations ignored).

Parameters
[in]inputFilePathPathname of the input file.
[in]importOptions(optional) Options for controlling the import. Caller must ensure import options actually match the type of the importer used for the file type.
[in]UUIDSpecific UUID to assign to the resource. If not specified a randomly generated UUID will be assigned.
Returns
Imported resource.
See also
createImportOptions
Vector<SubResource> importAll ( const Path inputFilePath,
SPtr< const ImportOptions importOptions = nullptr 
)

Imports a resource at the specified location, and returns the loaded data.

This method returns all imported resources, which is relevant for files that can contain multiple resources (for example an FBX which may contain both a mesh and animations).

Parameters
[in]inputFilePathPathname of the input file.
[in]importOptions(optional) Options for controlling the import. Caller must ensure import options actually match the type of the importer used for the file type.
Returns
A list of all imported resources. The primary resource is always the first returned resource.
See also
createImportOptions
void reimport ( HResource existingResource,
const Path inputFilePath,
SPtr< const ImportOptions importOptions = nullptr 
)

Imports a resource and replaces the contents of the provided existing resource with new imported data.

Parameters
[in]existingResourceResource whose contents to replace.
[in]inputFilePathPathname of the input file.
[in]importOptions(optional) Options for controlling the import. Caller must ensure import options actually match the type of the importer used for the file type.
See also
createImportOptions
bool supportsFileType ( const WString extension) const

Checks if we can import a file with the specified extension.

Parameters
[in]extensionThe extension without the leading dot.
bool supportsFileType ( const UINT8 *  magicNumber,
UINT32  magicNumSize 
) const

Checks if we can import a file with the specified magic number.

Parameters
[in]magicNumberThe buffer containing the magic number.
[in]magicNumSizeSize of the magic number buffer.