Scripting API
Scripting API
ModelImporter
Class in Abyss.Core, from Abyss.Core.
The engine's model importer: a model's file — glTF, FBX or OBJ — and its settings in, an .abymesh file of its meshes out, each as Bevy keeps it, its normals and tangents made once; and what such a file holds.
public static class ModelImporterRemarks
No world, and any thread, as TextureImporter: the editor runs as many at once as it has threads to spare and tells the world of each as it lands (World.UseImportedModel). A game built from the project never imports anything.
Properties
Extensions
public static IReadOnlyList<string> Extensions { get; }The kinds of file the importer reads: glTF, as text or binary, and FBX and OBJ, which ufbx reads.
Version
public static uint Version { get; }The importer's version: a model imported by any other is imported again.
Methods
IsModel
public static bool IsModel(string path)Whether a file under the asset root is a model this importer reads.
Parameters
path
ArtifactOf
public static string ArtifactOf(string cache, AssetGuid id)Where a model's import is kept in a cache: models/b6/<id>.abymesh.
Parameters
cache: The cache folder, its whole path.id: The model's identity.
DescriptionOf
public static string DescriptionOf(string artifact)Where an import's description of the model is: beside it, <id>.json.
Parameters
artifact
TextureOf
public static string TextureOf(string artifact, string label)Where an import keeps a texture the model carries: beside it, <id>.Texture0.ktx2.
Parameters
artifactlabel
PrefabOf
public static string PrefabOf(string artifact)Where the editor keeps the model's prefab, made of the description: beside it, <id>.prefab.
Parameters
artifact
AnimationOf
public static string AnimationOf(string artifact)Where an import keeps the model's skins and clips: beside it, <id>.abyanim; there only for a model with either.
Parameters
artifact
BakedOf
public static string BakedOf(string artifact, string baker)What baker baked of an import's meshes, beside it: ….abyss.physics3d.bake; see Schedule.BakeInEditor.
Parameters
artifactbaker
Import
public static ImportedModel Import(string source, ImportSettings settings, string artifact, ClipSettings? clips = null)Imports the meshes of source as settings say, into artifact; and beside it, what the file says of its nodes, materials and textures (ModelImporter.DescriptionOf) and each texture it carries (ModelImporter.TextureOf).
Parameters
source: The model's file — glTF, FBX or OBJ — its whole path.settings: How it is imported.artifact: The.abymeshfile to write, its whole path; written whole, its folder made.clips: How its clips are imported, beside its meshes as an.abyanimfile (ModelImporter.AnimationOf); null for the defaults.
Returns What it made.
Exceptions
AbyssException: The source cannot be read or is not a model, or the artifact cannot be written; the message says which and why.AbyssException: In a game's executable, which is built without what only the editor does (AbyssStatus.NotInBuiltGame).
ExtractImages
public static int ExtractImages(string source, string folder)Writes each image source carries inside it into folder, as it carries it — a PNG as a PNG, a JPEG as a JPEG, a TGA as the PNG it is read as — named by its texture's label, Texture0.png: what Extract Materials writes out beside the material files it makes. Reads the whole file, so any thread but not every frame.
Parameters
source: The model's file, its whole path.folder: Where the images go, its whole path; made if it is not there.
Returns How many it wrote.
Exceptions
AbyssException: The source cannot be read, or an image cannot be written.AbyssException: In a game's executable, which is built without what only the editor does (AbyssStatus.NotInBuiltGame).
Contents
public static IReadOnlyList<ImportedMesh> Contents(string artifact)What an imported model holds, its meshes in the file's order, read from its tables alone.
Parameters
artifact
Exceptions
AbyssException: The file cannot be read, or is not one this build writes.
GeometryOf
public static MeshGeometry? GeometryOf(string artifact, string label)The corners and triangles of the mesh labeled label in an imported model, as World.MeshGeometry gives a loaded mesh's; null for one not a list of triangles. What a package bakes of a model as it is imported.
Parameters
artifactlabel
Exceptions
AbyssException: The file cannot be read, or has no such mesh.
Use
public static void Use(World world, string path, string artifact)Tells world of a model's import and of each texture it carries, under the model's path and its label, models/crate.gltf#Texture0: what a world draws a model from, since a model is never read from its source.
Parameters
world: The world to tell.path: The model, by its path under the asset root.artifact: Its import, its whole path.
Exceptions
AbyssException: The import's tables, or a texture's import, cannot be read.IOException: Its description cannot be read.InvalidDataException: Its description is not one this build reads.
UseCache
public static IReadOnlyList<string> UseCache(World world, AssetDatabase database, string cache)Tells world of every model under database's root that cache holds an import of (see ModelImporter.Use): what a game played from its folders draws its models from, the imports the editor made.
Parameters
world: The world to tell.database: What every file under the asset root is called.cache: The cache the imports are in, its whole path.
Returns What could not be used, in words: each model with no import there, or one that cannot be read, which is not drawn.
Constants
Extension
public const string Extension = ".abymesh"The extension an imported model's file has.
CacheFolder
public const string CacheFolder = "cache"The folder beside a project's assets its imports are kept in.
