From d6b4d9551fa791f93650b136e9ed69d7b2e37cb6 Mon Sep 17 00:00:00 2001 From: Ali-RS Date: Sat, 12 Oct 2019 19:00:55 +0330 Subject: [PATCH] AnimComposer: added getTime() and setTime() methods Resolves #1200 --- .../main/java/com/jme3/anim/AnimComposer.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java b/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java index d997ab39d1..b8ac76668f 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java +++ b/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java @@ -104,6 +104,36 @@ public void removeCurrentAction(String layerName) { l.time = 0; l.currentAction = null; } + + /** + * Returns current time of the specified layer. + */ + public double getTime(String layerName) { + Layer l = layers.get(layerName); + if (l == null) { + throw new IllegalArgumentException("Unknown layer " + layerName); + } + return l.time; + } + + /** + * Sets current time on the specified layer. + */ + public void setTime(String layerName, double time) { + Layer l = layers.get(layerName); + if (l == null) { + throw new IllegalArgumentException("Unknown layer " + layerName); + } + if (l.currentAction == null) { + throw new RuntimeException("There is no action running in layer " + layerName); + } + double length = l.currentAction.getLength(); + if (time >= 0) { + l.time = time % length; + } else { + l.time = time % length + length; + } + } /** *