From 4b6be2a78988207ff0c046d5e7c356cb0dea9ecb Mon Sep 17 00:00:00 2001 From: Eirenliel Allier Date: Tue, 26 Apr 2016 10:16:03 +0300 Subject: [PATCH] FBX Importer cleanup --- .../jme3/scene/plugins/fbx/RotationOrder.java | 56 +------------------ .../jme3/scene/plugins/fbx/SceneLoader.java | 5 +- 2 files changed, 5 insertions(+), 56 deletions(-) diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/RotationOrder.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/RotationOrder.java index 94940609f..8a1e05b36 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/RotationOrder.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/RotationOrder.java @@ -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); diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/SceneLoader.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/SceneLoader.java index cf4af7682..7b9a5a7f5 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/SceneLoader.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/SceneLoader.java @@ -44,9 +44,8 @@ import com.jme3.scene.plugins.fbx.objects.FbxTexture; /** * FBX file format loader *

Loads scene meshes, materials, textures, skeleton and skeletal animation. - * Multiple animations can be defined with {@link AnimationList} passing into {@link SceneKey}.

- * - * @author Aleksandra Menshchikova + * Multiple animations can be defined with {@link AnimationList} passing into {@link SceneKey} + * or loaded from different animation layer.

*/ public class SceneLoader implements AssetLoader {