This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine.Importer Class

Warning
The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Engineering / Sim SDK edition to use it.

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 has a set of flags defining which scene components are to be extracted and imported. So, the importer should be initialized before use.

Each importer generates UNIGINE objects on the basis of metadata extracted from the imported files and uses a set of processors to perform all necessary auxiliary operations (data preparation, file saving, file management, etc.). Importer allows you to add any number of pre- and post-processors. However, you can set only one processor for each scene component.

Notice
This is a base class for all importers. Your custom importer class must be inherited from it.

You can customize actions to be performed when importing the whole scene as well as when importing textures, materials, meshes, animations, lights, cameras by overriding the corresponding event handler functions for your custom importer

Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
	MyCustomImporter();
	virtual ~MyCustomImporter();

/*...*/

// overrides of event functions
protected:
	virtual bool onInit(const ImportScenePtr &scene, const char *filepath) override;
	virtual bool onImport(const char *output_path) override;
	virtual bool onImportTexture(const Unigine::ImportProcessor &processor, const Unigine::ImportTexturePtr &import_texture) override;
	virtual bool onImportMaterial(const Unigine::ImportProcessor &processor, const Unigine::MaterialPtr &material, const Unigine::ImportMaterial &import_material) override;
	virtual bool onImportMesh(const Unigine::ImportProcessor &processor, const Unigine::MeshPtr &mesh, const Unigine::ImportMesh &import_mesh) override;
	virtual bool onImportLight(const Unigine::ImportProcessor &processor, const Unigine::LightPtr &light, const Unigine::ImportLight &import_light) override;
	virtual bool onImportCamera(const Unigine::ImportProcessor &processor, const Unigine::PlayerPtr &camera, const Unigine::ImportCamera &import_camera);
	virtual bool onImportNode(const Unigine::ImportProcessor &processor, const Unigine::NodePtr &node, const Unigine::ImportNode &import_node) override;
	virtual 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;
	virtual bool onImportAnimation(const Unigine::ImportProcessor &processor, const Unigine::MeshPtr &animation, const Unigine::ImportMesh &import_mesh, const Unigine::ImportAnimation &import_animation) override;

private:
	ImportScene *import_scene();
	void import_textures(const Unigine::ImportScene &scene);
	void import_materials(const Unigine::ImportScene &scene);
	void import_animations(const Unigine::ImportScene &scene);

	void process_node(const Unigine::ImportScene &import_scene, const Unigine::ImportNode &parent, fbx::FbxNode *fbx_node);
	void process_mesh(const Unigine::ImportScene &import_scene, const Unigine::ImportNode &node, fbx::FbxNode *fbx_node, fbx::FbxMesh *fbx_mesh);
	void process_light(const Unigine::ImportScene &import_scene, const Unigine::ImportNode &node, fbx::FbxNode *fbx_node, fbx::FbxLight *fbx_light);
	void process_camera(const Unigine::ImportScene &import_scene, const Unigine::ImportNode &node, fbx::FbxNode *fbx_node, fbx::FbxCamera *fbx_camera);

/*...*/

};

Importer Class

Enums

Axis#

Axis.
NameDescription
None = -1Axis none.
X = None + 1X axis.
NX = X + 1Negative X axis.
Y = NX + 1Y axis.
NY = Y + 1Negative Y axis.
Z = NY + 1Z axis.
NZ = Z + 1Negative Z axis.

Properties

string AnimationsProcessor#

The import processor to be used for importing animations.

string LightsProcessor#

The import processor to be used for importing light sources.

string MeshesProcessor#

The import processor to be used for importing meshes.

string NodesProcessor#

The import processor to be used for importing nodes.

string CamerasProcessor#

The import processor to be used for importing cameras.

string MaterialsProcessor#

The import processor to be used for importing materials.

string OutputFilepath#

The 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.

string TexturesProcessor#

The import processor to be used for importing textures.

Members


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.

