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
experimental
Kae..pl 11 years ago
parent 382c1c85f5
commit 45e82cdbb1
  1. 10
      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());
}

Loading…
Cancel
Save