Class Animator

java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.armature.Animator

public final class Animator extends Object
Everything one armature-driven thing is doing: its animation layers, procedural motion, joint styles and Molang variables. Every entity, block entity and item stack drawn with an armature has its own, made the first time it is drawn and set up by its renderer.
animator.layer("base").drive(ctx -> ctx.moving() ? WALK : IDLE);
animator.layer("action", l -> l.mask(JointMask.of("body")));
animator.lookAt("head");
animator.spring("tail").damping(6);
animator.onEvent(event -> { if (event.effect().equals("stomp")) shakeCamera(); });
animator.hide("saddle");
Only play(Motion) and layer(String) are needed for the simplest setups: a layer named "base" is made when first asked for, and play uses it.
  • Field Details

  • Constructor Details

  • Method Details

    • armature

      public Armature armature()
    • context

      public ArmatureContext context()
    • layer

      public AnimLayer layer(String name)
      A layer by name, made (on top of the others) if there is none yet.
    • layer

      public AnimLayer layer(String name, Consumer<AnimLayer> setup)
      A layer, set up by setup only when it is first made.
    • findLayer

      @Nullable public @Nullable AnimLayer findLayer(String name)
    • layers

      public List<AnimLayer> layers()
      Every layer, bottom first.
    • play

      public Animator play(Motion motion)
      Plays a motion on the "base" layer.
    • play

      public Animator play(String layer, Motion motion)
    • transition

      public Animator transition(Transition transition)
      How animations blend into each other on layers that set no transition of their own.
    • transitions

      public Animator transitions(boolean enabled)
      Turns blending on or off for every layer at once: off, every change cuts. On by default.
    • transitionsEnabled

      public boolean transitionsEnabled()
    • stop

      public Animator stop(String layer)
    • isPlaying

      public boolean isPlaying(String clip)
      Whether any layer is playing this clip.
    • lookAt

      public LookAt lookAt(String joint)
      Turns a joint toward where the entity looks (or the nearest player); made once, then the same one is returned.
    • spring

      public Spring spring(String joint)
      Makes a joint swing on a spring; made once, then the same one is returned.
    • prop

      public Animator prop(ObjProp prop)
      Carries an .obj model on a joint or point, as well as the ones its .armature.json gives.
    • removeProp

      public Animator removeProp(ObjProp prop)
    • trail

      public ArmatureTrail trail(String point)
      A glowing trail behind a point; made once, then the same one is returned.
    • emitter

      public ArmatureEmitter emitter(String point, ParticleSpec spec)
      Effect particles pouring from a point. Several can share a point.
    • modify

      public Animator modify(JointModifier modifier)
      Runs code on the pose every frame, after the layers and head tracking.
    • onEvent

      public Animator onEvent(ArmatureEvent.Listener listener)
      Gets every sound, particle and instruction keyframe as it plays.
    • builtInEffects

      public Animator builtInEffects(boolean play)
      Whether sound and particle keyframes play by themselves (they do unless turned off here).
    • hide

      public Animator hide(String joint)
      Hides a joint and everything on it until show(String)n.
    • show

      public Animator show(String joint)
    • setVisible

      public Animator setVisible(String joint, boolean visible)
    • tint

      public Animator tint(String joint, int argb)
      Multiplies a joint's colour (and its children's) by an ARGB colour; white clears it.
    • glow

      public Animator glow(String joint, boolean glow)
      Draws a joint and its children at full brightness, whatever the light.
    • variable

      public double variable(String name)
    • setVariable

      public Animator setVariable(String name, double value)
    • pose

      @Nullable public @Nullable ArmaturePose pose()
      The pose last worked out (what the layers, head tracking and modifiers made), or null before the first update.
    • frame

      @Nullable public @Nullable ArmatureFrame frame()
      The frame last worked out, or null before the first update.
    • update

      public ArmatureFrame update(double clock, float partialTick, org.joml.Matrix4fc modelToWorld)
      Moves everything on to a moment and poses the armature. Renderers call this each frame; call it yourself only to draw an armature somewhere CoolCatLib's renderers don't reach.
      Parameters:
      clock - seconds on any clock that only goes forward (GameClock-like); the first call starts it
      modelToWorld - from model pixels to the world, in blocks, for springs, head tracking and particles