@Override public void reset () { idt(); }
/** Helper method to apply one animation to either an objectmap for blending or directly to the bones. */ protected static void applyAnimation (final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final Animation animation, final float time) { if (out == null) { for (final NodeAnimation nodeAnim : animation.nodeAnimations) applyNodeAnimationDirectly(nodeAnim, time); } else { for (final Node node : out.keys()) node.isAnimated = false; for (final NodeAnimation nodeAnim : animation.nodeAnimations) applyNodeAnimationBlending(nodeAnim, out, pool, alpha, time); for (final ObjectMap.Entry<Node, Transform> e : out.entries()) { if (!e.key.isAnimated) { e.key.isAnimated = true; e.value.lerp(e.key.translation, e.key.rotation, e.key.scale, alpha); } } } }
private final static void applyNodeAnimationDirectly (final NodeAnimation nodeAnim, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); transform.toMatrix4(node.localTransform); }
private final static void applyNodeAnimationBlending (final NodeAnimation nodeAnim, final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); Transform t = out.get(node, null); if (t != null) { if (alpha > 0.999999f) t.set(transform); else t.lerp(transform, alpha); } else { if (alpha > 0.999999f) out.put(node, pool.obtain().set(transform)); else out.put(node, pool.obtain().set(node.translation, node.rotation, node.scale).lerp(transform, alpha)); } }
public Transform set (final Transform other) { return set(other.translation, other.rotation, other.scale); }
public Transform lerp (final Transform target, final float alpha) { return lerp(target.translation, target.rotation, target.scale, alpha); }
/** End applying multiple animations to the instance and update it to reflect the changes. */ protected void end () { if (!applying) throw new GdxRuntimeException("You must call begin() first"); for (Entry<Node, Transform> entry : transforms.entries()) { entry.value.toMatrix4(entry.key.localTransform); transformPool.free(entry.value); } transforms.clear(); target.calculateTransforms(); applying = false; }
@Override protected Transform newObject () { return new Transform(); } };
if (Gdx.input.isKeyPressed(Keys.UP)) { if (!animation.inAction) { trTmp.idt().lerp(trForward, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); trTmp.idt().lerp(trBackward, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); trTmp.idt().lerp(trRight, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } else if (Gdx.input.isKeyPressed(Keys.LEFT) && (status == walk || status == back) && !animation.inAction) { trTmp.idt().lerp(trLeft, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix));
/** Helper method to apply one animation to either an objectmap for blending or directly to the bones. */ protected static void applyAnimation (final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final Animation animation, final float time) { if (out == null) { for (final NodeAnimation nodeAnim : animation.nodeAnimations) applyNodeAnimationDirectly(nodeAnim, time); } else { for (final Node node : out.keys()) node.isAnimated = false; for (final NodeAnimation nodeAnim : animation.nodeAnimations) applyNodeAnimationBlending(nodeAnim, out, pool, alpha, time); for (final ObjectMap.Entry<Node, Transform> e : out.entries()) { if (!e.key.isAnimated) { e.key.isAnimated = true; e.value.lerp(e.key.translation, e.key.rotation, e.key.scale, alpha); } } } }
private final static void applyNodeAnimationBlending (final NodeAnimation nodeAnim, final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); Transform t = out.get(node, null); if (t != null) { if (alpha > 0.999999f) t.set(transform); else t.lerp(transform, alpha); } else { if (alpha > 0.999999f) out.put(node, pool.obtain().set(transform)); else out.put(node, pool.obtain().set(node.translation, node.rotation, node.scale).lerp(transform, alpha)); } }
private final static void applyNodeAnimationBlending (final NodeAnimation nodeAnim, final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); Transform t = out.get(node, null); if (t != null) { if (alpha > 0.999999f) t.set(transform); else t.lerp(transform, alpha); } else { if (alpha > 0.999999f) out.put(node, pool.obtain().set(transform)); else out.put(node, pool.obtain().set(node.translation, node.rotation, node.scale).lerp(transform, alpha)); } }
/** Helper method to apply one animation to either an objectmap for blending or directly to the bones. */ protected static void applyAnimation (final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final Animation animation, final float time) { if (out == null) { for (final NodeAnimation nodeAnim : animation.nodeAnimations) applyNodeAnimationDirectly(nodeAnim, time); } else { for (final Node node : out.keys()) node.isAnimated = false; for (final NodeAnimation nodeAnim : animation.nodeAnimations) applyNodeAnimationBlending(nodeAnim, out, pool, alpha, time); for (final ObjectMap.Entry<Node, Transform> e : out.entries()) { if (!e.key.isAnimated) { e.key.isAnimated = true; e.value.lerp(e.key.translation, e.key.rotation, e.key.scale, alpha); } } } }
public Transform lerp (final Transform target, final float alpha) { return lerp(target.translation, target.rotation, target.scale, alpha); }
public Transform set (final Transform other) { return set(other.translation, other.rotation, other.scale); }
public Transform lerp (final Transform target, final float alpha) { return lerp(target.translation, target.rotation, target.scale, alpha); }
@Override public void reset () { idt(); }
public Transform set (final Transform other) { return set(other.translation, other.rotation, other.scale); }
private final static void applyNodeAnimationDirectly (final NodeAnimation nodeAnim, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); transform.toMatrix4(node.localTransform); }
@Override protected Transform newObject () { return new Transform(); } };