pub struct ExprBlender { /* private fields */ }Expand description
Manages a library of ExpressionDefs and resolves them to morph-target
weight maps at runtime.
Implementations§
Source§impl ExpressionBlender
impl ExpressionBlender
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a blender pre-loaded with the default expression library
(default_expression_defs).
Sourcepub fn add(&mut self, def: ExpressionDef)
pub fn add(&mut self, def: ExpressionDef)
Add an expression definition to the library. If an expression with the same name already exists it is replaced.
Sourcepub fn get(&self, name: &str) -> Option<&ExpressionDef>
pub fn get(&self, name: &str) -> Option<&ExpressionDef>
Look up an expression definition by name (case-insensitive).
Sourcepub fn list_names(&self) -> Vec<&str>
pub fn list_names(&self) -> Vec<&str>
Return a sorted list of all expression names (original casing).
Sourcepub fn blend_to_weights(
&self,
expr: &str,
intensity: f64,
) -> Option<HashMap<String, f64>>
pub fn blend_to_weights( &self, expr: &str, intensity: f64, ) -> Option<HashMap<String, f64>>
Map a single expression at intensity to a HashMap<target, weight>.
Each per-target base weight is multiplied by intensity, then clamped
to [0.0, 1.0]. Returns None if the expression name is not found.
Sourcepub fn blend_multi(&self, exprs: &[(String, f64)]) -> HashMap<String, f64>
pub fn blend_multi(&self, exprs: &[(String, f64)]) -> HashMap<String, f64>
Additively blend multiple expressions.
exprs is a slice of (expression_name, intensity) pairs.
For each pair the expression is resolved at the given intensity and
its weights are added into the accumulator. The final map is
clamped per-target to [0.0, 1.0]. Unknown expression names are
silently skipped.
Sourcepub fn lerp_expression(
&self,
from: &str,
to: &str,
t: f64,
) -> HashMap<String, f64>
pub fn lerp_expression( &self, from: &str, to: &str, t: f64, ) -> HashMap<String, f64>
Linearly interpolate between two expressions at parameter t ∈ [0, 1].
At t = 0.0 the result equals blend_to_weights(from, 1.0).
At t = 1.0 the result equals blend_to_weights(to, 1.0).
Intermediate values are computed per-target as w_from * (1-t) + w_to * t.
Targets that appear in only one expression are treated as having weight 0.0 in the other. Returns an empty map if both expressions are unknown.
Sourcepub fn au_to_expression(au_code: u32, intensity: f64) -> HashMap<String, f64>
pub fn au_to_expression(au_code: u32, intensity: f64) -> HashMap<String, f64>
Map a FACS Action Unit code + intensity to morph-target weights.
This implements an approximate mapping from the standard FACS AU numbers (as used by Paul Ekman et al.) to OxiHuman morph-target names.
The mapping is intentionally broad: each AU drives one or more targets.
intensity is in [0.0, 1.0]; the return value is a weight map with
all values clamped to [0.0, 1.0].
Unknown AU codes return an empty map rather than erroring.
Trait Implementations§
Source§impl Clone for ExpressionBlender
impl Clone for ExpressionBlender
Source§fn clone(&self) -> ExpressionBlender
fn clone(&self) -> ExpressionBlender
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExpressionBlender
impl Debug for ExpressionBlender
Auto Trait Implementations§
impl Freeze for ExpressionBlender
impl RefUnwindSafe for ExpressionBlender
impl Send for ExpressionBlender
impl Sync for ExpressionBlender
impl Unpin for ExpressionBlender
impl UnsafeUnpin for ExpressionBlender
impl UnwindSafe for ExpressionBlender
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more