# juce/pes-model-tools architecture

> Architecture diagram of the GitHub repository juce/pes-model-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/juce/pes-model-tools
- Repository: https://github.com/juce/pes-model-tools

## Overview

This repository provides Blender tools for importing PES .model files, exporting trophy models for PES 2017, and a separate command-line utility for editing a model’s scale and translation matrix. The main workflow is to prepare a Blender scene and export a trophy model; the importer also supports reading models and exporting edits. The excerpts show format conversion and matrix editing, but not all operator wiring, so uncertain links are omitted.

Main entry points: [`pes_model_importer.py`](https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py) (Import controls), [`modmatrix.c`](https://github.com/juce/pes-model-tools/blob/master/modmatrix.c) (Edit transform matrix), [`pes_trophy_exporter.py`](https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py) (Export controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_blender_import["Model Importer"]
  node_import_ui["Import controls"]
  node_decode_model["Decode model"]
  node_build_mesh["Build scene mesh"]
  node_edit_export["Export edited model"]
end

subgraph group_trophy_export["Trophy Exporter"]
  node_trophy_ui["Export controls"]
  node_mesh_prepare["Prepare mesh data"]
  node_model_serialize["Write model data"]
  node_compress_model["Compress model"]
end

subgraph group_matrix_edit["Matrix Editor"]
  node_matrix_tool["Edit transform matrix<br/>[modmatrix.c]"]
end

node_user(("Artist"))
node_blender["Blender"]
node_pes_input["PES model file"]
node_pes_output["PES model file"]

node_user -->|"uses"| node_blender
node_blender -->|"opens controls"| node_import_ui
node_import_ui -->|"selects file"| node_pes_input
node_decode_model -->|"reads"| node_pes_input
node_decode_model -->|"creates geometry"| node_build_mesh
node_build_mesh -->|"adds scene mesh"| node_blender
node_import_ui -->|"dispatches export"| node_edit_export
node_edit_export -->|"reads model"| node_pes_input
node_edit_export -->|"writes model"| node_pes_output
node_blender -->|"opens controls"| node_trophy_ui
node_trophy_ui -->|"starts export"| node_mesh_prepare
node_mesh_prepare -->|"supplies mesh data"| node_model_serialize
node_model_serialize -->|"writes model"| node_compress_model
node_compress_model -->|"writes compressed file"| node_pes_output
node_user -->|"runs"| node_matrix_tool
node_matrix_tool -->|"reads and edits"| node_pes_input
node_matrix_tool -->|"writes changes"| node_pes_output

click node_import_ui "https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py"
click node_decode_model "https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py"
click node_build_mesh "https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py"
click node_edit_export "https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py"
click node_trophy_ui "https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py"
click node_mesh_prepare "https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py"
click node_model_serialize "https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py"
click node_compress_model "https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py"
click node_matrix_tool "https://github.com/juce/pes-model-tools/blob/master/modmatrix.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_import_ui,node_decode_model,node_build_mesh,node_edit_export toneBlue
class node_trophy_ui,node_mesh_prepare,node_model_serialize,node_compress_model toneAmber
class node_matrix_tool toneMint
class node_user,node_blender,node_pes_input,node_pes_output toneIndigo
```

## Components

### Model Importer

- [Import controls](https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py): `pes_model_importer.py`
- [Decode model](https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py): `pes_model_importer.py`
- [Build scene mesh](https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py): `pes_model_importer.py`
- [Export edited model](https://github.com/juce/pes-model-tools/blob/master/pes_model_importer.py): `pes_model_importer.py`

### Trophy Exporter

- [Export controls](https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py): `pes_trophy_exporter.py`
- [Prepare mesh data](https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py): `pes_trophy_exporter.py`
- [Write model data](https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py): `pes_trophy_exporter.py`
- [Compress model](https://github.com/juce/pes-model-tools/blob/master/pes_trophy_exporter.py): `pes_trophy_exporter.py`

### Matrix Editor

- [Edit transform matrix](https://github.com/juce/pes-model-tools/blob/master/modmatrix.c): `modmatrix.c`

### Other components

- **Artist**
- **Blender**
- **PES model file**
- **PES model file**

## Connections

- Artist → Blender: uses
- Blender → Import controls: opens controls
- Import controls → PES model file: selects file
- Decode model → PES model file: reads
- Decode model → Build scene mesh: creates geometry
- Build scene mesh → Blender: adds scene mesh
- Import controls → Export edited model: dispatches export
- Export edited model → PES model file: reads model
- Export edited model → PES model file: writes model
- Blender → Export controls: opens controls
- Export controls → Prepare mesh data: starts export
- Prepare mesh data → Write model data: supplies mesh data
- Write model data → Compress model: writes model
- Compress model → PES model file: writes compressed file
- Artist → Edit transform matrix: runs
- Edit transform matrix → PES model file: reads and edits
- Edit transform matrix → PES model file: writes changes
