Repository navigation
Expression Control
Expression control functions:
Model.SetRandomExpression(fadeoutMs=-1) -> str | None
Model.SetExpression(new_exp_id, fadeoutMs=-1)
Model.ResetExpression() # reset the expressionWhen fadeoutMs is -1, the expression switches to new_exp and new_exp becomes the default expression (persistent).
When fadeoutMs >= 0, the expression switches from last_exp to new_exp, and automatically reverts to last_exp after fadeoutMs milliseconds (temporary expression).
Model.SetExpression(expId: str): overrides all expressions added via Add
Model.SetRandomExpression() -> str: same as above
Model.AddExpression(expId: str): stacks expressions — non-conflicting expressions like hats, star eyes, and gestures can be active at the same time; some expressions conflict (e.g. golden pupils vs. red pupils), in which case only one can be shown
Model.RemoveExpression(expId: str): removes expressions added via Add
Model.ResetExpressions(): clears all expressions
Model.ResetExpression(): clears the expression set via Set; expressions activated by Add that were not Removed will show again
# All expression ids built into the model
expressions = model.GetExpressions()
# Load an extra expression file not defined in model3.json
model.LoadExtraExpression("extra_0", "path/to/F03.exp3.json")
model.SetExpression("extra_0")Internals:
Model.SetExpression(expId: str): updates expressions with a dedicated ExpressionManager _expressionManager
Model.AddExpression(expId: str), Model.RemoveExpression(expId: str): managed via Map<ExpIdString, ExpressionManager> _expManagers — each expression has its own ExpressionManager; AddExpression activates the corresponding ExpressionManager.
UpdateExpression logic:
if (_expressionManager->IsFinished())
{
for (auto &pair : _expManagers)
{
pair.second->UpdateMotion(_model, deltaSecs);
}
}
else
{
_expressionManager->UpdateMotion(_model, deltaSecs);
}This expression state machine is implemented inside the C++ Model (v2/v3 behave identically) — the temporary-expression restore logic of SetExpression(id, fadeoutMs) needs no Python-side handling.