文件系统
The Export System allows you to use default plugins and write custom ones to export UNIGINE's nodes to a file of different format and store it on a disk.导出系统允许您使用默认插件并编写自定义插件以将 UNIGINE 的节点导出到不同格式的文件并将其存储在磁盘上。
The structure of Export System is shown below. It includes Export Manager and a dynamic set of exporters for various external file formats.导出系统的结构如下图所示。它包括导出管理器和一组动态的出口商适用于各种外部文件格式。
Export Manager is used to create and manage exporters, as well as to directly export files to non-native formats, if an exporter for such files was previously registered.导出管理器用于创建和管理导出器,以及直接将文件导出为非本地格式(如果此类文件的导出器之前已注册)。
Exporter出口商#
Exporter is a module used by Export System to transfer UNIGINE's objects to files in various non-native formats. A single exporter can be used to export multiple nodes, but there shouldn't be two or more exporters registered for a single node type.Exporter 是导出系统用来将 UNIGINE 的对象传输到各种非本地格式的文件的模块。单个导出器可用于导出多个节点,但不应为单个节点类型注册两个或多个导出器。
Each exporter has a set of parameters that control the whole export process (e.g., whether to export lights, cameras, and material normal maps, reset root node transformation, etc.). The exporter should be initialized before the use.每个导出器都有一组参数来控制整个导出过程(例如,是否导出灯光、相机和材质法线贴图,重置根节点变换等)。使用前应初始化导出器。
Basic Workflow基本工作流程#
In order to be used, exporters must be registered in the system via Export Manager. You can manage the list of available modules dynamically by adding them to or removing from the registry. When you export a node to any external format, Export System automatically tries to find and use an appropriate exporter registered for the specified file extension.为了使用,出口商必须通过 Export Manager 在系统中注册。您可以通过将可用模块添加到注册表或从注册表中删除来动态管理可用模块的列表。当您将节点导出为任何外部格式时,导出系统会自动尝试查找并使用为指定文件扩展名注册的适当导出器。
The basic node export workflow is as follows:基本节点导出工作流程如下:
- Check the extension of the specified output file and find the appropriate exporter among the registered ones.检查指定输出文件的扩展名,并在已注册的导出器中找到合适的导出器。
- Extract scene data from the node, create the export scene and put the data to the corresponding export structures (e.g., FBX nodes).从节点中提取场景数据,创建导出场景并将数据放入相应的导出结构(例如,FBX 节点)。
- Use the appropriate exporter to generate output files on the basis of scene metadata.使用适当的导出器根据场景元数据生成输出文件。
Customization定制#
You can consider the FbxExporter plugin as an example to build your own custom exporting modules. You can also modify and rebuild this plugin to use your own custom exporter in the Editor.您可以将 FbxExporter 插件作为示例来构建您自己的自定义导出模块。您还可以修改和重建此插件以在编辑器中使用您自己的自定义导出器。
To use the FbxExporter plugin, just load it via the plugin_load console command or the following command line option on the application start-up:要使用 FbxExporter 插件,只需通过 plugin_load 控制台命令或以下命令加载它命令行选项在应用程序启动时:
-extern_plugin UnigineFbxExporter
In general, the workflow via the C++ API may be represented as follows:一般来说,通过 C++ API 的工作流可以表示如下:
// create an exporter for the exported file ("1.fbx" in our case)
Unigine::Exporter* exporter = Unigine::Export::get()->createExporterByFileName("1.fbx");
// enable the "export_material_normal_maps" parameter
exporter->setParameterInt("export_material_normal_maps", 1);
// initialize exporter
exporter->init();
// get the node
NodePtr node = World::getNodeByName("material_ball");
// export the node to the specified file path
exporter->doExport(node, "1.fbx");
// exporter deinitialization
exporter->deinit();
You can also export a node with default settings simply like this:您还可以像这样使用默认设置导出节点:
// get the node
NodePtr node = World::getNodeByName("material_ball");
// export the node to the file of specified format
Unigine::Export::get()->doExport(node, "../data/1/1.fbx")
Built-in Export Options内置导出选项#
The engine's built-in exporters (FbxExporter plugin, UsdExporter plugin) have a number of export options that customize the exporter's behavior and can also be used in custom exporters.引擎的内置导出器(FbxExporter 插件,UsdExporter 插件)有许多导出选项,可以自定义导出器的行为,也可以在自定义导出器中使用。
Parameter Names参数名称#
The following table lists the names for the parameters available out of the box that can be set via the setParameterInt("name", value) method. 下表列出了可通过 setParameterInt("name", value) 方法设置的现成可用参数的名称。
See Also也可以看看#
- FbxExporter 插件作为自定义导出插件的示例:source/plugins/Export/FbxExporter。
- UsdExporter pluginUsdExporter 插件
Fbx 导出系统 API:
导出功能类有关通过代码管理导出系统的更多详细信息。
导出系统 API 不适用于 Community SDK 版本。