Skip to content

DatabaseMeshes ​

Inherits: RefCounted

The mesh and material library of the project, read from the folders under res://src/data/meshes/.

Description ​

It holds weapons (equipment/weapons/<category>/), the parts of modular characters (equipment/body_parts/<tag>/<part>/), attachments (equipment/attachments/<tag>/<slot>/), facial features (facial/<skeleton tag>/<feature>/) and materials (materials/<category>/). A mesh file may have a skin file next to it with the same name (_mesh replaced by _skin). The folders are scanned once on first use; call refresh_database after adding files.

Methods ​

voidinitialize() static
voidrefresh_database() static
voidensure_initialized() static
Array[String]get_weapon_categories() static
Array[String]get_weapon_names( category: String ) static
Meshget_weapon_mesh( category: String, name: String ) static
Dictionaryget_weapon_data( category: String, name: String ) static
Meshget_random_weapon_mesh( category: String ) static
Array[String]get_modular_equipment_tags() static
Array[String]get_body_part_types() static
Array[String]get_body_part_names( body_part_type: String, tag: String = "" ) static
Dictionaryget_body_part_mesh_and_skin( body_part_type: String, name: String, tag: String = "" ) static
Meshget_body_part_mesh( body_part_type: String, name: String, tag: String = "" ) static
Dictionaryget_body_part_data( body_part_type: String, name: String, tag: String = "" ) static
Meshget_random_body_part_mesh( body_part_type: String, tag: String = "" ) static
Array[String]get_attachment_types() static
Array[String]get_attachment_names( attachment_type: String, tag: String = "" ) static
Meshget_attachment_mesh( attachment_type: String, name: String, tag: String = "" ) static
Dictionaryget_attachment_mesh_and_skin( attachment_type: String, name: String, tag: String = "" ) static
Dictionaryget_attachment_data( attachment_type: String, name: String, tag: String = "" ) static
Meshget_random_attachment_mesh( attachment_type: String, tag: String = "" ) static
Array[String]get_facial_skeleton_tags() static
Array[String]get_facial_categories( tag: String = "" ) static
Array[String]get_facial_mesh_names( category: String, tag: String = "" ) static
Meshget_facial_mesh( category: String, name: String, tag: String = "" ) static
Dictionaryget_facial_data( category: String, name: String, tag: String = "" ) static
Dictionaryget_facial_mesh_and_skin( tag: String, feature: GeneralSkeleton.FacialFeature, name: String ) static
Array[String]get_options_for_skeleton( tag: String, feature: GeneralSkeleton.FacialFeature ) static
Array[Dictionary]get_all_facial_features_for_list() static
Array[String]get_material_categories() static
Array[String]get_material_names( category: String ) static
Array[String]get_all_material_names() static
Materialget_material( category: String, name: String ) static
Materialget_material_by_name( name: String ) static
Dictionaryget_material_data_by_name( name: String ) static
Dictionaryget_material_data( category: String, name: String ) static
boolcreate_material_category( category_name: String ) static
booladd_material_to_category( material_file_path: String, category: String ) static
boolextract_and_save_material( material: Material, material_name: String, category: String ) static
Array[Dictionary]get_all_equipment_for_list() static
Dictionaryget_database_stats() static
Array[Dictionary]validate_database() static
boolis_database_empty() static
Texture2Dget_mesh_thumbnail( mesh_path: String ) static
intgenerate_thumbnails_batch( mesh_paths: Array[String], force_regenerate: bool = false ) static
intregenerate_all_thumbnails() static
voidclear_thumbnail_cache( clear_disk: bool = false ) static
Array[Dictionary]get_meshes_for_category( mesh_type: int, category: String ) static

Enumerations ​

enum MeshType ​

========== ENUMS ==========

  • SKELETON = 0
  • WEAPON = 1
  • BODY_PART = 2
  • ATTACHMENT = 3
  • FACIAL = 4
  • MATERIAL = 5

