This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Программирование
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Importer Class

Header:#include <UnigineImport.h>

Notice
Import System API is not available for Entertainment SDK edition.

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

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

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

/*...*/

};

Importer Class

Members


static ImporterPtr create()

Constructor. Creates an importer with default settings.

ImportScene * getScene()

Returns the imported scene.

Return value

ImportScene instance.

int containsParameter(const char * name)

Returns a value indicating whether the list of import parameters includes a parameter with a given name.

Arguments

  • const char * name - Parameter name.

Return value

1 if the list of import parameters includes a parameter with a given name; otherwise, 0.

void setParameterInt(const char * name, int v)

Sets a new value for the specified integer parameter.

Arguments

  • const char * name - Name of the integer parameter.
  • int v - New value to be set.

int getParameterInt(const char * name)

Returns the current value of the specified integer parameter.

Arguments

  • const char * name - Name of the integer parameter.

Return value

Value of the integer parameter.

void setParameterFloat(const char * name, float v)

Sets a new value for the specified float parameter.

Arguments

  • const char * name - Name of the float parameter.
  • float v - New value to be set.

float getParameterFloat(const char * name)

Returns the current value of the specified float parameter.

Arguments

  • const char * name - Name of the float parameter.

Return value

Value of the float parameter.

void setParameterDouble(const char * name, double v)

Sets a new value for the specified double parameter.

Arguments

  • const char * name - Name of the double parameter.
  • double v - New value to be set.

double getParameterDouble(const char * name)

Returns the current value of the specified double parameter.

Arguments

  • const char * name - Name of the double parameter.

Return value

Value of the double parameter.

void setParameterString(const char * name, const char * v)

Sets a new value for the specified string parameter.

Arguments

  • const char * name - Name of the string parameter.
  • const char * v - New value to be set.

const char * getParameterString(const char * name)

Returns the current value of the specified string parameter.

Arguments

  • const char * name - Name of the string parameter.

Return value

Value of the string parameter.

int addPreProcessor(const char * type_name)

Adds an import pre-processor with a given name.

Arguments

  • const char * type_name - Pre-processor name.

Return value

1 if the specified import pre-processor is successfully added; otherwise, 0.

void removePreProcessor(const char * type_name)

Removes an import pre-processor with a given name.

Arguments

  • const char * type_name - Pre-processor name.

int addPostProcessor(const char * type_name)

Adds an import post-processor with a given name.

Arguments

  • const char * type_name - Post-processor name.

Return value

1 if the specified import post-processor is successfully added; otherwise, 0.

void removePostProcessor(const char * type_name)

Removes an import post-processor with a given name.

Arguments

  • const char * type_name - Post-processor name.

void setAnimationsProcessor(const char * type_name)

Sets the specified processor to be used for importing animations.

Arguments

  • const char * type_name - Name of the animations processor to be set.

void setCamerasProcessor(const char * type_name)

Sets the specified processor to be used for importing cameras.

Arguments

  • const char * type_name - Name of the cameras processor to be set.

void setLightsProcessor(const char * type_name)

Sets the specified processor to be used for importing lights.

Arguments

  • const char * type_name - Name of the lights processor to be set.

void setMaterialsProcessor(const char * type_name)

Sets the specified processor to be used for importing materials.

Arguments

  • const char * type_name - Name of the materials processor to be set.

void setMeshesProcessor(const char * type_name)

Sets the specified processor to be used for importing meshes.

Arguments

  • const char * type_name - Name of the meshes processor to be set.

void setNodesProcessor(const char * type_name)

Sets the specified processor to be used for importing nodes.

Arguments

  • const char * type_name - Name of the nodes processor to be set.

void setTexturesProcessor(const char * type_name)

Sets the specified processor to be used for importing textures.

Arguments

  • const char * type_name - Name of the textures processor to be set.

int init(const char * filepath, int flags)

Initializes the importer for the specified file using the given flags. Import flags specify which scene components are to be imported.

Arguments

  • const char * 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

1 if the importer was initialized successfully; otherwise, 0.

int import(const char * output_path)

Imports the contents of the input file to the specified output path.

Arguments

  • const char * output_path - Output path.

Return value

1 if the contents of the input file are successfully imported to the specified output path; otherwise, 0.

const char * getOutputFilepath()

Returns the 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.

Return value

Output file path.

bool preprocess()

Starts execution of all added pre-processors.

Return value

true if the pre-processing is completed successfully.

