BBMOD_AnimationPlayer

Extends BBMOD_Class
Implements Struct.BBMOD_IEventListener, Struct.BBMOD_IRenderable

constructor

new BBMOD_AnimationPlayer(_model[, _paused])

Description

An animation player. Each instance of an animated model should have its own animation player.

Arguments

Name Type Description
_model Struct.BBMOD_Model A model that the animation player animates.
_paused Bool If true then the animation player is created as paused. Defaults to false.

Properties

Name Description
Animation The currently playing animation or undefined.
AnimationLoops If true then BBMOD_AnimationPlayer.Animation loops.
Frameskip Number of frames (calls to BBMOD_AnimationPlayer.update) to skip. Defaults to 0 (frame skipping is disabled). Increasing the value increases performance. Use infinity to disable computing animation frames entirely.
Model A model that the animation player animates.
Paused If true, then the animation playback is paused.
PlaybackSpeed Controls animation playback speed. Must be a positive number!
Time The current animation playback time.

Methods

Name Description
change Starts playing an animation from its start, only if it is a different one that the last played animation.
get_node_transform Returns a transformation (dual quaternion) of a node, which can be used for example for attachments.
get_node_transform_from_frame Returns a transformation (dual quaternion) of a node from the last animation frame. This is useful if you want to add additional transformations onto an animated bone, instead of competely replacing it.
get_transform Returns an array of current transformations of all bones. This should be passed to a vertex shader.
play Starts playing an animation from its start.
render Enqueues the animated model for rendering.
set_node_position Overrides a position of a node.
set_node_rotation Overrides a rotation of a node.
submit Immediately submits the animated model for rendering.
update Updates the animation player. This should be called every frame in the step event.

Example

Following code shows how to load models and animations in a resource manager object and then play animations in multiple instances of another object.

/// @desc Create event of OResourceManager
modCharacter = new BBMOD_Model("character.bbmod");
animIdle = new BBMOD_Animation("idle.bbanim");

/// @desc Create event of OCharacter
model = OResourceManager.modCharacter;
animationPlayer = new BBMOD_AnimationPlayer(model);
animationPlayer.play(OResourceManager.animIdle, true);

/// @desc Step event of OCharacter
animationPlayer.update(delta_time);

/// @desc Draw event of OCharacter
bbmod_material_reset();
animationPlayer.render();
bbmod_material_reset();

See also

BBMOD_Animation, BBMOD_IEventListener, BBMOD_Model

Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on September 19, 2022 using GMDoc.