Setting Animations with code

I don’t really know what to call this post, but here it goes; so recently I have been going into csgo’s code and stuff like that when I noticed that the view models don’t really have a hand mesh, just a skeleton. Each faction of CTs and Ts in csgo has their own hand models. So I’m assuming that they attached their hand meshes to the skeleton at run time.

Is there a way to do that in jme? To attach a mesh to the skeleton and have the mesh play the animations of the skeleton?

Hi, our paperdoll models in Project Aleron use the same technique.

Our method is:
In Blender, create your base hand mesh including your skeleton.
When creating different hand meshes, always copy this base, so the skeletons bones have exactly the same name and structure.

For the gun you copy the base hand mesh+skeleton.
Here you add the gun and position it in the hand, then delete the hand, but keep the skeleton.

The results should now be:

  • Each Hand .blend file contains a hand mesh and the skeleton
  • Each gun contains the gun model and the skeleton
  • All animations should be applied to the gun’s skeleton (hand doesn’t need a single animation)

Now when you import the hand models, remove the skeleton via code and attach the gun’s skeleton to it. It will map perfectly, because the skeleton’s were identical.

Our main character node only has a skeleton and eyes (because they are only retextured)
The body parts are meshes which are imported with this exact method.

Remember that you only have to apply the animations to the “real” skeleton (gun in your case).
The hand skeletons are only used for mapping.

Thanks I’ll try that by the way is there a way to assign an object to just 1 bone instead of the entire skeleton?

You can attach a static object to a single bone.

What you do for this, is to generate an attachNode for a bone.

Here’s our code snippet for that task. We only use it for the hands (weapons)

private Node getAttachNode(PaperdollSlot slot) {
    SkeletonControl skeletonControl = getMainSkeletonControl();
    if (slot == PaperdollSlot.RIGHT_HAND) {
        return skeletonControl.getAttachmentsNode(RIGHT_HAND_BONE_NAME);
    } else if (slot == PaperdollSlot.LEFT_HAND) {
        return skeletonControl.getAttachmentsNode(LEFT_HAND_BONE_NAME);
    } else {
        throw new IllegalArgumentException("Requested other Attachnode than " + LEFT_HAND_BONE_NAME + " or " + RIGHT_HAND_BONE_NAME);