From 60abc9363880511e00b28e1deb19f660458efe03 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 1 Feb 2007 20:03:00 +0000 Subject: [PATCH] Specify the default repeat type as a parameter; model animations should not loop by default. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@138 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../com/threerings/jme/model/TextureAnimator.java | 3 ++- src/java/com/threerings/jme/tools/AnimationDef.java | 3 ++- src/java/com/threerings/jme/util/JmeUtil.java | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/jme/model/TextureAnimator.java b/src/java/com/threerings/jme/model/TextureAnimator.java index 036352ae..68d6bb95 100644 --- a/src/java/com/threerings/jme/model/TextureAnimator.java +++ b/src/java/com/threerings/jme/model/TextureAnimator.java @@ -55,7 +55,8 @@ public class TextureAnimator extends TextureController _frameHeight = Float.valueOf(props.getProperty("frame_height", "0.5")); _frameCount = Integer.valueOf(props.getProperty("frame_count", "4")); _frameRate = Float.valueOf(props.getProperty("frame_rate", "1")); - _repeatType = JmeUtil.parseRepeatType(props.getProperty("repeat_type")); + _repeatType = JmeUtil.parseRepeatType(props.getProperty("repeat_type"), + Controller.RT_WRAP); } // documentation inherited diff --git a/src/java/com/threerings/jme/tools/AnimationDef.java b/src/java/com/threerings/jme/tools/AnimationDef.java index a096de44..f686642b 100644 --- a/src/java/com/threerings/jme/tools/AnimationDef.java +++ b/src/java/com/threerings/jme/tools/AnimationDef.java @@ -145,7 +145,8 @@ public class AnimationDef // create and configure the animation Model.Animation anim = new Model.Animation(); anim.frameRate = frameRate; - anim.repeatType = JmeUtil.parseRepeatType(props.getProperty("repeat_type")); + anim.repeatType = JmeUtil.parseRepeatType(props.getProperty("repeat_type"), + Controller.RT_CLAMP); // collect all transforms anim.transformTargets = targets.toArray(new Spatial[targets.size()]); diff --git a/src/java/com/threerings/jme/util/JmeUtil.java b/src/java/com/threerings/jme/util/JmeUtil.java index cbac38d0..51503f34 100644 --- a/src/java/com/threerings/jme/util/JmeUtil.java +++ b/src/java/com/threerings/jme/util/JmeUtil.java @@ -109,19 +109,20 @@ public class JmeUtil /** * Attempts to parse a string describing one of the repeat types defined in {@link Controller}: - * "clamp", "cycle", or "wrap". Will return {@link Controller#RT_WRAP} if the type is + * "clamp", "cycle", or "wrap". Will return the specified default if the type is * null or invalid. */ - public static int parseRepeatType (String type) + public static int parseRepeatType (String type, int defaultType) { if ("clamp".equals(type)) { return Controller.RT_CLAMP; } else if ("cycle".equals(type)) { return Controller.RT_CYCLE; - } - if (type != null && !"wrap".equals(type)) { + } else if ("wrap".equals(type)) { + return Controller.RT_WRAP; + } else if (type != null) { Log.warning("Invalid repeat type [type=" + type + "]."); } - return Controller.RT_WRAP; + return defaultType; } }