-
Notifications
You must be signed in to change notification settings - Fork 0
Import
The addon would not be complete without a way to bring already existing model configurations into Blender. The import function serves this purpose.
While the addon contains versatile nodes that allow for a wide variety of setups, due to the nature of the written model.cfg syntax, and the own inner workings of Blender, there are limitations to the importer functionality.
- CfgConvert.exe is required from the official Arma 3 Tools for preprocessing of the config
- the model config must be syntactically correct and without errors
- preprocessor macros cannot be preserved, they get applied by the CfgConvert.exe
- the import process can take a long time and temporarily freeze up Blender with larger config files
- only simple mathematical expressions are supported for floating point values

Due to the Blender API, the real bottleneck is not the processing of the config or the creation of the nodes, but the creation of links between the nodes. For this reason, a setting is present to limit the created links if need be, as limiting the number of links speeds up the process significantly. If not all links are created, the connections need to be reconstructed by hand, and inheritance settings may break.
- None: none of the links are created (fastest, but most inaccurate)
- Only essentials: parenting links, unique value links (sections, inherit bones etc.) are created, but links to list type nodes are omitted
- All: all links are created (slowest, but most accurate)
There may be scenarios when not all data is needed from the config to be imported.
- Only skeletons: only the skeletons are imported
- Skeletons and models: skeletons and models are imported too, but animations are ignored
- All: all data is imported
In order to spare the need for an entirely custom syntax parser, the addon makes use of the Arma 3 Tools, as well as the built-in modules of Blender.
- File browser window pops up to select file to import
- Import options are saved
- The CfgConvert.exe is called to convert the model.cfg to .xml format and saved to the active temporary folder
- XML format file is read and parsed to an ElementTree object
- ElementTree is translated to a custom class structure to support easier processing
- Class structure is processed and nodes are created
- Class nodes are created
- Relevant connecting nodes are created
- Links are created according to the options
- Node values are set

A note is created to indicate that the node tree is an imported setup, and also marks the path to the original file

To make debugging easier, some measure of logging is present in the importer functions.