SkeletonControl or AnimControl to host skeleton

  1. For a skeleton loader i’m working on, I would like to know where to store Skeleton in SkeletonControl or AnimControl ?
  2. From where to search the skeleton of a spatial ?
  3. What is deprecated ?

Thanks for any info

  1. both need a reference to it. To the SAME reference Skeleton.
  2. in the its SkeletonControl or its AnimControl
  3. uh…everything marked as such. What do you mean?
  1. So to add/remove skeleton, I should add/remove both control, each time ?
  2. when I search in the forum deprecated was used about AnimControl(Skeleton), but nothing in the javadoc (but some in source) => confusion

like the following ?

    public void link(Spatial v, Skeleton sk) {
        v.removeControl(AnimControl.class);
        v.removeControl(SkeletonControl.class);
        v.addControl(new SkeletonControl(sk));
        v.addControl(new AnimControl(sk));
    }
  1. yes, But the skeleton doesn’t really belongs to the model, more to the Controls. and IDK why you’d want to remove it (I mean without removing the controls)
  2. What’s deprecated is the constructor with the array of meshes. Now the skeleton control gathers meshes in the sub graph automatically. use the constructor with the skeleton
  1. to edit skeleton (via blender)

is it better ?

    public void link(Spatial v, Skeleton sk) {
        v.removeControl(SkeletonControl.class);
        v.addControl(new SkeletonControl(sk));
        //update AnimControl if related to skeleton
        AnimControl ac = v.getControl(AnimControl.class);
        if (ac != null && ac.getSkeleton() != null) {
            v.removeControl(ac);
            v.addControl(new AnimControl(sk));
        }
    }

That’s correct, except for one thing: You have to make sure the SkeletonControl is always after the AnimControl in the list.
This is because AnimControl animates the skeleton first, then SkeletonControl will move the model’s vertices according to the animated skeleton.

    public void link(Spatial v, Skeleton sk) {
        v.removeControl(SkeletonControl.class);
        //update AnimControl if related to skeleton
        AnimControl ac = v.getControl(AnimControl.class);
        if (ac != null && ac.getSkeleton() != null) {
            v.removeControl(ac);
            v.addControl(new AnimControl(sk));
        }
        // SkeletonControl should be after AnimControl in the list of Controls
        v.addControl(new SkeletonControl(sk));
    }
1 Like