# boshinomikoto/mdlviewer architecture

> Architecture diagram of the GitHub repository boshinomikoto/mdlviewer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boshinomikoto/mdlviewer
- Repository: https://github.com/boshinomikoto/mdlviewer

## Overview

ModelsViewer is a Urho3D desktop model viewer. Users choose an MDL model and optional XML material, load it into a 3D scene, then adjust object transforms and material color through the UI while navigating with the camera controls. The sampled code shows startup assembling the UI and scene, and the load handler calling the model loader; several UI-to-handler and renderer relationships are documented or implied but not fully shown. Native file dialogs are supplied by the bundled cross-platform NFD library.

Main entry points: [`src/Core.cpp`](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Core.cpp) (App startup), [`src/Handlers.cpp`](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp) (UI and input handlers), [`src/Scene.cpp`](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Scene.cpp) (Scene and lighting), [`external/nfd/src/include/nfd.h`](https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/include/nfd.h) (Dialog API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["Application entry<br/>[main.cpp]"]
  node_startup["App startup<br/>[Core.cpp]"]
  node_viewport["Scene viewport<br/>[Core.cpp]"]
end

subgraph group_interaction["User Interaction"]
  node_ui["Viewer UI<br/>[UI.cpp]"]
  node_handlers["UI and input handlers<br/>[Handlers.cpp]"]
  node_camera["Camera controls<br/>[Handlers.cpp]"]
  node_transform["Object transforms and color<br/>[Handlers.cpp]"]
end

subgraph group_scene["Scene and Assets"]
  node_scene_setup["Scene and lighting<br/>[Scene.cpp]"]
  node_model_loader["Model and material loader<br/>[Utils.cpp]"]
  node_assets["Model and material files"]
end

subgraph group_dialogs["Native File Dialogs"]
  node_dialog_api["Dialog API<br/>[nfd.h]"]
  node_dialog_windows["Windows dialog backend<br/>[nfd_win.cpp]"]
  node_dialog_gtk["GTK dialog backend<br/>[nfd_gtk.cpp]"]
  node_dialog_portal["Portal dialog backend<br/>[nfd_portal.cpp]"]
end

node_user(("Viewer user"))
node_engine["Urho3D runtime"]

node_user -->|"operates"| node_ui
node_entry -.->|"starts"| node_startup
node_startup -->|"initializes"| node_ui
node_startup -->|"creates"| node_scene_setup
node_startup -->|"sets up"| node_viewport
node_viewport -->|"renders"| node_scene_setup
node_ui -.->|"dispatches events"| node_handlers
node_handlers -->|"opens dialogs"| node_dialog_api
node_handlers -->|"loads model"| node_model_loader
node_handlers -->|"handles navigation"| node_camera
node_handlers -.->|"handles edits"| node_transform
node_scene_setup -->|"loads default model"| node_model_loader
node_model_loader -->|"reads resources"| node_assets
node_startup -->|"uses"| node_engine
node_scene_setup -->|"builds scene"| node_engine
node_dialog_windows -->|"implements"| node_dialog_api
node_dialog_gtk -->|"implements"| node_dialog_api
node_dialog_portal -->|"implements"| node_dialog_api

click node_entry "https://github.com/boshinomikoto/mdlviewer/blob/main/main.cpp"
click node_startup "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Core.cpp"
click node_ui "https://github.com/boshinomikoto/mdlviewer/blob/main/src/UI.cpp"
click node_handlers "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp"
click node_camera "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp"
click node_transform "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp"
click node_dialog_api "https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/include/nfd.h"
click node_dialog_windows "https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/nfd_win.cpp"
click node_dialog_gtk "https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/nfd_gtk.cpp"
click node_dialog_portal "https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/nfd_portal.cpp"
click node_scene_setup "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Scene.cpp"
click node_model_loader "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Utils.cpp"
click node_assets "https://github.com/boshinomikoto/mdlviewer/tree/main/Data/Materials"
click node_viewport "https://github.com/boshinomikoto/mdlviewer/blob/main/src/Core.cpp"

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_entry,node_startup,node_viewport,node_user toneBlue
class node_ui,node_handlers,node_camera,node_transform toneAmber
class node_scene_setup,node_model_loader,node_assets toneMint
class node_dialog_api,node_dialog_windows,node_dialog_gtk,node_dialog_portal toneRose
class node_engine toneIndigo
```

## Components

### Application

- [Application entry](https://github.com/boshinomikoto/mdlviewer/blob/main/main.cpp): `main.cpp`
- [App startup](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Core.cpp): `src/Core.cpp`
- [Scene viewport](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Core.cpp): `src/Core.cpp`

### User Interaction

- [Viewer UI](https://github.com/boshinomikoto/mdlviewer/blob/main/src/UI.cpp): `src/UI.cpp`
- [UI and input handlers](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp): `src/Handlers.cpp`
- [Camera controls](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp): `src/Handlers.cpp`
- [Object transforms and color](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Handlers.cpp): `src/Handlers.cpp`

### Scene and Assets

- [Scene and lighting](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Scene.cpp): `src/Scene.cpp`
- [Model and material loader](https://github.com/boshinomikoto/mdlviewer/blob/main/src/Utils.cpp): `src/Utils.cpp`
- [Model and material files](https://github.com/boshinomikoto/mdlviewer/tree/main/Data/Materials): `Data/Materials`

### Native File Dialogs

- [Dialog API](https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/include/nfd.h): `external/nfd/src/include/nfd.h`
- [Windows dialog backend](https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/nfd_win.cpp): `external/nfd/src/nfd_win.cpp`
- [GTK dialog backend](https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/nfd_gtk.cpp): `external/nfd/src/nfd_gtk.cpp`
- [Portal dialog backend](https://github.com/boshinomikoto/mdlviewer/blob/main/external/nfd/src/nfd_portal.cpp): `external/nfd/src/nfd_portal.cpp`

### Other components

- **Viewer user**
- **Urho3D runtime**

## Connections

- Viewer user → Viewer UI: operates (evidence: `README.md`)
- Application entry → App startup: starts
- App startup → Viewer UI: initializes (evidence: `src/Core.cpp`)
- App startup → Scene and lighting: creates (evidence: `src/Core.cpp`)
- App startup → Scene viewport: sets up (evidence: `src/Core.cpp`)
- Scene viewport → Scene and lighting: renders (evidence: `src/Core.cpp`)
- Viewer UI → UI and input handlers: dispatches events
- UI and input handlers → Dialog API: opens dialogs (evidence: `src/Handlers.cpp`)
- UI and input handlers → Model and material loader: loads model (evidence: `src/Handlers.cpp`)
- UI and input handlers → Camera controls: handles navigation (evidence: `src/Handlers.cpp`)
- UI and input handlers → Object transforms and color: handles edits (evidence: `src/Handlers.cpp`)
- Scene and lighting → Model and material loader: loads default model (evidence: `src/Scene.cpp`)
- Model and material loader → Model and material files: reads resources (evidence: `src/Utils.cpp`)
- App startup → Urho3D runtime: uses (evidence: `src/Core.cpp`)
- Scene and lighting → Urho3D runtime: builds scene (evidence: `src/Scene.cpp`)
- Windows dialog backend → Dialog API: implements (evidence: `external/nfd/src/nfd_win.cpp`)
- GTK dialog backend → Dialog API: implements (evidence: `external/nfd/src/nfd_gtk.cpp`)
- Portal dialog backend → Dialog API: implements (evidence: `external/nfd/src/nfd_portal.cpp`)
