Added a translation controller.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@139 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Andrzej Kapolka
2007-02-01 21:54:53 +00:00
parent 60abc93638
commit 7f36e60353
2 changed files with 159 additions and 12 deletions
+25 -12
View File
@@ -88,25 +88,38 @@ public class JmeUtil
*/
public static Vector3f parseAxis (String axis)
{
if (axis == null) {
return null;
}
if (axis.equalsIgnoreCase("x")) {
if ("x".equalsIgnoreCase(axis)) {
return Vector3f.UNIT_X;
} else if (axis.equalsIgnoreCase("y")) {
} else if ("y".equalsIgnoreCase(axis)) {
return Vector3f.UNIT_Y;
} else if (axis.equalsIgnoreCase("z")) {
} else if ("z".equalsIgnoreCase(axis)) {
return Vector3f.UNIT_Z;
}
float[] vals = StringUtil.parseFloatArray(axis);
if (vals != null && vals.length == 3) {
return new Vector3f(vals[0], vals[1], vals[2]).normalizeLocal();
} else {
Log.warning("Invalid axis [axis=" + axis + "].");
return null;
Vector3f vector = parseVector3f(axis);
if (vector != null) {
vector.normalizeLocal();
}
return vector;
}
}
/**
* Attempts to parse a string containing three comma-delimited values and return a
* {@link Vector3f}.
*/
public static Vector3f parseVector3f (String vector)
{
if (vector != null) {
float[] vals = StringUtil.parseFloatArray(vector);
if (vals != null && vals.length == 3) {
return new Vector3f(vals[0], vals[1], vals[2]);
} else {
Log.warning("Invalid vector [vector=" + vector + "].");
}
}
return null;
}
/**
* Attempts to parse a string describing one of the repeat types defined in {@link Controller}:
* "clamp", "cycle", or "wrap". Will return the specified default if the type is