Constants ​

  • String EQUIPMENT_PATH = "res://src/data/meshes/equipment/" - ========== PATHS ==========
  • String WEAPONS_PATH = "res://src/data/meshes/equipment/weapons/" - The folder of the weapon meshes.
  • String BODY_PARTS_PATH = "res://src/data/meshes/equipment/body_parts/" - The folder of the body part meshes.
  • String ATTACHMENTS_PATH = "res://src/data/meshes/equipment/attachments/" - The folder of the attachment meshes.
  • String FACIAL_PATH = "res://src/data/meshes/facial/" - The folder of the facial meshes.
  • String MATERIALS_PATH = "res://src/data/meshes/materials/" - The folder of the materials.
  • Array[String] MESH_EXTENSIONS = [".tres", ".res", ".obj", ".glb", ".gltf", ".fbx", ".blend"] - ========== FILE EXTENSIONS ========== A model that Godot imports as a scene (.glb, .gltf, .fbx, .blend) is a mesh file if it holds one mesh node (see MeshSource).
  • Array[String] MATERIAL_EXTENSIONS = [".tres", ".res"] - The file types that count as materials.
  • String METADATA_ALLOWED_MATERIALS = "allowed_materials" - ========== METADATA KEYS ==========
  • String METADATA_PREFERRED_MATERIAL = "preferred_material" - The metadata key of the material a mesh prefers.
  • String METADATA_MATERIAL_CATEGORIES = "material_categories" - The metadata key of the material categories a mesh accepts.
  • Array[String] BODY_PART_TYPES = [ - ========== DEFINITIONS ==========
  • Array[String] ATTACHMENT_TYPES = [ - The kinds of attachment mesh the folder can hold.
  • String THUMBNAILS_PATH = "res://src/data/meshes/.thumbnails/" - ========== THUMBNAIL MANAGEMENT ==========
  • int THUMBNAIL_SIZE = 64 - The size of the thumbnails, in pixels.
  • String THUMBNAIL_EXTENSION = ".png" - The file type of the thumbnails.

Method descriptions ​

void initialize() ​

Makes the folders (when missing) and scans all the mesh folders. Runs once.

void refresh_database() ​

Scans all the mesh folders again (after files were added or removed).

void ensure_initialized() ​

Scans the mesh folders if that has not been done yet.

Array[String] get_weapon_categories() ​

The weapon categories (the folders under equipment/weapons/), sorted.

Array[String] get_weapon_names( category: String ) ​

The names of the weapons of a category, sorted.

Mesh get_weapon_mesh( category: String, name: String ) ​

The mesh of a weapon, or null when there is none with this category and name.

Dictionary get_weapon_data( category: String, name: String ) ​

A copy of what the database knows about a weapon: name, category, mesh path, display name. Empty when it does not exist.

Mesh get_random_weapon_mesh( category: String ) ​

The mesh of a random weapon of a category, or null when the category is empty.

Array[String] get_modular_equipment_tags() ​

The tags of the modular equipment (the folders under body_parts/ and attachments/), sorted. A tag groups the parts that belong together.

Array[String] get_body_part_types() ​

The body part types the database knows (head, torso, arms, hands, legs, feet and the face parts).

Array[String] get_body_part_names( body_part_type: String, tag: String = "" ) ​

The names of the parts of a body part type, for one tag or (with an empty tag) for all of them, sorted.

Dictionary get_body_part_mesh_and_skin( body_part_type: String, name: String, tag: String = "" ) ​

The mesh and the skin of a body part as {mesh, skin}. The skin is the file with the same name and _skin instead of _mesh; either is null when missing.

Mesh get_body_part_mesh( body_part_type: String, name: String, tag: String = "" ) ​

The mesh of a body part, or null.

Dictionary get_body_part_data( body_part_type: String, name: String, tag: String = "" ) ​

A copy of what the database knows about a body part, or an empty dictionary.

Mesh get_random_body_part_mesh( body_part_type: String, tag: String = "" ) ​

The mesh of a random body part of a type (and tag), or null.

Array[String] get_attachment_types() ​

The attachment slots the database knows (head, face, chest, back, hips, hands, shoulders, knees, elbows, cloak).

Array[String] get_attachment_names( attachment_type: String, tag: String = "" ) ​

The names of the attachments of a slot, for one tag or all of them, sorted.

Mesh get_attachment_mesh( attachment_type: String, name: String, tag: String = "" ) ​

The mesh of an attachment, or null.

Dictionary get_attachment_mesh_and_skin( attachment_type: String, name: String, tag: String = "" ) ​

The mesh and the skin of an attachment as {mesh, skin}.

Dictionary get_attachment_data( attachment_type: String, name: String, tag: String = "" ) ​

A copy of what the database knows about an attachment, or an empty dictionary.

Mesh get_random_attachment_mesh( attachment_type: String, tag: String = "" ) ​

The mesh of a random attachment of a slot (and tag), or null.

Array[String] get_facial_skeleton_tags() ​

The skeleton tags that have facial features (the folders under facial/), sorted.

Array[String] get_facial_categories( tag: String = "" ) ​

The facial feature categories (eyes, nose ...) for one skeleton tag, or for all of them.

Array[String] get_facial_mesh_names( category: String, tag: String = "" ) ​

The names of the facial meshes of a category, for one tag or all of them, sorted.

Mesh get_facial_mesh( category: String, name: String, tag: String = "" ) ​

The mesh of a facial feature, or null.

Dictionary get_facial_data( category: String, name: String, tag: String = "" ) ​

A copy of what the database knows about a facial mesh, or an empty dictionary.

Dictionary get_facial_mesh_and_skin( tag: String, feature: GeneralSkeleton.FacialFeature, name: String ) ​

The mesh and the skin of a facial feature of a skeleton tag as {mesh, skin, materials}.

Array[String] get_options_for_skeleton( tag: String, feature: GeneralSkeleton.FacialFeature ) ​

The names of the meshes a skeleton tag offers for a facial feature, sorted.

Array[Dictionary] get_all_facial_features_for_list() ​

Every facial mesh as a list of dictionaries, for the editor.

Array[String] get_material_categories() ​

The material categories (the folders under materials/), sorted.

Array[String] get_material_names( category: String ) ​

The names of the materials of a category, sorted.

Array[String] get_all_material_names() ​

The names of all the materials of all the categories.

Material get_material( category: String, name: String ) ​

The material with this category and name, or null.

Material get_material_by_name( name: String ) ​

The first material with this name in any category, or null.

Dictionary get_material_data_by_name( name: String ) ​

A copy of what the database knows about the first material with this name, or an empty dictionary.

Dictionary get_material_data( category: String, name: String ) ​

A copy of what the database knows about a material, or an empty dictionary.

bool create_material_category( category_name: String ) ​

Makes a new material category folder. False when the name is empty or the category exists.

bool add_material_to_category( material_file_path: String, category: String ) ​

Copies a material file into a category folder and adds it to the database.

bool extract_and_save_material( material: Material, material_name: String, category: String ) ​

Saves a material (for example one taken from a mesh) as <name>.tres in a category and adds it to the database.

Array[Dictionary] get_all_equipment_for_list() ​

Every weapon, body part and attachment as a list of dictionaries, for the editor.

Dictionary get_database_stats() ​

How many of everything the database found: weapons, body parts, attachments, facial meshes, materials and their categories.

Array[Dictionary] validate_database() ​

Checks that the files the database found still exist. Returns a list of {type, message, category, item_name, severity}; empty when everything is fine.

bool is_database_empty() ​

True when no weapon, body part, attachment, facial mesh or material was found.

Texture2D get_mesh_thumbnail( mesh_path: String ) ​

Get mesh thumbnail (cached or generated)

int generate_thumbnails_batch( mesh_paths: Array[String], force_regenerate: bool = false ) ​

Generate thumbnails for multiple meshes Uses async thumbnail generation with proper callbacks

int regenerate_all_thumbnails() ​

Force regenerate all thumbnails

void clear_thumbnail_cache( clear_disk: bool = false ) ​

Clear thumbnail cache

Array[Dictionary] get_meshes_for_category( mesh_type: int, category: String ) ​

Get all meshes for a category (for catalog display with thumbnails)