From 45e82cdbb121a58acd9c412d53ae278f3315aa80 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Thu, 28 Nov 2013 21:19:31 +0000 Subject: [PATCH] Bugfix: fixed parenting issue (turned out that blender does not always store parent inverse matrix in objects parentinv field) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10922 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../scene/plugins/blender/objects/ObjectHelper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java index 6af11c5c6..ec7b84b3d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java @@ -276,13 +276,15 @@ public class ObjectHelper extends AbstractBlenderHelper { * @return objects transformation relative to its parent */ public Transform getTransformation(Structure objectStructure, BlenderContext blenderContext) { - // load parent inverse matrix only if the object has parent + Matrix4f parentInv = Matrix4f.IDENTITY; Pointer pParent = (Pointer) objectStructure.getFieldValue("parent"); - Matrix4f parentInv = pParent.isNull() ? Matrix4f.IDENTITY : this.getMatrix(objectStructure, "parentinv", fixUpAxis); + if(pParent.isNotNull()) { + Structure parentObjectStructure = (Structure) blenderContext.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_STRUCTURE); + parentInv = this.getMatrix(parentObjectStructure, "obmat", fixUpAxis).invertLocal(); + } Matrix4f globalMatrix = this.getMatrix(objectStructure, "obmat", fixUpAxis); - Matrix4f localMatrix = parentInv.mult(globalMatrix); - + Matrix4f localMatrix = parentInv.multLocal(globalMatrix); return new Transform(localMatrix.toTranslationVector(), localMatrix.toRotationQuat(), localMatrix.toScaleVector()); }