Skip to content
View source

entelechy-exportGenerated

Layer: interface · Lines of code: 2,328 · Integration test files: 2

The exporter: writes the Host’s files as formats other software opens, from outside the runtime

A mesh and a rig as GLB, and a font as TrueType or WOFF, from the Host’s files. Sounds, scores and pictures are written by entelechy_formats::encode.

Internal dependencies entelechy-formats, entelechy-host
External dependencies serde_json
Source crates/interface/export
Name Brief
font A font file from a font’s Fields (entelechy_formats::font), the Fields entelechy import reads a font into: TrueType outlines in a .ttf, the same tables compressed in a .woff, or CFF outlines in an .otf.
gltf A mesh as GLB: vertex rows {position, normal, uv} (or with a tangent after them), triangle rows and optional PNGs (a base color, a normal map, an occlusion map) become one glTF 2.0 binary with one mesh, node and scene.
Name Brief
font::Face A font ready to write: its glyphs and which characters map to them.
gltf::Rig A rig’s rows beside the mesh.
gltf::Options What a GLB carries beyond the rows: how its texture is sampled, its joints’ names in skeleton order (joint0, joint1,… when none are given), and whether its material is seen from both sides.
gltf::Textures A GLB’s pictures, each a PNG: the base color, the normal map (in the tangent space the vertices’ tangents give), the occlusion (read from its red), and an ORM map packing occlusion, roughness and metalness in its red, green and blue (glTF’s metallic-roughness texture, its occlusion where no occlusion map is given).
Name Brief
gltf::Filter How a GLB’s texture is sampled.
Function Brief
fn face(inputs: &[FieldData], family: &str, chars: Option<&str>) -> Result<Face, String> The font the Fields inputs hold (glyph rows, segments and, if given, the measures; told apart by layout), named family: of the characters of chars, or of every one the rows map.
fn ttf(face: &Face) -> Vec<u8> The face as a TrueType file.
fn otf(face: &Face) -> Vec<u8> The face as an OpenType file of CFF outlines.
fn woff(face: &Face) -> Vec<u8> The face as a WOFF file: the TrueType file’s tables, each compressed (zlib) where that makes it smaller, head with the TrueType file’s checksum adjustment.
fn write_rig(vertices: &FieldData, triangles: &FieldData, textures: &Textures<'_>, rig: Option<&Rig<'_>>, name: &str, options: &Options) -> Result<Vec<u8>, String> The same, with a skin and one animation per clip.
fn export(vertices: &Path, triangles: &Path, texture: Option<&Path>, out: &Path) -> Result<(), String> Reads the vertex and triangle Field files and optional texture, and writes the GLB at out.
fn export_rig(vertices: &Path, triangles: &Path, textures: &[&Path], rig: &[&Path], clips: &[&Path], rate: f32, out: &Path, options: &Options) -> Result<(), String> The same, with weights, skeleton and clip files, each clip named by its file name before .clip.field, and options. A PNG named <stem>.normal.png is the normal map, <stem>.occlusion.png the occlusion, <stem>.orm.png the occlusion, roughness and metalness, any other the base color; one of each at most.

crates/interface/export/src/font.rs#L25

A font ready to write: its glyphs and which characters map to them.

Methods

Function Description
fn characters(&self) -> usize Characters mapped.
fn glyphs(&self) -> usize Glyphs, the missing character’s counted.

Implemented traits: Debug


crates/interface/export/src/gltf.rs#L16

A rig’s rows beside the mesh.

Properties

Name Type Description
weights &'a FieldData Per vertex: four joints, then their weights.
skeleton &'a FieldData Per joint: its parent, then its inverse bind matrix.
clips Vec<(String, &'a FieldData, f32)> Each clip: name, rows, sample rate.

crates/interface/export/src/gltf.rs#L50

What a GLB carries beyond the rows: how its texture is sampled, its joints’ names in skeleton order (joint0, joint1,… when none are given), and whether its material is seen from both sides.

Properties

Name Type Description
filter Filter The texture’s sampling.
joints Vec<String> One name a skeleton row, or none.
double_sided bool Both sides of each triangle drawn and lit (glTF’s doubleSided): a leaf, a sheet, anything one layer thick.

Implemented traits: Clone, Debug, Default


crates/interface/export/src/gltf.rs#L66

A GLB’s pictures, each a PNG: the base color, the normal map (in the tangent space the vertices’ tangents give), the occlusion (read from its red), and an ORM map packing occlusion, roughness and metalness in its red, green and blue (glTF’s metallic-roughness texture, its occlusion where no occlusion map is given).

Properties

Name Type Description
color Option<&'a [u8]>
normal Option<&'a [u8]>
occlusion Option<&'a [u8]>
orm Option<&'a [u8]>

Implemented traits: Clone, Copy, Debug, Default


crates/interface/export/src/gltf.rs#L27

How a GLB’s texture is sampled.

Variants

Name Description
Linear Blended between texels, with mipmaps.
Nearest The nearest texel, no mipmaps: flat colors stay flat, as pixel art and palette textures want.

Implemented traits: Clone, Copy, Debug, Default, Eq, PartialEq, StructuralPartialEq