Some 3D models contain one long animation (like Take 001 which seems to be created by default in 3ds Max), and the 3D artist relies that you split the long animation into smaller animations (more logical to use) on the game engine side.
This example shows how to do it.
We call the smaller animations "subanimations" in this demo, since they are a subrange of some larger animation.
This example defines TSubAnimations behavior class, descendant of TCastleBehavior. This behavior can be added to parent TCastleScene and play subanimations there:
-
Define subanimations using
TSubAnimations.Add. -
Read information about subanimations by
TSubAnimations.List. -
Play the subanimation using
TSubAnimations.Play.
Internally: the playback uses TCastleSceneCore.ForceAnimationPose to update each frame. It is done by TSubAnimations.Update.
Note: Castle Game Engine API of TCastleScene allows you to access the long animation, using TCastleSceneCore.PlayAnimation, TCastleSceneCore.ForceAnimationPose, TCastleSceneCore.AnimationsList. You should not use it directly if you want to use subanimations.
Using Castle Game Engine.
Compile by:
-
CGE editor. Just use menu items "Compile" or "Compile And Run".
-
Or use CGE command-line build tool. Run
castle-engine compilein this directory. -
Or use Lazarus. Open in Lazarus
split_long_animation_standalone.lpifile and compile / run from Lazarus. Make sure to first register CGE Lazarus packages. -
Or use Delphi. Open in Delphi
split_long_animation_standalone.dprojfile and compile / run from Delphi. See CGE and Delphi documentation for details.
