From 25e20509c628d97fe27dd96693fd16bb50dd9d46 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Tue, 10 Dec 2013 19:29:52 +0000 Subject: [PATCH] Bugfix: bone context returns the length of the bone without taking model scale into account; that caused troubles during constraint's computations but should be used for bone debugger length (an appropriate notice is in the method's javadoc). git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10940 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/animations/BoneContext.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java index f650a3a75..e9b52efde 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java @@ -23,37 +23,37 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; */ public class BoneContext { // the flags of the bone - public static final int CONNECTED_TO_PARENT = 0x10; + public static final int CONNECTED_TO_PARENT = 0x10; /** * The bones' matrices have, unlike objects', the coordinate system identical to JME's (Y axis is UP, X to the right and Z toward us). * So in order to have them loaded properly we need to transform their armature matrix (which blender sees as rotated) to make sure we get identical results. */ - public static final Matrix4f BONE_ARMATURE_TRANSFORMATION_MATRIX = new Matrix4f(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1); + public static final Matrix4f BONE_ARMATURE_TRANSFORMATION_MATRIX = new Matrix4f(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1); - private BlenderContext blenderContext; + private BlenderContext blenderContext; /** The OMA of the bone's armature object. */ - private Long armatureObjectOMA; + private Long armatureObjectOMA; /** The OMA of the model that owns the bone's skeleton. */ - private Long skeletonOwnerOma; + private Long skeletonOwnerOma; /** The structure of the bone. */ - private Structure boneStructure; + private Structure boneStructure; /** Bone's name. */ - private String boneName; + private String boneName; /** The bone's flag. */ - private int flag; + private int flag; /** The bone's matrix in world space. */ - private Matrix4f globalBoneMatrix; + private Matrix4f globalBoneMatrix; /** The bone's matrix in the model space. */ - private Matrix4f boneMatrixInModelSpace; + private Matrix4f boneMatrixInModelSpace; /** The parent context. */ - private BoneContext parent; + private BoneContext parent; /** The children of this context. */ - private List children = new ArrayList(); + private List children = new ArrayList(); /** Created bone (available after calling 'buildBone' method). */ - private Bone bone; + private Bone bone; /** The length of the bone. */ - private float length; + private float length; /** * Constructor. Creates the basic set of bone's data. @@ -174,10 +174,15 @@ public class BoneContext { } /** + * The method returns the length of the bone. + * If you want to use it for bone debugger take model space scale into account and do + * something like this: + * boneContext.getLength() * boneContext.getBone().getModelSpaceScale().y. + * Otherwise the bones might not look as they should in the bone debugger. * @return the length of the bone */ public float getLength() { - return length * bone.getModelSpaceScale().y; + return length; } /**