4.4 KiB
Developer Guide: Architecture
This document provides a high-level overview of the Asset Processor Tool's architecture and core components for developers.
High-Level Architecture
The Asset Processor Tool is designed to process 3D asset source files into a standardized library format. Its high-level architecture consists of:
- Core Processing Engine (
AssetProcessor): The central component responsible for orchestrating the asset processing pipeline for a single input asset. - Configuration System (
Configuration): Handles loading core settings and merging them with supplier-specific rules defined in JSON presets. - Multiple Interfaces: Provides different ways to interact with the tool:
- Graphical User Interface (GUI)
- Command-Line Interface (CLI)
- Directory Monitor for automated processing. These interfaces exchange data structures containing information about each file and asset set being processed.
- Optional Integration: Includes scripts and logic for integrating with external software, specifically Blender, to automate material and node group creation.
Core Components
config.py: Defines core, global settings and constants.Presets/*.json: Supplier-specific JSON files defining rules for file interpretation and processing.configuration.py(Configurationclass): Loadsconfig.pysettings and merges them with a selected preset, pre-compiling regex patterns for efficiency.asset_processor.py(AssetProcessorclass): Contains the core logic for processing a single asset through the defined pipeline steps. This component works with data structures containing detailed information about the asset and its files.main.py: The entry point for the Command-Line Interface (CLI). It handles argument parsing, logging, parallel processing orchestration, and triggering Blender scripts. It orchestrates the processing of multiple assets by interacting with theAssetProcessorfor individual assets and manages the overall CLI execution flow.gui/: Directory containing modules for the Graphical User Interface (GUI), built with PySide6. The GUI interacts with the core processing logic indirectly via dedicated handler classes (ProcessingHandler,PredictionHandler) running in separate threads. Data structures, such as input paths, configuration details, processing progress updates, and file prediction results, are passed between the GUI, these handlers, and theAssetProcessorusing thread-safe mechanisms like Qt signals and slots.monitor.py: Implements the directory monitoring feature usingwatchdog.blenderscripts/: Contains Python scripts designed to be executed within Blender for post-processing tasks.
Processing Pipeline (Simplified)
The core processing engine (AssetProcessor) executes a series of steps for each asset:
- Extraction of input to a temporary workspace.
- Classification of files (map, model, extra, ignored, unrecognised) using preset rules.
- Determination of base metadata (asset name, category, archetype).
- Skip check if output exists and overwrite is not forced.
- Processing of maps (resize, format/bit depth conversion, inversion, stats calculation).
- Merging of channels based on rules.
- Generation of
metadata.jsonfile. - Organization of processed files into the final output structure.
- Cleanup of the temporary workspace.
- (Optional) Execution of Blender scripts for post-processing.
This architecture allows for a modular design, separating configuration, core processing logic, and different interfaces. The data structures flowing through this pipeline carry detailed information about individual files and asset sets. Examples include lists of input file paths, configuration objects, dictionaries summarizing processing outcomes, and detailed lists of file predictions. Parallel processing is utilized for efficiency, and background threads keep the GUI responsive.
Note on Data Passing: Major changes to the data passing mechanisms between the GUI, Main (CLI orchestration), and AssetProcessor modules are currently being planned. These changes are expected to involve new data structures and updated interaction patterns to convey detailed specifications for datasets/asset-sets and processing instructions for individual files. The documentation in this section, particularly regarding data flow, will require significant review and updates once the plan for these changes is finalized.