API Reference · Skinning and morph targets

MorphShapes

Namespace: Ava3D

public sealed class MorphShapes

The morph targets of a loaded model, addressed by name, with opposed pairs folded into one signed parameter each.

Why the folding. A character creator exports its sliders as pairs — eye_large and eye_small, build_heavy and build_slim — because a morph target can only add. Handed to a caller raw that is two independent 0..1 weights with a meaningless state in the middle where both are 1, and every consumer writes the same clamping code. Detected as a pair it is one number from −1 to 1 that cannot be set wrong.

The folding is a convenience over the raw weights and never a replacement: MorphShapes.Weights still reaches every target by its own name, and a pair the heuristic does not recognise simply appears as two parameters instead of one.

Properties

MemberDescription
float Item { get; set; }

A parameter's value. −1 to 1 for a detected pair, 0 to 1 otherwise; not clamped, because a caller overshooting a shape deliberately is a thing character creators do and clamping cannot be undone.

IReadOnlyList<string> Names { get; }

Every parameter name, in the order the targets were added.

IReadOnlyList<AppearanceParameter> Parameters { get; }

Every parameter, as something a UI can lay out: a name, a range and a default.

Built once, on first use, because pairing cannot know what is paired until every target is in. Adding a target after this has been read starts the set again rather than leaving it stale.

MorphWeights Weights { get; }

Every morph target by its own name, unfolded — the escape hatch from the pairing.

Methods

MemberDescription
void Add(string target, MeshNode node, int index, float initial = 0.0f)

Registers one morph target of one mesh node under a name.

The same name may be added for several nodes — a mesh split into two primitives shares its target names across both, and setting the parameter writes to all of them, which is what makes one slider reshape a head and the eyes in it together.

target

The target's name, as the file gave it or as the caller chooses.

node

The node carrying the mesh.

index

Which of the mesh's Mesh.MorphTargets this is.

initial

The weight the model starts at, which is what MorphShapes.Reset returns to.

bool Contains(string name)

Whether a parameter by this name exists.

void Reset()

Puts every parameter back to what the file said.

See also