glTF Mixamo armature runtime animate

Hello,

Can animate glTF armature rigs on runtime?

I have this glTF only model and armature there is no animation included.
I am trying change rotation or scale on runtime like that but nothing changed on Scene

TransformNode:=Scene1.RootNode.FindNode('mixamorig:Spine') as TTransformNode;
TransformNode.Scale:=TransformNode.Scale*2;

I can change the rotation or scale on any glTF editor/viewer, example:


My main goal is create complex animations like walk&attack, run&attack

if not possible to edit this kinds TransformNodes on runtime, can we play multiple animation on same mesh? (animations not conflict, one of walk with only legs other one is attack with only hand)

I tried play 2 animation with TTimeSensorNode but always last animation effected my model

This video showing how Unity handle this topic, I am trying did same on Castle Game Engine
Video:Creating Animation Layers and Masks in Unity

Thanks.

1 Like
  1. You can change the transformations at runtime, by finding TTransformNode and setting it’s property like Translation, Rotation, Scale. Just like you show.

    However… it will not work for transformations that perform skinned animation in glTF. Although you can change these transformations, they will not have an effect on the skinned mesh. That’s a consequence of how we currently internally calculate skinned animation in glTF – the skins are actually calculated at loading. Changing the bone transformation at runtime has no effect on the skinned mesh.

    Changing TTransformNode properties for non-skinned animation works OK, but (looking at your description and screenshots) this is not your case.

    I plan to improve it (by calculating skin at runtime using GPU), but we’re not there yet. It would be quite some work, I decided to postpone it after CGE 7.0 release.

  2. You can play 2 animations (2 TimeSensors) simultaneously. See https://castle-engine.io/creating_data_model_formats.php#section_gltf – it links to example on https://github.com/castle-engine/castle-engine/tree/master/examples/animations/simultaneous_animations_one_scene , that uses TTimeSensorNode.Play that can be used to play two animations simultaneously.

    However, in case of skinned animation, playing 2 animations simultaneously that affect the same skin will not yield any useful effect. It’s a consequence of the same problem as above – we have already calculated the skin, and now we just apply it on mesh, it doesn’t help that each animation’s bones affect different parts of the mesh.

In summary: Unfortunately both your issues are blocked by the way we currently implement glTF skinning. In case of glTF skinned animation,

  1. changing transformations from code will not result in any change in the (visible) skinned mesh,
  2. and playing 2 animations simultaneously will not work, the last animation (in glTF file order) will just override the former.

These is no easy workaround for this now. Both these features work OK for non-skinned glTF animations, or any other animations from other formats, but this doesn’t help you.

Proposed solutions (both involve reworking the model significantly, I’m afraid):

  1. Create all the “combined” animations in Blender (or other software where you create your model). I.e. create “run_and_attack” animation, “walk_and_attack” and so on, not just “walk” and “attack” and “run”. I realize that this may be troublesome, as you’ll need much more animations, and the times of many actions (like attack and walk) will have to be synchronized.

  2. If the upper body performs one action (like “attack” or “idle”), and lower body another action (like “walk”, “run”, “idle”) then split them into 2 meshes with 2 separate skeletons. Then you can use the approach from https://github.com/castle-engine/castle-engine/tree/master/examples/animations/simultaneous_animations_one_scene and play 2 animations independently on the same model.

    This requires having a “hard split” between upper body part and lower body part, i.e. a ring of vertexes around the character belt that would not move at all in any animation. I realize that it sucks, it limits what you can do with the animation.

1 Like

Thank you for detailed answer
Solutions 1 is the best way for now

1 Like