Scripting API

Scripting API

ModelPrefab

Class in Abyss.Core.Scenes, from Abyss.Core.

A model's prefab: what an import says of its nodes, materials and textures, made into the document a prefab is, which the editor keeps beside the import (ModelImporter.PrefabOf) and PrefabFolder reads when a scene instances the model.

public static class ModelPrefab

Remarks

An entity a node, its transform the node's. A node drawing a mesh of one primitive draws it itself; one whose mesh has several has a child for each, named as Bevy's loader names them, since an entity here draws one mesh with one material.

The root is named after the file. A file with one node at its top makes that node the root, with its transform — a modeler's whole object, turned as it was exported; a file with several, or one whose settings say Preserve Hierarchy, has a root of its own above them, where the instance is placed without turning anything.

An entity's id is worked out from the names above it: the model's identity and the path of node names from the top of its file, the second of two siblings with one name told apart by coming second. So an import made again — another Scale Factor, a file exported again with a node moved — gives each node the id it had, and what a scene changed inside an instance stays with the node it changed; and the root of its own Preserve Hierarchy adds is not among the names, so turning it on or off keeps every node's id too. A node renamed in the file is a node the prefab no longer has, as it would be anywhere.

Its materials are written into it, each the numbers Bevy's loader makes of the file's, and its textures name the images the import made of the ones the model carries — the model's identity and #Texture0 — or the project's own file where one is beside the model.

Methods

Build

public static SceneDocument Build(ModelDescription model, string path, AssetGuid id, bool keepHierarchy, Func<string, AssetGuid> identify, List<string> notes)

Makes a model's prefab.

Parameters

  • model: What its import says of it.
  • path: The model, by its path under the asset root.
  • id: The model's identity, which its meshes and the images it carries are named by.
  • keepHierarchy: Whether the prefab keeps a root of its own above a file's one node at the top.
  • identify: The identity of a file under the asset root, by its path there; for an image beside the model.
  • notes: What could not be made, in words.

Build

public static SceneDocument Build(ModelDescription model, string path, AssetGuid id, bool keepHierarchy, Func<string, AssetGuid> identify, List<string> notes, Func<string, RemappedMaterial?>? remapped)

Makes a model's prefab, each of its materials given a file drawn as that file.

Parameters

  • model: What its import says of it.
  • path: The model, by its path under the asset root.
  • id: The model's identity, which its meshes and the images it carries are named by.
  • keepHierarchy: Whether the prefab keeps a root of its own above a file's one node at the top.
  • identify: The identity of a file under the asset root, by its path there; for an image beside the model.
  • notes: What could not be made, in words.
  • remapped: The material file a material is drawn as, by its name (ModelPrefab.NameOf), with where it is now; null for the model's own. See MaterialRemap.

Surface

public static SceneMaterial? Surface(ModelDescription model, string path, AssetGuid id, string label, Func<string, AssetGuid> identify, SceneDocument document, List<string> notes)

One of a model's materials as a material of document's own: its surface, and each image it draws with — one the model carries, models/x.gltf#Texture0, or the file beside it — added to the document's assets under a key of its own. Null for a label the model has no material by.

Parameters

  • model: What its import says of it.
  • path: The model, by its path under the asset root.
  • id: The model's identity, which the images it carries are named by.
  • label: The material, as a path names it: Material0.
  • identify: The identity of a file under the asset root, by its path there.
  • document: The document the images go into.
  • notes: What could not be made, in words.

What a scene naming models/x.gltf#Material0 is packed with, a built game having no glTF to read the material out of; the material is the one the model's prefab draws with.

NameOf

public static string NameOf(ModelMaterial material)

What a model's material is known by to what is given in its place (MaterialRemap): its name in the file, or its label, Material0, for one the file names nothing.

Parameters

  • material

BesideOf

public static string? BesideOf(string model, string file)

A file a model names relative to itself — a texture's image in a file of its own — by its path under the asset root, or null for one outside it.

Parameters

  • model: The model, by its path under the asset root.
  • file: The file, as the model's import names it, relative to the model.

Constants

Version

public const uint Version = 4

What Build is: a prefab made by any other is made again.

Raised whenever what it makes of the same description changes: 3 when an animated model's root was given its animator; 4 when the images a model names were looked for in the whole project (ModelImages).

Animator

public const string Animator = "Animator"

What plays a model's clips: the engine's component, on the prefab's root.