|
@@ -4,11 +4,11 @@ import com.jme3.math.FastMath;
|
|
|
import com.jme3.math.Quaternion;
|
|
|
import com.jme3.math.Vector3f;
|
|
|
|
|
|
-// TODO This class has some potential in it... Should investigate
|
|
|
public enum RotationOrder {
|
|
|
|
|
|
EULER_XYZ, EULER_XZY, EULER_YZX, EULER_YXZ, EULER_ZXY, EULER_ZYX, SPHERIC_XYZ;
|
|
|
|
|
|
+ // Static values field for fast access by an oridinal without Enum.values() overhead
|
|
|
public static final RotationOrder[] values = values();
|
|
|
|
|
|
private RotationOrder() {
|
|
@@ -37,63 +37,13 @@ public enum RotationOrder {
|
|
|
case EULER_XZY:
|
|
|
return toQuat(x, Vector3f.UNIT_X, z, Vector3f.UNIT_Z, y, Vector3f.UNIT_Y);
|
|
|
case SPHERIC_XYZ:
|
|
|
+ default:
|
|
|
throw new IllegalArgumentException("Spheric rotation is unsupported in this importer");
|
|
|
}
|
|
|
- /*float c1 = FastMath.cos( x / 2 );
|
|
|
- float c2 = FastMath.cos( y / 2 );
|
|
|
- float c3 = FastMath.cos( z / 2 );
|
|
|
- float s1 = FastMath.sin( x / 2 );
|
|
|
- float s2 = FastMath.sin( y / 2 );
|
|
|
- float s3 = FastMath.sin( z / 2 );
|
|
|
-
|
|
|
- float _x;
|
|
|
- float _y;
|
|
|
- float _z;
|
|
|
- float _w;
|
|
|
-
|
|
|
- switch(order) {
|
|
|
- case EULER_XYZ:
|
|
|
- _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
|
- _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
|
- _z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
|
- _w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
|
- return new Quaternion(_x, _y, _z, _w);
|
|
|
- case EULER_YXZ:
|
|
|
- _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
|
- _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
|
- _z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
|
- _w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
|
- return new Quaternion(_x, _y, _z, _w);
|
|
|
- case EULER_ZXY:
|
|
|
- _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
|
- _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
|
- _z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
|
- _w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
|
- return new Quaternion(_x, _y, _z, _w);
|
|
|
- case EULER_ZYX:
|
|
|
- _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
|
- _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
|
- _z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
|
- _w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
|
- return new Quaternion(_x, _y, _z, _w);
|
|
|
- case EULER_YZX:
|
|
|
- _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
|
- _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
|
- _z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
|
- _w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
|
- return new Quaternion(_x, _y, _z, _w);
|
|
|
- case EULER_XZY:
|
|
|
- _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
|
- _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
|
- _z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
|
- _w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
|
- return new Quaternion(_x, _y, _z, _w);
|
|
|
- }
|
|
|
- */
|
|
|
- throw new AssertionError("Impossible");
|
|
|
}
|
|
|
|
|
|
private static Quaternion toQuat(float ax1v, Vector3f ax1, float ax2v, Vector3f ax2, float ax3v, Vector3f ax3) {
|
|
|
+ // TODO It has some potential in optimization
|
|
|
Quaternion q1 = new Quaternion().fromAngleNormalAxis(ax1v, ax1);
|
|
|
Quaternion q2 = new Quaternion().fromAngleNormalAxis(ax2v, ax2);
|
|
|
Quaternion q3 = new Quaternion().fromAngleNormalAxis(ax3v, ax3);
|