Node ConvertNode ( ImportProcessor processor, ImportNode root_node ) #

Converts metadata stored in an instance of the ImportNode class to UNIGINE's node (node hierarchy).

Arguments

Return value

Resulting UNIGINE's node instance that stores the specified imported node (node hierarchy).

bool ImportTexture ( ImportProcessor processor, ImportTexture import_texture ) #

Imports the specified texture and uses the specified processor to process and save the generated texture to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing textures, when implementing a custom importer, you can override the OnImportTexture() method.

Arguments

Return value

true if the specified texture was successfully imported; otherwise, false.

bool ImportMaterial ( ImportProcessor processor, Material material, ImportMaterial import_material ) #

Imports the specified material and uses the specified processor to process and save the generated material to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing materials, when implementing a custom importer, you can override the OnImportMaterial() method.

Arguments

Return value

true if the specified material was successfully imported; otherwise, false.

bool ImportMesh ( ImportProcessor processor, Mesh mesh, ImportMesh import_mesh ) #

Imports the specified mesh and uses the specified processor to process and save the generated mesh to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing meshes, when implementing a custom importer, you can override the OnImportMesh() method.

Arguments

Return value

true if the specified mesh was successfully imported; otherwise, false.

Light ImportLight ( ImportProcessor processor, ImportLight import_light ) #

Imports the specified light and uses the specified processor to process and save the generated light to a corresponding *.node file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing lights, when implementing a custom importer, you can override the OnImportLight() method.

Arguments

Return value

UNIGINE's light instance that stores the specified imported light source.

Player ImportCamera ( ImportProcessor processor, ImportCamera import_camera ) #

Imports the specified camera and uses the specified processor to process and save the generated player to a corresponding *.node file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing cameras, when implementing a custom importer, you can override the OnImportCamera() method.

Arguments

Return value

UNIGINE's player instance that stores the specified imported camera.

bool ImportAnimation ( ImportProcessor processor, Mesh animation, ImportAnimation import_animation ) #

Imports the specified mesh animation and uses the specified processor to process and save the generated mesh animation to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing mesh animations, when implementing a custom importer, you can override the OnImportAnimation() method.

Arguments

Return value

true if the specified animation was successfully imported; otherwise, false.

bool ImportAnimation ( ImportProcessor processor, Mesh animation, ImportMesh import_mesh, ImportAnimation import_animation ) #

Imports the specified mesh animation and uses the specified processor to process and save the generated mesh animation to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing mesh animations, when implementing a custom importer, you can override the OnImportAnimation() method.

Arguments

Return value

true if the specified animation was successfully imported; otherwise, false.

Node ImportNode ( ImportProcessor processor, ImportNode import_node ) #

Imports the specified node and uses the specified processor to process and save the generated node to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing nodes, when implementing a custom importer, you can override the OnImportNode() method.

Arguments

Return value

Target UNIGINE's node instance to store the specified imported node.

bool ImportNodeChild ( ImportProcessor processor, Node node_parent, ImportNode import_node_parent, Node node_child, ImportNode import_node_child ) #

Imports the specified parent node with the specified child node and uses the specified processor to process and save generated nodes to a corresponding file in the output directory specified in the Import() method.
Notice
To customize actions to be performed on importing nodes, when implementing a custom importer, you can override the OnImportNodeChild() method.

Arguments

Return value

true if the specified parent node along with the specified child node were successfully imported; otherwise, false.

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 ( Importer.Axis up_axis, Importer.Axis front_axis, out dmat4 ret ) #

Returns the transformation matrix for the basis specified by axes.

Arguments

  • Importer.Axis up_axis - Up axis of the basis.
  • Importer.Axis front_axis - Front axis of the basis.
  • out 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

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

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

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

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

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

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

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

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

Return value

true if the specified mesh animation was successfully imported; otherwise, false.
Last update: 2024-03-04
Build: ()