Importer Class
Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
This class is used to manage a file importer. File importers are used by the Engine's import system to bring the data stored in various non-native formats to UNIGINE. Each importer can be used to import multiple file formats, but there shouldn't be two or more importers registered for a single file format.
Importer Class
Members
void setAnimationsProcessor ( string processor ) #
Sets a new import processor to be used for importing animations.
Arguments
- string processor - The animations import processor.
string getAnimationsProcessor() const#
Returns the current
import processor to be used for importing animations.
Return value
Current animations import processor.void setLightsProcessor ( string processor ) #
Sets a new import processor to be used for importing light sources.
Arguments
- string processor - The lights import processor.
string getLightsProcessor() const#
Returns the current
import processor to be used for importing light sources.
Return value
Current lights import processor.void setMeshesProcessor ( string processor ) #
Sets a new import processor to be used for importing meshes.
Arguments
- string processor - The meshes import processor.
string getMeshesProcessor() const#
Returns the current
import processor to be used for importing meshes.
Return value
Current meshes import processor.void setNodesProcessor ( string processor ) #
Sets a new import processor to be used for importing nodes.
Arguments
- string processor - The nodes import processor.
string getNodesProcessor() const#
Returns the current
import processor to be used for importing nodes.
Return value
Current nodes import processor.void setCamerasProcessor ( string processor ) #
Sets a new import processor to be used for importing cameras.
Arguments
- string processor - The cameras import processor.
string getCamerasProcessor() const#
Returns the current
import processor to be used for importing cameras.
Return value
Current cameras import processor.void setMaterialsProcessor ( string processor ) #
Sets a new import processor to be used for importing materials.
Arguments
- string processor - The materials import processor.
string getMaterialsProcessor() const#
Returns the current
import processor to be used for importing materials.
Return value
Current materials import processor.void setOutputFilepath ( string filepath ) #
Sets a new output file path.resulting output file path for imported scene component(s). In case a set of files is generated, the path to resulting *.node file will be returned.
Arguments
- string filepath - The
string getOutputFilepath() const#
Returns the current
output file path.resulting output file path for imported scene component(s). In case a set of files is generated, the path to resulting *.node file will be returned.
Return value
Currentvoid setTexturesProcessor ( string processor ) #
Sets a new import processor to be used for importing textures.
Arguments
- string processor - The textures import processor.
string getTexturesProcessor() const#
Returns the current
import processor to be used for importing textures.
Return value
Current textures import processor.Importer ( ) #
Constructor. Creates an empty importer.Importer getImporter ( ) #
Returns the importer itself.Return value
Importer itself.bool containsParameter ( string name ) #
Returns a value indicating whether the list of import parameters includes a parameter with a given name.Arguments
- string name - Parameter name.
Return value
true if the list of import parameters includes a parameter with a given name; otherwise, false.void setParameterInt ( string name, int v ) #
Sets a new value for the specified integer parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the integer parameter.
- int v - New value to be set.
int getParameterInt ( string name ) #
Returns the current value of the specified integer parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the integer parameter.
Return value
Value of the integer parameter.void setParameterFloat ( string name, float v ) #
Sets a new value for the specified float parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the float parameter.
- float v - New value to be set.
float getParameterFloat ( string name ) #
Returns the current value of the specified float parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the float parameter.
Return value
Value of the float parameter.void setParameterDouble ( string name, double v ) #
Sets a new value for the specified double parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the double parameter.
- double v - New value to be set.
double getParameterDouble ( string name ) #
Returns the current value of the specified double parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the double parameter.
Return value
Value of the double parameter.void setParameterString ( string name, string v ) #
Sets a new value for the specified string parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the string parameter.
- string v - New value to be set.
string getParameterString ( string name ) #
Returns the current value of the specified string parameter. There are built-in parameters that can also be used in custom importers.Arguments
- string name - Name of the string parameter.
Return value
Value of the string parameter.bool addPreProcessor ( string type_name ) #
Adds an import pre-processor with a given type name. There are built-in pre-processors that can also be added to custom importers.Arguments
- string type_name - Pre-processor type name.
Return value
true if the specified import pre-processor is successfully added; otherwise, false.void removePreProcessor ( string type_name ) #
Removes an import pre-processor with a given type name. There are built-in pre-processors that can also be added to custom importers.Arguments
- string type_name - Pre-processor type name.
bool hasPreProcessor ( string type_name ) #
Returns a value indicating if an import pre-processor with a given type name is used by the importer. There are built-in pre-processors that can also be added to custom importers.Arguments
- string type_name - Pre-processor type name.
Return value
true if an import pre-processor with a given type name is used by the importer; otherwise, false.bool addPostProcessor ( string type_name ) #
Adds an import post-processor with a given type name. There are built-in post-processors that can also be added to custom importers.Arguments
- string type_name - Post-processor type name to check.
void removePostProcessor ( string type_name ) #
Removes an import post-processor with a given type name. There are built-in post-processors that can also be added to custom importers.Arguments
- string type_name - Post-processor type name.
bool hasPostProcessor ( string type_name ) #
Returns a value indicating if an import post-processor with a given type name is used by the importer. There are built-in post-processors that can also be added to custom importers.Arguments
- string type_name - Post-processor type name to check.
Return value
true if an import post-processor with a given type name is used by the importer; otherwise, false.ImportScene getScene ( ) #
Returns the imported scene.Return value
Instance of the ImportScene class.bool init ( string filepath, int flags = ~0 ) #
Initializes the importer for the specified file using the given flags. Import flags specify which scene components are to be imported.Arguments
- string filepath - Path to a file to be imported.
- int flags - Set of import flags. Any combination of IMPORT_* flags, or ~0 to set all of them.
Return value
true if the importer was initialized successfully; otherwise, 0.bool import ( string output_path ) #
Imports the contents of the input file to the specified output path.Arguments
- string output_path - Output path.
Return value
true if the contents of the input file are successfully imported to the specified output path; otherwise, false.string getSourceFilepath ( ) #
Returns the path to the source file.Return value
Source file path.int getFlags ( ) #
Returns the current set of import flags (IMPORT_*) resulting output file path for imported scene component(s). In case if a set of files were generated the path to resulting *.node file will be returned.bool computeBoundBox ( ImportMesh import_mesh ) #
Computes a bound box for the specified mesh.Arguments
- ImportMesh import_mesh - Imported mesh for which a bound box is to be calculated.
Return value
true if a bound box for the specified mesh is successfully calculated; otherwise, false.bool preprocess ( ) #
Starts execution of all added pre-processors.Return value
true if the pre-processing is completed successfully.bool postprocess ( ) #
Starts execution of all added post-processors. Post-processors can be used to manage files generated in the process of import.Return value
true if the post-processing is completed successfully.bool getBasis ( int up_axis, int front_axis, dmat4 & ret ) #
Returns the transformation matrix for the basis specified by axes.Arguments
- int up_axis - Up axis of the basis.
- int front_axis - Front axis of the basis.
- dmat4 & ret - Transformation matrix for the basis specified by axes.
Return value
true the transformation matrix for the basis was successfully calculated; otherwise, false.bool onComputeBoundBox ( ImportMesh import_mesh ) #
Extendable method for custom bound box computation.Arguments
- ImportMesh import_mesh - Imported mesh for which a bound box is to be calculated.
Return value
true if a bound box for the specified mesh was successfully calculated; otherwise, false.bool onInit ( ImportScene import_scene, string filepath ) #
Builds and initializes the imported scene based on the data contained in the specified input file.Arguments
- ImportScene import_scene - Imported scene (built from the data contained in the specified input file).
- string filepath - Path to an input file to be imported.
Return value
true if the scene is successfully initialized using the data from the specified input file; otherwise, false.bool onImport ( string output_path ) #
Import event handler function. This function is called each time when the import() function is called. You can specify your custom actions to be performed on scene import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
bool onImport(const char *output_path) override;
/*...*/
};
/*...*/
bool MyCustomImporter::onImport(const char *output_path)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- string output_path - Output path to be used to store generated file(s) with imported data.
Return value
true if import operation for the specified output path was successful; otherwise, false.bool onImportTexture ( ImportProcessor processor, ImportTexture import_texture ) #
Texture import event handler function. This function is called each time when the importTexture() function is called. You can specify your custom actions to be performed on texture import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
bool onImportTexture(const ImportProcessorPtr &processor, const ImportTexturePtr &import_texture) override;
/*...*/
};
/*...*/
bool MyCustomImporter::onImportTexture(const ImportProcessorPtr &processor, const ImportTexturePtr &import_texture)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- ImportTexture import_texture - Instance of the ImportTexture class.
Return value
true if the specified texture was successfully imported; otherwise, false.bool onImportMaterial ( ImportProcessor processor, Material material, ImportMaterial import_material ) #
Material import event handler function. This function is called each time when the importMaterial() function is called. You can specify your custom actions to be performed on material import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
bool onImportMaterial(const ImportProcessorPtr &processor, const Unigine::MaterialPtr &material, const ImportMaterialPtr &import_material) override;
/*...*/
};
/*...*/
bool MyCustomImporter::onImportMaterial(const ImportProcessorPtr &processor, const Unigine::MaterialPtr &material, const ImportMaterialPtr &import_material)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- Material material - Target UNIGINE's material instance to store the specified imported material.
- ImportMaterial import_material - Instance of the ImportMaterial class.
Return value
true if the specified material was successfully imported; otherwise, false.Light onImportLight ( ImportProcessor processor, ImportLight import_light ) #
Light import event handler function. This function is called each time when the importLight() function is called. You can specify your custom actions to be performed on light import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
Unigine::LightPtr onImportLight(const ImportProcessorPtr &processor, const ImportLightPtr &import_light) override;
/*...*/
};
/*...*/
Unigine::LightPtr MyCustomImporter::onImportLight(const ImportProcessorPtr &processor, const ImportLightPtr &import_light)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- ImportLight import_light - Instance of the ImportLight class.
Return value
UNIGINE's light instance that stores the specified imported light.Player onImportCamera ( ImportProcessor processor, ImportCamera import_camera ) #
Camera import event handler function. This function is called each time when the importCamera() function is called. You can specify your custom actions to be performed on camera import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
Unigine::PlayerPtr onImportCamera(const ImportProcessorPtr &processor, const ImportCameraPtr &import_camera) override;
/*...*/
};
/*...*/
Unigine::PlayerPtr MyCustomImporter::onImportCamera(const ImportProcessorPtr &processor, const ImportCameraPtr &import_camera)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- ImportCamera import_camera - Instance of the ImportCamera class.
Return value
UNIGINE's player instance that stores the specified imported camera.bool onImportMesh ( ImportProcessor processor, Mesh mesh, ImportMesh import_mesh ) #
Mesh import event handler function. This function is called each time when the importMesh() function is called. You can specify your custom actions to be performed on mesh import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
bool onImportMesh(const ImportProcessorPtr &processor, const Unigine::MeshPtr &mesh, const ImportMeshPtr &import_mesh) override;
/*...*/
};
/*...*/
bool MyCustomImporter::onImportMesh(const ImportProcessorPtr &, const Unigine::MeshPtr &mesh, const ImportMeshPtr &import_mesh)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- Mesh mesh - Target UNIGINE's mesh instance to store the specified imported mesh animation.
- ImportMesh import_mesh - Instance of the ImportMesh class.
Return value
true if the specified mesh was successfully imported; otherwise, false.Node onImportNode ( ImportProcessor processor, ImportNode import_node ) #
Node import event handler function. This function is called each time when the importNode() function is called. You can specify your custom actions to be performed on node import.Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
Unigine::NodePtr onImportNode(const ImportProcessorPtr &processor, const ImportNodePtr &import_node) override;
/*...*/
};
/*...*/
Unigine::NodePtr MyCustomImporter::onImportNode(const ImportProcessorPtr &processor, const ImportNodePtr &import_node)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- ImportNode import_node - Instance of the ImportNode class.
Return value
UNIGINE's node instance that stores the specified imported node.bool onImportNodeChild ( ImportProcessor processor, Node node_parent, ImportNode import_node_parent, Node node_child, ImportNode import_node_child ) #
Node import event handler function. This function is called each time when the importNodeChild() function is called. You can specify your custom actions to be performed on importing and processing node hierarchies (e.g. assigning properties to node children).Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
MyCustomImporter();
virtual ~MyCustomImporter();
/*...*/
// overrides of event functions
protected:
bool onImportNodeChild(const ImportProcessorPtr &processor, const Unigine::NodePtr &node_parent, const ImportNodePtr &import_node_parent, const Unigine::NodePtr &node_child, const ImportNodePtr &import_node_child) override;
/*...*/
};
/*...*/
bool MyCustomImporter::onImportNodeChild(const ImportProcessorPtr &processor, const Unigine::NodePtr &node_parent, const ImportNodePtr &import_node_parent, const Unigine::NodePtr &node_child, const ImportNodePtr &import_node_child)
{
bool result = false;
// your custom actions
return result;
}
Arguments
- ImportProcessor processor - Import processor used for this import operation.
- Node node_parent - Target UNIGINE's node instance to store the specified imported parent node.
- ImportNode import_node_parent - Instance of the ImportNode class for the parent node.
- Node node_child - Target UNIGINE's node instance to store the specified imported child node.
- ImportNode import_node_child - Instance of the ImportNode class for the child node.
Return value
true if the specified parent node and its child node animation were successfully imported; otherwise, false.bool onImportAnimation ( ImportProcessor processor, Mesh animation, ImportAnimation import_animation ) #
Animation import event handler function. This function is called each time when the importAnimation() function is called. You can specify your custom actions to be performed on animation import.Arguments
- ImportProcessor processor - Import processor used for this import operation.
- Mesh animation - Target UNIGINE's mesh instance to store the specified imported mesh animation.
- ImportAnimation import_animation - ImportMesh structure pointer.The metadata for the animation that needs to be imported.
Return value
true if the specified mesh animation was successfully imported; otherwise, false.bool onImportAnimation ( ImportProcessor processor, Mesh animation, ImportMesh import_mesh, ImportAnimation import_animation ) #
Animation import event handler function. This function is called each time when the importAnimation() function is called. You can specify your custom actions to be performed on animation import.Arguments
- ImportProcessor processor - Import processor used for this import operation.
- Mesh animation - Target UNIGINE's mesh instance to store the specified imported mesh animation.
- ImportMesh import_mesh - ImportMesh structure pointer.The metadata for the mesh that needs to be imported.
- ImportAnimation import_animation - ImportMesh structure pointer.The metadata for the animation that needs to be imported.
Return value
true if the specified mesh animation was successfully imported; otherwise, false.Last update:
2022-12-14
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)