Trait AnimationSource

Source
pub trait AnimationSource {
    type Prefab: PrefabData<Graph = Self::SceneGraph>;
    type SceneGraph: SceneGraph<Node = Self::Node, Prefab = Self::Prefab>;
    type Node: SceneGraphNode<SceneGraph = Self::SceneGraph, ResourceData = Self::Prefab>;

    // Required method
    fn inner_graph(&self) -> &Self::SceneGraph;

    // Provided methods
    fn retarget_animations_directly(
        &self,
        root: Handle<Self::Node>,
        graph: &Self::SceneGraph,
        self_kind: ResourceKind,
    ) -> Vec<Animation<Handle<Self::Node>>> { ... }
    fn retarget_animations_to_player(
        &self,
        root: Handle<Self::Node>,
        dest_animation_player: Handle<Self::Node>,
        graph: &mut Self::SceneGraph,
        self_kind: ResourceKind,
    ) -> Vec<Handle<Animation<Handle<Self::Node>>>> { ... }
    fn retarget_animations(
        &self,
        root: Handle<Self::Node>,
        graph: &mut Self::SceneGraph,
        self_kind: ResourceKind,
    ) -> Vec<Handle<Animation<Handle<Self::Node>>>> { ... }
}
Expand description

Common trait that has animation retargetting methods.

Required Associated Types§

Source

type Prefab: PrefabData<Graph = Self::SceneGraph>

Prefab type.

Source

type SceneGraph: SceneGraph<Node = Self::Node, Prefab = Self::Prefab>

Scene graph type.

Source

type Node: SceneGraphNode<SceneGraph = Self::SceneGraph, ResourceData = Self::Prefab>

Scene node type.

Required Methods§

Source

fn inner_graph(&self) -> &Self::SceneGraph

Returns a reference to an inner graph.

Provided Methods§

Source

fn retarget_animations_directly( &self, root: Handle<Self::Node>, graph: &Self::SceneGraph, self_kind: ResourceKind, ) -> Vec<Animation<Handle<Self::Node>>>

Tries to retarget animations from given model resource to a node hierarchy starting from root on a given scene.

Animation retargeting allows you to “transfer” animation from a model to a model instance on a scene. Imagine you have a character that should have multiple animations like idle, run, shoot, walk, etc. and you want to store each animation in a separate file. Then when you creating a character on a level you want to have all possible animations assigned to a character, this is where this function comes into play: you just load a model of your character with skeleton, but without any animations, then you load several “models” which have only skeleton with some animation (such “models” can be considered as “animation” resources). After this you need to instantiate model on your level and retarget all animations you need to that instance from other “models”. All you have after this is a handle to a model and bunch of handles to specific animations. After this animations can be blended in any combinations you need to. For example idle animation can be blended with walk animation when your character starts walking.

§Notes

Most of the 3d model formats can contain only one animation, so in most cases this function will return vector with only one animation.

Source

fn retarget_animations_to_player( &self, root: Handle<Self::Node>, dest_animation_player: Handle<Self::Node>, graph: &mut Self::SceneGraph, self_kind: ResourceKind, ) -> Vec<Handle<Animation<Handle<Self::Node>>>>

Tries to retarget animations from given model resource to a node hierarchy starting from root on a given scene. Unlike Self::retarget_animations_directly, it automatically adds retargetted animations to the specified animation player in the hierarchy of given root.

§Panic

Panics if dest_animation_player is invalid handle, or the node does not have AnimationContainer component.

Source

fn retarget_animations( &self, root: Handle<Self::Node>, graph: &mut Self::SceneGraph, self_kind: ResourceKind, ) -> Vec<Handle<Animation<Handle<Self::Node>>>>

Tries to retarget animations from given model resource to a node hierarchy starting from root on a given scene. Unlike Self::retarget_animations_directly, it automatically adds retargetted animations to a first animation player in the hierarchy of given root.

§Panic

Panics if there’s no animation player in the given hierarchy (descendant nodes of root).

Implementors§