Assets Manager

The Gorilla3D Assets Manager provides centralized media management through asset packages. Models, textures, audio, video, dialogues, inventories, scripts, prefabs, and skill system files are cached in ZIP-based packages for fast loading and modular organization.

Table of Contents

Overview

Class Description
TGorillaAssetsManager Main component managing packages
TGorillaAssetsPackage A ZIP-based asset package
TGorillaAssetsGroup A group of assets by type (models, textures, etc.)
TGorillaAsset Base class for individual assets

Asset Types

The assets manager supports these built-in asset groups:

Constant ID Group Description
GORILLA_ASSETS_MODEL 0 MODEL 3D models (G3D, FBX, glTF, etc.)
GORILLA_ASSETS_TEXTURE 1 TEXTURE Image textures (PNG, JPG, DDS, TGA)
GORILLA_ASSETS_AUDIO 2 AUDIO Sound files
GORILLA_ASSETS_VIDEO 3 VIDEO Video files
GORILLA_ASSETS_MISC 4 MISC Miscellaneous files
GORILLA_ASSETS_DIALOGUE 5 DIALOGUE Dialogue system files
GORILLA_ASSETS_INVENTORY 6 INVENTORY Inventory definitions
GORILLA_ASSETS_SCRIPT 7 SCRIPT Script files
GORILLA_ASSETS_PREFAB 8 PREFAB Prefab templates
GORILLA_ASSETS_SKILLS 9 SKILLS Skill system definitions

Getting Started

Design-Time

  1. Drop a TGorillaAssetsManager onto your form
  2. Use the IDE Assets Manager editor to create packages and import files

Runtime

uses Gorilla.AssetsManager;

var
  AssetsMgr: TGorillaAssetsManager;
begin
  AssetsMgr := TGorillaAssetsManager.Create(Self);
end;

Asset Packages

Packages are ZIP archives containing organized asset files and a asset.json metadata file. The default package name is 'default'.

// Packages are stored as ZIP files
// Internal structure:
//   asset.json          - metadata with version and asset listing
//   MODEL/              - 3D model files
//   TEXTURE/            - texture files
//   AUDIO/              - audio files
//   DIALOGUE/           - dialogue definitions
//   INVENTORY/          - inventory definitions
//   SKILLS/             - skill system files
//   PREFAB/             - prefab files
//   ...

Importing Assets

From File

var LAsset: TGorillaAsset;
begin
  // Import auto-detects the asset type by file extension
  LAsset := TGorillaAsset.ImportFromFile(SomeGroup, 'models/character.g3d');
end;

From Stream

LAsset := TGorillaAsset.ImportFromStream(SomeGroup, 'character.g3d', MyStream);

Import Flags

Flag Description
StrictFileName Match filename exactly (no path normalization)
Cached Mark asset as cached immediately

Asset Groups and Subgroups

Assets are organized into groups by type. Each group can contain subgroups for further organization:

// Each asset knows its group
var LGroup := LAsset.Group;

// Assets provide JSON serialization for package storage
var LJSON := LAsset.ToJSON();
LAsset.FromJSON(LJSON);

Loading and Accessing Assets

Asset Properties

Property Type Description
Id TGorillaGUID Unique identifier
Filename String Original filename
Extension String File extension
Cached Boolean Whether data is buffered in memory
IsStandalone Boolean Created without a group reference
State TAssetState Current state (Loading, Loaded, Storing, Stored)
Group TGorillaAssetsGroup Parent group reference

Asset States

State Description
asUndef Undefined
asLoading Currently loading
asLoaded Loaded and available
asStoring Currently saving
asStored Saved to package

Extension Detection

// Check if a file extension is supported
if TGorillaAsset.IsExtensionSupported('.g3d') then ...;

// Get the asset class for an extension
var LClass := TGorillaAsset.GetSupportedAssetClass('.png');

Package Versioning

Asset packages include version information (current version: 1.3):

  • v1.1: Subgroups, version in asset.json, SKP/PLY support
  • v1.2: Compiler directive fixes, SkillSystem files
  • v1.3: PBR material support, additional material properties

Best Practices

  • Organize assets into packages by scene or module (e.g., main_character.zip, level1.zip)
  • Use subgroups for detailed organization within a package
  • Share common assets (like a character model) by referencing the same package across scenes
  • Use Cached flag to keep frequently used assets in memory
  • The assets manager uses ZIP compression — keep original files organized but pack them for distribution
  • Use the IDE's Assets Manager editor for visual package management at design-time
  • Asset packages support Level of Detail flags (prepared for future use)