From f8c256d1277169e3672a3d908b63e56bb02061c8 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Fri, 12 Apr 2013 21:04:16 +0000 Subject: [PATCH] Feature: added scale retreive methods to Matrix4f. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10534 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/math/Matrix4f.java | 29 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/engine/src/core/com/jme3/math/Matrix4f.java b/engine/src/core/com/jme3/math/Matrix4f.java index cddae7bc4..3c73f5739 100644 --- a/engine/src/core/com/jme3/math/Matrix4f.java +++ b/engine/src/core/com/jme3/math/Matrix4f.java @@ -1744,7 +1744,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable public Matrix3f toRotationMatrix() { return new Matrix3f(m00, m01, m02, m10, m11, m12, m20, m21, m22); - } public void toRotationMatrix(Matrix3f mat) { @@ -1757,8 +1756,32 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable mat.m20 = m20; mat.m21 = m21; mat.m22 = m22; - - } + } + + /** + * Retreives the scale vector from the matrix. + * + * @return the scale vector + */ + public Vector3f toScaleVector() { + Vector3f result = new Vector3f(); + this.toScaleVector(result); + return result; + } + + /** + * Retreives the scale vector from the matrix and stores it into a given + * vector. + * + * @param the + * vector where the scale will be stored + */ + public void toScaleVector(Vector3f vector) { + float scaleX = (float) Math.sqrt(m00 * m00 + m10 * m10 + m20 * m20); + float scaleY = (float) Math.sqrt(m01 * m01 + m11 * m11 + m21 * m21); + float scaleZ = (float) Math.sqrt(m02 * m02 + m12 * m12 + m22 * m22); + vector.set(scaleX, scaleY, scaleZ); + } public void setScale(float x, float y, float z) { m00 *= x;