Asset Viewer Application
Relevant source files
The following files were used as context for generating this wiki page:
The Asset Viewer Application is an independent utility for exploring original Redguard (1998) assets. It opens every game file format, including models, worlds, textures, fonts, animations, scripts, and audio. The application reads the player's local game installation without modifying original data.
Sources: [crates/cyrus-viewer/README.md:1-5](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/README.md#L1-L5), [README.md:94-98](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/README.md#L94-L98), [dev/pages/index.html:104-106](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/dev/pages/index.html#L104-L106)
Architecture and Platform Support
The application supports both native and browser targets. It uses the Bevy engine for rendering and the egui library for the user interface.
Native Target
The native version runs on Windows, macOS, and Linux. It uses the clap crate to handle command-line arguments for install location and asset selection.
Sources: [crates/cyrus-viewer/src/main.rs:1-35](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/main.rs#L1-L35), [crates/cyrus-viewer/README.md:17-25](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/README.md#L17-L25)
Browser Target (WASM)
The browser version executes as a WebAssembly (WASM) module. It handles asset decoding in a background BrowserWorker to maintain UI responsiveness. It utilizes a cache:// asset source for in-memory files generated during runtime.
Sources: [crates/cyrus-viewer/src/main.rs:43-50](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/main.rs#L43-L50), [crates/cyrus-viewer/src/browser.rs:20-30](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/browser.rs#L20-L30), [crates/cyrus-viewer/src/browser.rs:163-174](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/browser.rs#L163-L174)
Component Interaction
The following diagram illustrates the high-level startup flow for both targets.
The application initializes differently based on the platform but shares the same core Bevy plugin structure.
Sources: [crates/cyrus-viewer/src/main.rs:52-111](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/main.rs#L52-L111)
Core Data Structures
The Viewer resource maintains the global state of the application. It tracks user selection, search queries, and active preview data.
| Field | Type | Description |
|---|---|---|
catalog | Option<Catalog> | The complete list of available game assets. |
selected | Option<usize> | Index of the currently highlighted asset. |
preview | Option<Preview> | The decoded content and metadata of the selection. |
camera_mode | CameraMode | Switch between Orbit and Flycam. |
shading | Shading | Render modes: Textured, Unlit, Solid, Wireframe. |
palette | ImagePalette | The palette used for indexed image rendering. |
Sources: [crates/cyrus-viewer/src/ui.rs:50-98](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L50-L98)
User Interface Layout
The interface comprises four primary functional areas defined in ui.rs.
Navigation Panels
- Categories Panel: Lists asset types like 3DC (Models), RGM (Worlds), or WAV (Audio).
- Entries Panel: Displays searchable assets within the selected category or archive.
- Details Panel: Shows source metadata, file size, and links to related assets.
Sources: [crates/cyrus-viewer/src/ui.rs:280-450](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L280-L450)
Central Preview Panel
The central panel renders the asset based on its Content type. It supports diverse visualizations:
- 3D Models: Renders geometry with animation controls and frame selection.
- Images/Fonts: Displays textures with zoom, fit, and palette controls.
- Audio/Movies: Provides playback transport for sound and Smacker video.
- Spatial Data: Visualizes PVO octree cells and visibility data.
Sources: [crates/cyrus-viewer/src/ui.rs:523-568](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L523-L568), [crates/cyrus-viewer/src/ui.rs:728-750](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L728-L750)
Asset Loading Workflow
Asset loading occurs asynchronously when a user selects an entry.
The loading system switches between native file access and browser worker messages to retrieve decoded asset previews.
Sources: [crates/cyrus-viewer/src/ui.rs:569-585](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L569-L585), [crates/cyrus-viewer/src/browser.rs:218-230](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/browser.rs#L218-L230)
Inspection Features
The viewer includes specialized modules for technical analysis of Redguard data.
- Mesh Inspection: Supports UV layout visualization and face picking.
- World/Terrain Inspection: Inspects map placements, heightmaps, and materials.
- Spatial (PVO) Inspection: Visualizes the visibility octree using wireframe boxes or 2D slices.
- JSON Data View: Exposes the raw decoded records without binary payloads.
Sources: [crates/cyrus-viewer/src/ui.rs:809-900](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L809-L900), [crates/cyrus-viewer/src/ui.rs:945-980](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/src/ui.rs#L945-L980), [crates/cyrus-viewer/README.md:46-52](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/README.md#L46-L52)
Summary
The Asset Viewer Application provides a cross-platform environment for Redguard technical research. It leverages the preservation work of the rgpre crate to present original formats in a modern rendering context. By separating the viewer from the core game engine, the project allows for detailed asset inspection without the overhead of game logic.
Sources: [crates/cyrus-viewer/README.md:1-10](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/crates/cyrus-viewer/README.md#L1-L10), [AGENTS.md:10-20](https://github.com/michidk/cyrus/blob/0105d8ea914aee3bfcd1254113406fd23c770422/AGENTS.md#L10-L20)