bool importAnimation(ImportProcessor * processor, MeshPtr & 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 mesh animation was successfully imported; otherwise, false.

bool importCamera(ImportProcessor * processor, PlayerPtr & camera, 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

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

bool importLight(ImportProcessor * processor, LightPtr & light, 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

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

bool importMaterial(ImportProcessor * processor, MaterialPtr & 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, MeshPtr & 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.

bool importNode(ImportProcessor * processor, NodePtr & node, 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

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

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

ImportScene * onInit(const String & filepath)

Arguments

  • const String & filepath - Path to a file to be imported.

Return value

Scene contained in the specified input file.

bool onImport(const char * 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:
	virtual bool onImport(const char *output_path) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImport(const char *output_path)
{
	bool result = false;

	// your custom actions

	return result;
}

Arguments

  • const char * 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 successfull; otherwise, false.

bool onImportAnimation(ImportProcessor * processor, MeshPtr & 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.
Source code (C++)
class MyCustomImporter : public Unigine::Importer
{
public:
	MyCustomImporter();
	virtual ~MyCustomImporter();

/*...*/

// overrides of event functions
protected:
	virtual bool onImportAnimation(ImportProcessor *processor, MeshPtr &animation, ImportMesh *import_mesh, ImportAnimation *import_animation) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportAnimation(ImportProcessor *processor, MeshPtr &animation, ImportMesh *import_mesh, ImportAnimation *import_animation)
{
	bool result = false;
	
	// your custom actions
	
	return result;
}

Arguments

Return value

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

bool onImportCamera(ImportProcessor * processor, PlayerPtr & camera, 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:
	virtual bool onImportCamera(ImportProcessor *processor, Unigine::PlayerPtr &camera, ImportCamera *import_camera) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportCamera(ImportProcessor *processor, Unigine::PlayerPtr &camera, ImportCamera *import_camera)
{
	bool result = false;

	// your custom actions

	return result;
}

Arguments

Return value

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

bool onImportLight(ImportProcessor * processor, LightPtr & light, 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:
	virtual bool onImportLight(ImportProcessor *processor, Unigine::LightPtr &light, ImportLight *import_light) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportLight(ImportProcessor *processor, Unigine::LightPtr &light, ImportLight *import_light)
{
	bool result = false;

	// your custom actions

	return result;
}

Arguments

Return value

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

bool onImportMaterial(ImportProcessor * processor, MaterialPtr & 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:
	virtual bool onImportMaterial(ImportProcessor *processor, Unigine::MaterialPtr &material, ImportMaterial *import_material) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportMaterial(ImportProcessor *processor, Unigine::MaterialPtr &material, ImportMaterial *import_material)
{
	bool result = false;
	
	// your custom actions
	
	return result;
}

Arguments

Return value

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

bool onImportMesh(ImportProcessor * processor, MeshPtr & 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:
	virtual bool onImportMesh(ImportProcessor *processor, Unigine::MeshPtr &mesh, ImportMesh *import_mesh) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportMesh(ImportProcessor *processor, Unigine::MeshPtr &mesh, ImportMesh *import_mesh)
{
	bool result = false;
	
	// your custom actions
	
	return result;
}

Arguments

Return value

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

bool onImportNode(ImportProcessor * processor, NodePtr & node, 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:
	virtual bool onImportNode(ImportProcessor *processor, Unigine::NodePtr &node, ImportNode *import_node) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportNode(ImportProcessor *processor, Unigine::NodePtr &node, ImportNode *import_node)
{
	bool result = false;
	
	// your custom actions
	
	return result;
}

Arguments

Return value

true if the specified node was successfully imported; 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:
	virtual bool onImportTexture(ImportProcessor *processor, ImportTexture *import_texture) override;

/*...*/

};

/*...*/

bool MyCustomImporter::onImportTexture(ImportProcessor *processor, ImportTexture *import_texture)
{
	bool result = false;
	
	// your custom actions
	
	return result;
}

Arguments

Return value

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

int IMPORT_LIGHTS

Description

Flag indicating that lights are to be imported.

int IMPORT_CAMERAS

Description

Flag indicating that cameras are to be imported.

int IMPORT_MESHES

Description

Flag indicating that meshes are to be imported.

int IMPORT_ANIMATIONS

Description

Flag indicating that animations are to be imported.

int IMPORT_TEXTURES

Description

Flag indicating that textures are to be imported.

int IMPORT_MATERIALS

Description

Flag indicating that materials are to be imported.

int IMPORT_JOINTS

Description

Flag indicating that joints (bones) for animated FBX assets are to be imported.
Last update: 04.06.2018
Build: ()