Unigine.Importer Class
You should upgrade to
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.
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
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
int 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
1 if the list of import parameters includes a parameter with a given name; otherwise, 0.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.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.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
const char * 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.int AddPreProcessor ( String type_name ) #
Adds an import pre-processor with a given name. There are built-in pre-processors that can also be added to custom importers.Arguments
- String type_name - Pre-processor name.
Return value
1 if the specified import pre-processor is successfully added; otherwise, 0.void RemovePreProcessor ( String type_name ) #
Removes an import pre-processor with a given name. There are built-in pre-processors that can also be added to custom importers.Arguments
- String type_name - Pre-processor name.
int AddPostProcessor ( String type_name ) #
Adds an import post-processor with a given name. There are built-in post-processors that can also be added to custom importers.Arguments
- String type_name - Post-processor name.
Return value
1 if the specified import post-processor is successfully added; otherwise, 0.void RemovePostProcessor ( String type_name ) #
Removes an import post-processor with a given name. There are built-in post-processors that can also be added to custom importers.Arguments
- String type_name - Post-processor name.
int Init ( int flags ) #
Initializes the importer for the specified file using the given flags. Import flags specify which scene components are to be imported.Arguments
- 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 ( String output_path ) #
Imports the contents of the input file to the specified output path.Arguments
- String output_path - Output path.