Changes to Y-is-Up-Axis issue.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8516 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 13 years ago
parent 65cbed47c6
commit 18ce27faae
  1. 2
      engine/src/blender/com/jme3/scene/plugins/blender/BlenderLoader.java
  2. 7
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java
  3. 20
      engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java

@ -211,6 +211,8 @@ public class BlenderLoader extends AbstractBlenderLoader {
helper.setyIsUpAxis(true);
helper = blenderContext.getHelper(ArmatureHelper.class);
helper.setyIsUpAxis(true);
helper = blenderContext.getHelper(MeshHelper.class);
helper.setyIsUpAxis(true);
}
MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
materialHelper.setFaceCullMode(blenderKey.getFaceCullMode());

@ -498,10 +498,17 @@ public class MeshHelper extends AbstractBlenderHelper {
Pointer pMVert = (Pointer) meshStructure.getFieldValue("mvert");
List<Structure> mVerts = pMVert.fetchData(blenderContext.getInputStream());
if(this.fixUpAxis) {
for (int i = 0; i < verticesAmount; ++i) {
DynamicArray<Number> coordinates = (DynamicArray<Number>) mVerts.get(i).getFieldValue("co");
vertices[i] = new Vector3f(coordinates.get(0).floatValue(), coordinates.get(2).floatValue(), coordinates.get(1).floatValue());
}
} else {
for (int i = 0; i < verticesAmount; ++i) {
DynamicArray<Number> coordinates = (DynamicArray<Number>) mVerts.get(i).getFieldValue("co");
vertices[i] = new Vector3f(coordinates.get(0).floatValue(), coordinates.get(1).floatValue(), coordinates.get(2).floatValue());
}
}
return vertices;
}

@ -282,14 +282,6 @@ public class ObjectHelper extends AbstractBlenderHelper {
//load parent inverse matrix
Pointer pParent = (Pointer) objectStructure.getFieldValue("parent");
Structure parent = null;
if(pParent.isNotNull()) {
try {
parent = pParent.fetchData(blenderContext.getInputStream()).get(0);
} catch (BlenderFileException e) {
LOGGER.log(Level.WARNING, "Cannot fetch parent for object! Reason: {0}", e.getLocalizedMessage());
}
}
Matrix4f parentInv = pParent.isNull() ? Matrix4f.IDENTITY : this.getMatrix(objectStructure, "parentinv");
//create the global matrix (without the scale)
@ -309,12 +301,18 @@ public class ObjectHelper extends AbstractBlenderHelper {
size.get(1).floatValue() * scaleY,
size.get(2).floatValue() * scaleZ);
//the root object is transformed if the Y axis is UP
if(fixUpAxis && (pParent.isNull() || (parent!=null && !this.shouldBeLoaded(parent, blenderContext)))) {
if(fixUpAxis) {
float y = translation.y;
translation.y = translation.z;
translation.z = -y;
rotation = this.upAxisRotationQuaternion.mult(rotation);
y = rotation.getY();
float z = rotation.getZ();
rotation.set(rotation.getX(), z, -y, rotation.getW());
y=scale.y;
scale.y = scale.z;
scale.z = -y;
}
//create the result

Loading…
Cancel
Save