UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

Unigine::Skinner

Skinner is a visual scripting system for animations. It allows blending different animations together to create complex movements of skinned characters. It also possible to include the physical ragdoll into played animation (for the whole the character or per bone).

The Skinner is based on Unigine::Schemer. Skinner scripts can be found under data/core/systems/skinner folder.
The predefined Skinner blocks that are available by default are contained in the data/core/systems/skinner/blocks/skinner.blocks file.

Skinner graph

Skinner graph (in the external Qt-based interface)

How To Use Skinner Graph

Skinner is built based on Unigine::Schemer. It uses the same entities (see Schemer overview) and shares blocks with it. That means, you can add any of the Schemer block to be used in Skinner graph.

  • Skinner graph is created in the same way as Schemer one (see the how-to guide).
  • The skinned mesh that Skinner controls is specified in the script (see the details below).
  • By default, the Skinner graph should start with schemer.entry named update (see the details below).
  • It is possible to create entry point for playing a single animation event. It can be used to create a momentary action, for example, a punch or an action to pick up an item, instead of playing a looped animation (see details below).
  • All Skinner nodes in the graph, just like Schemer ones, are triggered by dragging a path to their input. After thy has finished their work, an output path is used to trigger next following nodes, if any.

For a start, do the following to create a simple graph that sets an animation to the mesh:

  1. Create schemer.entry named update as the start-up point for the graph.
  2. Add skinner.animation node that will load the animation. Connect schemer.entry output with the input of skinner.animation by dragging a joint. By doing this, you indicate what node to execute after the graph has been run.
  3. Add schemer.file node that will specify the skinned animation file name. Connect it to the name anchor of skinner.animation node.
  4. Add skinner.set node that will play the animation (i.e. set animation to the mesh). This node needs an animation buffer that contains bones transformation data. Connect skinner.animation buffer to the skinner.set buffer. Connect skinner.animation output to skinner.set input to indicate that this is the next node to be executed.
  5. After the Skinner graph has been created or modified, click Run button. A script will be generated out of the graph, compiled on-the-fly and run.
  6. You can also save the created script into *.script file via Save button for it to be loaded and edited later or executed at runtime.

Here is how this simple Skinner graph would look like. Nodes will be executed in the specified order.

Simple Skinner graph

Simple Skinner graph

Available Skinner Blocks

The following blocks are the predefined Skinner blocks loaded from data/core/systems/skinner/blocks/skinner.blocks file.

skinner.add Sums two animations together, for example, to combine two arms swinging animations. This function should be used when some bones are used in both animations at the same time. In case of separate animations, use skinner.combine. This node multiplies two animation buffers.
  • buffer — the resulting output buffer with summed animations.
  • output — the final node output.
  • weight — weight for interpolating animations in range [0;1]:
    • By the value of 0, only the first animation is used.
    • By the value of 1, the result is a sum of two animations.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
skinner.animation Loads an animation file and sets animation data to the animation buffer. After that, it can be set to the mesh or used as an input buffer for combining animations, etc.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • name — name of the animation file. It can be set via schemer.file.
  • time (at the left) — the frame (in the "from-to" interval) to start animation playback from.
    • 0 means the from frame. This is the default value.
    • If the larger value is provided outside from "from-to" interval, the corresponding frame of looped animation is set.
    • If a float argument is passed, the animation is interpolated between nearby frames.
    • If a negative value is provided, interpolation will be done from the current frame to the from frame.
  • speed — speed of animation playback (in frames per second).
  • from — the starting frame number. The default -1 means the first frame from the animation file.
  • to — the ending frame number. The default -1 means the last frame from the animation file.
  • frames — the total number of frames in the animation file.
  • time (at the right) — the current frame in the animation playback.
skinner.animation2 Loads two animation files to blends animations. The resulting interpolated animation data is set to the output animation buffer. After that, it can be set to the mesh or used as an input buffer for combining animations, etc.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • name 0 — name of the first animation file to be blended. It can be set via schemer.file.
  • name 1 — name of the second animation file to be blended. It can be set via schemer.file.
  • speed 0 — speed of the first animation playback (in frames per second).
  • speed 1 — speed of the second animation playback (in frames per second).
  • weight — the weight for interpolating animations in range [0;1]:
    • By the value of 0, only the first animation is used.
    • By the value of 0.5 (by default), both animations are used in the same proportion.
    • By the value of 1, only the second animation is used.
