Adding additional comments.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7701 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
1704f839b7
commit
82a718e413
@ -281,16 +281,20 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Transform getTransformation(Structure objectStructure) {
|
public Transform getTransformation(Structure objectStructure) {
|
||||||
|
//these are transformations in global space
|
||||||
DynamicArray<Number> loc = (DynamicArray<Number>)objectStructure.getFieldValue("loc");
|
DynamicArray<Number> loc = (DynamicArray<Number>)objectStructure.getFieldValue("loc");
|
||||||
DynamicArray<Number> size = (DynamicArray<Number>)objectStructure.getFieldValue("size");
|
DynamicArray<Number> size = (DynamicArray<Number>)objectStructure.getFieldValue("size");
|
||||||
DynamicArray<Number> rot = (DynamicArray<Number>)objectStructure.getFieldValue("rot");
|
DynamicArray<Number> rot = (DynamicArray<Number>)objectStructure.getFieldValue("rot");
|
||||||
|
|
||||||
|
//load parent inverse matrix
|
||||||
Pointer parent = (Pointer) objectStructure.getFieldValue("parent");
|
Pointer parent = (Pointer) objectStructure.getFieldValue("parent");
|
||||||
Matrix4f parentInv = parent.isNull() ? Matrix4f.IDENTITY : this.getMatrix(objectStructure, "parentinv");
|
Matrix4f parentInv = parent.isNull() ? Matrix4f.IDENTITY : this.getMatrix(objectStructure, "parentinv");
|
||||||
|
|
||||||
|
//create the global matrix (without the scale)
|
||||||
Matrix4f globalMatrix = new Matrix4f();
|
Matrix4f globalMatrix = new Matrix4f();
|
||||||
globalMatrix.setTranslation(loc.get(0).floatValue(), loc.get(1).floatValue(), loc.get(2).floatValue());
|
globalMatrix.setTranslation(loc.get(0).floatValue(), loc.get(1).floatValue(), loc.get(2).floatValue());
|
||||||
globalMatrix.setRotationQuaternion(new Quaternion().fromAngles(rot.get(0).floatValue(), rot.get(1).floatValue(), rot.get(2).floatValue()));
|
globalMatrix.setRotationQuaternion(new Quaternion().fromAngles(rot.get(0).floatValue(), rot.get(1).floatValue(), rot.get(2).floatValue()));
|
||||||
|
//compute local matrix
|
||||||
Matrix4f localMatrix = parentInv.mult(globalMatrix);
|
Matrix4f localMatrix = parentInv.mult(globalMatrix);
|
||||||
|
|
||||||
Vector3f translation = localMatrix.toTranslationVector();
|
Vector3f translation = localMatrix.toTranslationVector();
|
||||||
@ -302,12 +306,16 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
Vector3f scale = new Vector3f(size.get(0).floatValue() * scaleX,
|
Vector3f scale = new Vector3f(size.get(0).floatValue() * scaleX,
|
||||||
size.get(1).floatValue() * scaleY,
|
size.get(1).floatValue() * scaleY,
|
||||||
size.get(2).floatValue() * scaleZ);
|
size.get(2).floatValue() * scaleZ);
|
||||||
|
|
||||||
|
//the root object is transformed if the Y axis is UP
|
||||||
if(parent.isNull() && fixUpAxis) {
|
if(parent.isNull() && fixUpAxis) {
|
||||||
float y = translation.y;
|
float y = translation.y;
|
||||||
translation.y = translation.z;
|
translation.y = translation.z;
|
||||||
translation.z = -y;
|
translation.z = -y;
|
||||||
rotation.multLocal(this.upAxisRotationQuaternion);
|
rotation.multLocal(this.upAxisRotationQuaternion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//create the result
|
||||||
Transform t = new Transform(translation, rotation);
|
Transform t = new Transform(translation, rotation);
|
||||||
t.setScale(scale);
|
t.setScale(scale);
|
||||||
return t;
|
return t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user