skinner.animation3 Loads three animation files to blends animations. The resulting interpolated animation data is set to the output animation buffer. After that, it can be set to the mesh or used as an input buffer for combining animations, etc.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • name 0 — name of the first animation file to be blended. It can be set via schemer.file.
  • name 1 — name of the second animation file to be blended. It can be set via schemer.file.
  • name 2 — name of the third animation file to be blended. It can be set via schemer.file.
  • speed 0 — speed of the first animation playback (in frames per second).
  • speed 1 — speed of the second animation playback (in frames per second).
  • speed 2 — speed of the third animation playback (in frames per second).
  • weight — the weight for interpolating animations in range [0;1]:
    • By the value of 0, only the first animation is used.
    • By the value of 0.5 (by default), only the second animation is used.
    • By the value of 1, only the third animation is used.
skinner.blend Mixes two animations together, each in the required proportion. The resulting blended animation data is set to the output animation buffer (for example, to be set to the mesh after that).
The blender should be connected to two skinner nodes that set data into two animation buffers of the blender (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the blender. The second animation loop is the same, except that out 1, in 1 and buf 1 are used. After getting two buffers with animation data, the combiner combines them into one and outputs as the resulting buffer.
Interpolation weights used for blending of each animation are added together.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • weight 0 — interpolation weight for the first animation in range [0;1].
    • By the value of 0, the first animation is not used.
    • By the non-zero value, the first animation is used depending on the resulting proportion of all animation weights.
  • weight 1 — interpolation weight for the second animation in range [0;1].
    • By the value of 0, the second animation is not used.
    • By the non-zero value, the second animation is used depending on the resulting proportion of all animation weights.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
skinner.blend3 Mixes three animations together, each in the required proportion. The resulting blended animation data is set to the output animation buffer (for example, to be set to the mesh after that).
The blender should be connected to three skinner nodes that set data into three animation buffers of the blender (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the blender. Two other animation loops are the same, except that out 1 and out 2 (as well as other anchors) are used. After getting three buffers with animation data, the combiner combines them into one and outputs as the resulting buffer.
Interpolation weights used for blending of each animation are added together.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • weight 0 — interpolation weight for the first animation in range [0;1].
    • By the value of 0, the first animation is not used.
    • By the non-zero value, the first animation is used depending on the resulting proportion of all animation weights.
  • weight 1 — interpolation weight for the second animation in range [0;1].
    • By the value of 0, the second animation is not used.
    • By the non-zero value, the second animation is used depending on the resulting proportion of all animation weights.
  • weight 2 — interpolation weight for the third animation in range [0;1].
    • By the value of 0, the third animation is not used.
    • By the non-zero value, the third animation is used depending on the resulting proportion of all animation weights.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
skinner.blend4 Mixes four animations together, each in the required proportion. The resulting blended animation data is set to the output animation buffer (for example, to be set to the mesh after that).
The blender should be connected to four skinner nodes that set data into four animation buffers of the blender (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the blender. Other animation loops are the same, except that out 1, out 2 and out 3 (as well as other anchors) are used. After getting four buffers with animation data, the combiner combines them into one and outputs as the resulting buffer.
Interpolation weights used for blending of each animation are added together.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • weight 0 — interpolation weight for the first animation in range [0;1].
    • By the value of 0, the first animation is not used.
    • By the non-zero value, the first animation is used depending on the resulting proportion of all animation weights.
  • weight 1 — interpolation weight for the second animation in range [0;1].
    • By the value of 0, the second animation is not used.
    • By the non-zero value, the second animation is used depending on the resulting proportion of all animation weights.
  • weight 2 — interpolation weight for the third animation in range [0;1].
    • By the value of 0, the third animation is not used.
    • By the non-zero value, the third animation is used depending on the resulting proportion of all animation weights.
  • weight 3 — interpolation weight for the fourth animation in range [0;1].
    • By the value of 0, the fourth animation is not used.
    • By the non-zero value, the fourth animation is used depending on the resulting proportion of all animation weights.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • out 3 — exit to the fourth animation to set.
  • buf 3 — input buffer from the fourth set animation.
  • in 3 — input after the fourth animation was set.
skinner.blend5 Mixes five animations together, each in the required proportion. The resulting blended animation data is set to the output animation buffer (for example, to be set to the mesh after that).
The blender should be connected to five skinner nodes that set data into five animation buffers of the blender (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the blender. Other animation loops are the same, except that out 1, out 2 and out 3 (as well as other anchors) are used. After getting five buffers with animation data, the combiner combines them into one and outputs as resulting buffer.
Interpolation weights used for blending of each animation are added together.
  • buffer — the resulting output buffer with the played animation.
  • output — the final node output.
  • weight 0 — interpolation weight for the first animation in range [0;1].
    • By the value of 0, the first animation is not used.
    • By the non-zero value, the first animation is used depending on the resulting proportion of all animation weights.
  • weight 1 — interpolation weight for the second animation in range [0;1].
    • By the value of 0, the second animation is not used.
    • By the non-zero value, the second animation is used depending on the resulting proportion of all animation weights.
  • weight 2 — interpolation weight for the third animation in range [0;1].
    • By the value of 0, the third animation is not used.
    • By the non-zero value, the third animation is used depending on the resulting proportion of all animation weights.
  • weight 3 — interpolation weight for the fourth animation in range [0;1].
    • By the value of 0, the fourth animation is not used.
    • By the non-zero value, the fourth animation is used depending on the resulting proportion of all animation weights.
  • weight 4 — interpolation weight for the fifth animation in range [0;1].
    • By the value of 0, the fifth animation is not used.
    • By the non-zero value, the fifth animation is used depending on the resulting proportion of all animation weights.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • out 3 — exit to the fourth animation to set.
  • buf 3 — input buffer from the fourth set animation.
  • in 3 — input after the fourth animation was set.
  • out 4 — exit to the fifth animation to set.
  • buf 4 — input buffer from the fifth set animation.
  • in 4 — input after the fifth animation was set.
skinner.bone Sets a name of the bone. After setting a bone, it can be used for partial ragdoll animation or for custom transformation.
  • bone — bone from the skinned mesh loaded on Skinner start-up.
skinner.combine Combines two separate animations together, for example, to combine arms animation with legs animation. This function should be used when there are no bones that are used in both animations at the same time; otherwise, use skinner.add.
The combiner should be connected to two skinner nodes that set data into two animation buffers of the combiner (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from it enters into buf 0 of the combiner. The second animation loop is the same, except that out 1, in 1 and buf 1 are used. After getting two buffers with animation data, the blender blends them into one and outputs as the resulting buffer that can be set to mesh.
  • buffer — the resulting output buffer with combined animations.
  • output — the final combiner node output.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
skinner.combine3 Combines three separate animations together, for example, to combine arms animation with legs animation and torso animation. This function should be used when there are no bones that are used in animations at the same time; otherwise, use skinner.add.
The combiner should be connected to three skinner nodes that set data into two animation buffers of the combiner (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from it enters into buf 0 of the combiner. The second and the third animation loops are the same, except that out 1 and out 2 (as well as other anchors) are used. After getting three buffers with animation data, the combiner combines them into one and outputs as the resulting buffer that can be set to mesh.
  • buffer — the output buffer with combined animations.
  • output — the final combiner node output.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the third animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
skinner.combine4 Combines four separate animations together, for example, to combine arms animation with legs animation, torso animation and head animation. This function should be used when there are no bones that are used in animations at the same time; otherwise, use skinner.add.
The combiner should be connected to four skinner nodes that set data into two animation buffers of the combiner (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from it enters into buf 0 of the combiner. Other animation loops are the same, except that out 1, out 2 and out 3 (as well as other anchors) are used. After getting four buffers with animation data, the combiner combines them into one and outputs as the resulting buffer that can be set to mesh.
  • buffer — the output buffer with combined animations.
  • output — the final combiner node output.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the third animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • out 3 — exit to the fourth animation to set.
  • buf 3 — input buffer from the fourth set animation.
  • in 3 — input after the fourth animation was set.
skinner.combine5 Combines five separate animations together. This function should be used when there are no bones that are used in animations at the same time; otherwise, use skinner.add.
The combiner should be connected to five skinner nodes that set data into two animation buffers of the combiner (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from it enters into buf 0 of the combiner. Other animation loops are the same, except that out 1, out 2, out 3 and out 4 (as well as other anchors) are used. After getting five buffers with animation data, the combiner combines them into one and outputs as the resulting buffer that can be set to mesh.
  • buffer — the output buffer with combined animations.
  • output — the final combiner node output.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the third animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • out 3 — exit to the fourth animation to set.
  • buf 3 — input buffer from the fourth set animation.
  • in 3 — input after the fourth animation was set.
  • out 4 — exit to the fifth animation to set.
  • buf 4 — input buffer from the fifth set animation.
  • in 4 — input after the fifth animation was set.
skinner.difference Calculates the difference between the reference frame of the loaded animation and all other frames in this animation. It calculates the difference in bone transformations for each frame of the played animation relative, for example, the bind pose (0 frame). After that, this data is output to the buffer and can be added to another animation, for example, to combine breathing animation (calculated via difference) with other animation that contains torso movement.
  • buffer — output buffer with animation data calculated relative to the reference frame.
  • output — the final node output.
  • name — name of the loaded animation.
  • reference (0.0f) — reference from the loaded animation. The default is a bind pose (0 frame). If the value is non-integer, the reference animation frame is interpolated between the loaded frames.
  • time (at the left) — the frame (in the "from-to" interval) to start animation playback from.
    • 0 means the from frame. This is the default value.
    • If the larger value is provided outside from "from-to" interval, the corresponding frame of looped animation is set.
    • If a float argument is passed, the animation is interpolated between nearby frames.
    • If a negative value is provided, interpolation will be done from the current frame to the from frame.
  • speed — speed of animation playback (in frames per second).
  • from — the starting frame number. The default -1 means the first frame from the animation file.
  • to — the ending frame number. The default -1 means the last frame from the animation file.
  • frames — the total number of frames in the animation file.
  • time (at the right) — the current frame in the animation playback.
skinner.get Creates the buffer out of the skinned animation frame that is currently played. It is used for blending between skinned and ragdoll animation. This node should be connected to the node that sets animation onto the mesh, frame-based or ragdoll one. Usually, it is connected through a number of nodes that set animation buffers to skinner.set at the end of the graph branch.
  • output (at the left) — the output after the get block has finished its work.
  • output (at the right) — the immediate output.
  • buffer — the output buffer with stored animation data.
  • input — input after the immediate output exit.
skinner.inverse Inverts the animation. This node should be connected to another skinner node that sets data into animation buffer (for example, skinner.animation node). The animation loop exits on right output, enters another skinner node and returns from it on the right input. The buffer from a skinner node enters into right buffer.
The block works according tho the following formula:
Source code (UnigineScript)
pos = -src_pos;
rot = inverse(src_rot)(-src_rot);
scale = 1.0/src_scale;
  • output (at the right) — the immediate output.
  • buffer (at the right) — the input buffer with stored animation data.
  • input (at the right) — input used after the immediate output exit.
  • output (at the left) — the output after the Get block has finished its work.
  • buffer (at the left) — the output buffer with inversed animation.
skinner.lerp Linear interpolation between two animations in the required proportion.
This node should be connected to two skinner nodes that set data into animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the interpolator. The second animation loop is the same, except that out 1, in 1 and buf 1 are used. After getting two buffers with animation data, the interpolator interpolates them into one and outputs as the resulting buffer.
  • buffer — output buffer with the interpolated animation.
  • output (at the left) — the output after the interpolator has finished its work.
  • weight — the weight for interpolating animations in range [0;1]:
    • By the value of 0, only the first animation is used.
    • By the value of 0.5 (by default), both animations are used.
    • By the value of 1, only the second animation is used.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
skinner.lerp3 Linear interpolation between three animations in the required proportion.
This node should be connected to three skinner nodes that set data into animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the interpolator. Other animation loops are the same, except that out 1, and out 2 (as well as other anchors) are used. After getting three buffers with animation data, the interpolator interpolates them into one and outputs as the resulting buffer.
  • buffer — output buffer with the interpolated animation.
  • output (at the left) — the output after the interpolator has finished its work.
  • weight — the weight for interpolating animations in range [0;1]:
    • By the value of 0, only the first animation is used.
    • By the value of 0.5 (by default), only the second animation is used.
    • By the value of 1, only the third animation is used.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
skinner.lookat Allows for the head direction control. For example, it can be used to control in at what point in 3D space the character looks.
This node should be connected to a skinner node that sets data into the animation buffer (for example, skinner.animation nodes). The animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a skinner node enters into buf 0 of the Lookat node.
  • buffer — output buffer with the controlled animation.
  • output (at the left) — output after the Lookat node has finished its work.
  • bone — bone (only one bone should be used per one Lookat node). It can be set via skinner.bone.
  • pos — point to look at. By default it is the origin of world coordinates.
  • speed — speed of the head movement to the specified position. The default is 360 degrees per second.
  • min x — the maximum rotation along the X-axis (to the character left). The default is -90 degrees.
  • min y — the maximum rotation along the Y-axis (upwards). The default is -90 degrees.
  • max x — the maximum rotation along the X-axis (to the character right). The default is 90 degrees.
  • max x — the maximum rotation along the X-axis (downwards). The default is 90 degrees.
  • output — exit to the animation loop.
  • buffer — input buffer from the set animation.
  • input — input after the animation was set.
skinner.ragdoll Enables physics-driven ragdoll ("death") animation for the skinned mesh. It can be set either for the whole mesh (if no bone is specified) or for a separate bone.
  • enables0 for disabling a ragdoll, 1 for enabling it.
  • bone — a bone to be physics-driven (only one bone should be used). It can be set via skinner.bone.
skinner.rotation Rotates the bone along a specified axis by the given angle.
This node should be connected to a skinner node that sets data into the animation buffer (for example, skinner.animation nodes). The animation loop exits on the right output, enters another skinner node and returns from it on the right input. The buffer from a skinner node enters into right buffer of the Lookat node.
  • buffer (at the left) — output animation buffer with a rotated bone.
  • output (at the left) — the output after the Rotation node has finished its work.
  • bone — a bone to be rotated (only one bone should be used). It can be set via skinner.bone.
  • axis — axis to rotate the bone around. By default it is vec3(0,0,1), i.e. rotate around the Z-axis.
  • angle — angle of rotation. By default it is 0, i.e. no rotation.
  • output (at the right) — exit to the animation loop.
  • buffer — input buffer from the set animation.
  • input — input after the animation was set.
skinner.sequence Loads the animation and sets it to the animation buffer. This animation is played only once when the node is triggered via the play input. When the animation playback is almost over, the sequencer triggers the next following node connected via the stop output. After that, it plays the animation to its end. stop output should always return to the right input (after passing other nodes, if necessary) for the sequencer to work properly.
  • buffer — output animation buffer with the loaded animation.
  • output (at the left) — output used for creating an animation loop (set the animation to another node).
  • name — name of the animation file to be loaded. It can be set via schemer.file.
  • threshold — the time (in seconds) before the playback end to trigger stop output. The default is one second.
  • speed — speed of animation playback.
  • from — the starting frame number for animation playback. The default -1 means the first frame from the animation file.
  • to — the ending frame number for animation playback. The default -1 means the last frame from the animation file.
  • stop — the output triggered when threshold time is left before the animation stops completely. This output should always be connected to the right input.
  • input (at the right) — the input after stop output was used.
  • frames — the total number of frames in the animation file.
  • weight — coefficient in range [0;1] that indicates the stop progress for the animation during the threshold time interval at the end:
    • The value of 0 is returned when the animation is played, up to the moment when it reaches the stop point.
    • The value of 1 is returned when the animation playback has stopped completely.
  • play — the input that triggers the animation playback.
  • output (at the bottom)— the output used when the animation has played to the end (unlike the stop output triggered before the animation has actually stopped).
skinner.set Sets the animation to the mesh and plays it. This node should be connected to another node that loads the animation from a file and sets data into animation buffer (for example, skinner.animation nodes). The animation loop exits on the right output, enters another skinner node and returns from it on the right input. The animation data from a Skinner node enters into buffer.
  • output (at the left) — output used after the Set node has finished its work.
  • input (at the right) — input on return from the animation loop.
  • buffer — input buffer with animation data to be rendered.
skinner.smooth Allows for smooth change of value according to the current framerate. This block is used to avoid unnecessary spikes when calculating animation parameters. It calculates the change in parameter value (delta) and limits it by "values per second".
  • value (at the left) — input value to be smoothed.
  • speed — speed of smoothing the value.
    • The default is 1 value per second.
    • The higher the value, the faster the value is smoothed.
  • min — minimum possible value to use. If the input value is lower, it will be clamped to this one. The default is 0.
  • max — maximum possible value to use. If the input value is higher, it will be clamped to this one. The default is 1.
  • output — output used after the Set node has finished its work.
  • value (at the right) — output smoothed value.
skinner.sub Subtracts the second animation from the first one.
The subtractor should be connected to two skinner nodes that set data into two animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the blender. The second animation loop is the same, except that out 1, in 1 and buf 1 are used. After getting two buffers with animation data, the subtractor subtracts the first one from the second one and outputs the result into buffer.
  • buffer — output buffer with subtracted animation data.
  • output — output used after the subtractor has finished its work.
  • weight — the weight for interpolating animations in range [0;1]:
    • By the value of 0, only the first animation is used.
    • By the value of 1 (by default), the result is equal to the first animation minus the second one.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
skinner.switch Allows for switching between two different animations depending on the trigger value. If the trigger value is equal to 0, the first animation is played. If it is equal to 1, the second animation is chosen. When the trigger indicates that transition between animation states should be done, animations are smoothly interpolated. Blending into the new animation state is performed with given speed. A switcher can be used, for example, to switch between file-based animation and a physical-driven ragdoll.
The switcher should be connected to two skinner nodes that set data into two animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the switcher. The second animation loop is the same, except that out 1, in 1 and buf 1 are used. After getting two buffers with animation data, the switcher chooses the animation to be output or blends animations together in necessary proportion and outputs the result into buffer.
  • buffer — output buffer with the animation data.
  • output — output used after the switcher has finished its work.
  • value — trigger value to switch between animations in range [0;1]:
    • By the value of 0 (by default), only the first animation is played.
    • By the value of 1, only the second animation is played.
    • Values between 0 and 1 indicate transition between animation states.
  • speed — speed of transition between animation states.
    • The default is 1 weight value per second.
    • The higher the value, the faster the transition between animation states is.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • weight 0 — the current weight for interpolation state of the first animation in range [0;1]:
    • The value of 0 indicates that the first animation is not used.
    • The value of 1 indicates that the first animation is used in full.
  • weight 1 — the current weight for interpolation state of the second animation in range [0;1]:
    • The value of 0 indicates that the second animation is not used.
    • The value of 1 indicates that the second animation is used in full.
skinner.switch3 Allows for switching between three different animations depending on the trigger value. If the trigger value is equal to 0, the first animation is played. If it is equal to 1, the second animation is chosen. If it is 2, the third one is played. When the trigger indicates that transition between animation states should be done, animations are smoothly interpolated. Blending into the new animation state is performed with given speed.
The switcher should be connected to three skinner nodes that set data into three animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the switcher. Other animation loops are the same, except that out 1 and out 2 (and other anchors) are used. After getting three buffers with animation data, the switcher chooses the animation to be output or blends animations together in necessary proportion and outputs the result into buffer.
  • buffer — output buffer with the animation data.
  • output — output used after the switcher has finished its work.
  • value — trigger value to switch between animations in range [0;1]:
    • By the value of 0 (by default), only the first animation is used.
    • By the value of 1, only the second animation is used.
    • By the value of 2, only the third animation is used.
    • Values in range (0;1) and (1;2) indicate transition between animation states.
  • speed — speed of transition between animation states.
    • The default is 1 weight value per second.
    • The higher the value, the faster the transition between animation states is.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • weight 0 — the current weight for interpolation state of the first animation in range [0;1]:
    • The value of 0 indicates that the first animation is not used.
    • The value of 1 indicates that the first animation is used in full.
  • weight 1 — the current weight for interpolation state of the second animation in range [0;1]:
    • The value of 0 indicates that the second animation is not used.
    • The value of 1 indicates that the second animation is used in full.
  • weight 2 — the current weight for interpolation state of the third animation in range [0;1]:
    • The value of 0 indicates that the third animation is not used.
    • The value of 1 indicates that the third animation is used in full.
skinner.switch4 Allows for switching between four different animations depending on the trigger value. If the trigger value is equal to 0, the first animation is played. If it is equal to 1, the second animation is chosen, etc. When the trigger indicates that transition between animation states should be done, animations are smoothly interpolated. Blending into the new animation state is performed with given speed.
The switcher should be connected to four skinner nodes that set data into four animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the switcher. Other animation loops are the same, except that out 1, out 2 and out 3 (and other anchors) are used. After getting four buffers with animation data, the switcher chooses the animation to be output or blends animations together in necessary proportion and outputs the result into buffer.
  • buffer — output buffer with the animation data.
  • output — output used after the switcher has finished its work.
  • value — trigger value to switch between animations in range [0;1]:
    • By the value of 0 (by default), only the first animation is used.
    • By the value of 1, only the second animation is used.
    • By the value of 2, only the third animation is used.
    • By the value of 3, only the fourth animation is used.
    • Values in range (0;1), (1;2) and (2;3) indicate transition between animation states.
  • speed — speed of transition between animation states.
    • The default is 1 weight value per second.
    • The higher the value, the faster the transition between animation states is.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • out 3 — exit to the fourth animation to set.
  • buf 3 — input buffer from the fourth set animation.
  • in 3 — input after the fourth animation was set.
  • weight 0 — the current weight for interpolation state of the first animation in range [0;1]:
    • The value of 0 indicates that the first animation is not used.
    • The value of 1 indicates that the first animation is used in full.
  • weight 1 — the current weight for interpolation state of the second animation in range [0;1]:
    • The value of 0 indicates that the second animation is not used.
    • The value of 1 indicates that the second animation is used in full.
  • weight 2 — the current weight for interpolation state of the third animation in range [0;1]:
    • The value of 0 indicates that the third animation is not used.
    • The value of 1 indicates that the third animation is used in full.
  • weight 3 — the current weight for interpolation state of the fourth animation in range [0;1]:
    • The value of 0 indicates that the fourth animation is not used.
    • The value of 1 indicates that the fourth animation is used in full.
skinner.switch5 Allows for switching between five different animations depending on the trigger value. If the trigger value is equal to 0, the first animation is played. If it is equal to 1, the second animation is chosen, etc. When the trigger indicates that transition between animation states should be done, animations are smoothly interpolated. Blending into the new animation state is performed with given speed.
The switcher should be connected to five skinner nodes that set data into five animation buffers (for example, skinner.animation nodes). The first animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from a Skinner node enters into buf 0 of the switcher. Other animation loops are the same, except that out 1, out 2, out 3 and out 4 (and other anchors) are used. After getting five buffers with animation data, the switcher chooses the animation to be output or blends animations together in necessary proportion and outputs the result into buffer.
  • buffer — output buffer with the animation data.
  • output — output used after the switcher has finished its work.
  • value — trigger value to switch between animations in range [0;1]:
    • By the value of 0 (by default), only the first animation is used.
    • By the value of 1, only the second animation is used.
    • By the value of 2, only the third animation is used.
    • By the value of 3, only the fourth animation is used.
    • By the value of 4, only the fifth animation is used.
    • Values in range (0;1), (1;2), (2;3) and (3;4) indicate transition between animation states.
  • speed — speed of transition between animation states.
    • The default is 1 weight value per second.
    • The higher the value, the faster the transition between animation states is.
  • out 0 — exit to the first animation to set.
  • buf 0 — input buffer from the first set animation.
  • in 0 — input after the first animation was set.
  • out 1 — exit to the second animation to set.
  • buf 1 — input buffer from the second set animation.
  • in 1 — input after the second animation was set.
  • out 2 — exit to the third animation to set.
  • buf 2 — input buffer from the third set animation.
  • in 2 — input after the third animation was set.
  • out 3 — exit to the fourth animation to set.
  • buf 3 — input buffer from the fourth set animation.
  • in 3 — input after the fourth animation was set.
  • out 4 — exit to the fifth animation to set.
  • buf 4 — input buffer from the fifth set animation.
  • in 4 — input after the fifth animation was set.
  • weight 0 — the current weight for interpolation state of the first animation in range [0;1]:
    • The value of 0 indicates that the first animation is not used.
    • The value of 1 indicates that the first animation is used in full.
  • weight 1 — the current weight for interpolation state of the second animation in range [0;1]:
    • The value of 0 indicates that the second animation is not used.
    • The value of 1 indicates that the second animation is used in full.
  • weight 2 — the current weight for interpolation state of the third animation in range [0;1]:
    • The value of 0 indicates that the third animation is not used.
    • The value of 1 indicates that the third animation is used in full.
  • weight 3 — the current weight for interpolation state of the fourth animation in range [0;1]:
    • The value of 0 indicates that the fourth animation is not used.
    • The value of 1 indicates that the fourth animation is used in full.
  • weight 4 — the current weight for interpolation state of the fifth animation in range [0;1]:
    • The value of 0 indicates that the fifth animation is not used.
    • The value of 1 indicates that the fifth animation is used in full.
skinner.transform Allows setting a custom transformation to the bone, for example, to rotate it and output the whole animation buffer with transformed node. As the input value, this nodes receives a matrix.
The transformer should be connected to a skinner node that sets data into an animation buffer of the transformer (for example, skinner.animation node). The animation loop exits on out 0, enters another skinner node and returns from it on in 0. The buffer from it enters into buf 0 of the transformer. After that, it can transform the specified bone and output the result with the rest of animation data as a modified buffer.
  • buffer — output buffer with modified animation data.
  • output (at the left) — output used after the node has finished its work.
  • bone — bone to be transformed (only one bone should be used per one node). It can be set via skinner.bone.
  • value — transformation matrix (mat4).

How to Run Skinner Script

To initialize the Skinner (here, without the visual editor), you need to add the code as in the following example. First of all, a mesh to be controlled by the Skinner is specified. After that, similar to running a Schemer, you need to call update() function. However, it must be called from within world script update() and this function requires to be passed the inverse FPS value to play animations. Update function will trigger execution of all nodes in the Skinner graph one by one starting from the schemer.entry named update and further in the specified order.

Source code (UnigineScript)
#include <core/scripts/utils.h>
#include <core/systems/skinner/skinner.h>
#include <samples/common/common.h>

Unigine::Skinner::Skinner skinner;
Unigine::Skinner::SkinnerMesh skinner_mesh;
/*
 */
int init() {

	// Use Skinner namespace.
	using Unigine::Skinner;
	
	// Load the skinned mesh and add it into the editor.
	ObjectMeshSkinned mesh = add_editor(node_load("samples/skinner/meshes/agent.node"));

	// Create a Skinner.
	skinner = new Skinner();
	
	// Create SkinnerMesh that will manage the executable script compiled from a graph.
	skinner_mesh = new SkinnerMesh(skinner,mesh);
	
	// Load a graph that scripts character behavior.
	skinner_mesh.loadScript("samples/skinner/scripts/agent_00.script");

	return 1;
}

int update() {

	float ifps = engine.game.getIFps();
	
	// Update Skinner mesh.
	skinner_mesh.update(ifps);

	return 1;
}

In case of using ragdolls, render() function of the world script instead of update() can be used as a starting point for a graph. It will allow to get animations transformation in the current frame and use this data to simulate physics-driven ragdoll. (See details on render().) In this case, schemer.entry named render.

Source code (UnigineScript)
int render() {
	
	float ifps = engine.game.getIFps();
	// Run the Skinner graph script from "render" entry.
	skinner_mesh.render(ifps);
	}
	
	return 1;
}

How to Run Event

To create a one-time action, you can call event() function of the Skinner (found in data/core/systems/skinner/skinner_mesh.h). It will simply call an update function for Skinner script created from a graph with the passed name.

Source code (UnigineScript)
int id = skinner_mesh.getEventID(entry_name);
skinner_mesh.event(id);
Last update: 2017-07-03