|
|
|
@ -41,10 +41,10 @@ import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>Matrix4f</code> defines and maintains a 4x4 matrix in row major order. |
|
|
|
|
* This matrix is intended for use in a translation and rotational capacity. |
|
|
|
|
* It provides convenience methods for creating the matrix from a multitude |
|
|
|
|
* This matrix is intended for use in a translation and rotational capacity. |
|
|
|
|
* It provides convenience methods for creating the matrix from a multitude |
|
|
|
|
* of sources. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* Matrices are stored assuming column vectors on the right, with the translation |
|
|
|
|
* in the rightmost column. Element numbering is row,column, so m03 is the zeroth |
|
|
|
|
* row, third column, which is the "x" translation part. This means that the implicit |
|
|
|
@ -69,7 +69,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* Constructor instantiates a new <code>Matrix</code> that is set to the |
|
|
|
|
* identity matrix. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f() { |
|
|
|
|
loadIdentity(); |
|
|
|
@ -105,7 +104,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* Create a new Matrix4f, given data in column-major format. |
|
|
|
|
* |
|
|
|
|
* @param array |
|
|
|
|
* An array of 16 floats in column-major format (translation in elements 12, 13 and 14). |
|
|
|
|
* An array of 16 floats in column-major format (translation in elements 12, 13 and 14). |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f(float[] array) { |
|
|
|
|
set(array, false); |
|
|
|
@ -115,7 +114,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* Constructor instantiates a new <code>Matrix</code> that is set to the |
|
|
|
|
* provided matrix. This constructor copies a given Matrix. If the provided |
|
|
|
|
* matrix is null, the constructor sets the matrix to the identity. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param mat |
|
|
|
|
* the matrix to copy. |
|
|
|
|
*/ |
|
|
|
@ -127,7 +126,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>copy</code> transfers the contents of a given matrix to this |
|
|
|
|
* matrix. If a null matrix is supplied, this matrix is set to the identity |
|
|
|
|
* matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param matrix |
|
|
|
|
* the matrix to copy. |
|
|
|
|
*/ |
|
|
|
@ -188,7 +187,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>get</code> retrieves the values of this object into |
|
|
|
|
* a float array in row-major order. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param matrix |
|
|
|
|
* the matrix to set the values into. |
|
|
|
|
*/ |
|
|
|
@ -199,7 +198,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>set</code> retrieves the values of this object into |
|
|
|
|
* a float array. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param matrix |
|
|
|
|
* the matrix to set the values into. |
|
|
|
|
* @param rowMajor |
|
|
|
@ -252,11 +251,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>get</code> retrieves a value from the matrix at the given |
|
|
|
|
* position. If the position is invalid a <code>JmeException</code> is |
|
|
|
|
* thrown. |
|
|
|
|
* |
|
|
|
|
* @param i |
|
|
|
|
* the row index. |
|
|
|
|
* @param j |
|
|
|
|
* the colum index. |
|
|
|
|
* |
|
|
|
|
* @param i the row index. |
|
|
|
|
* @param j the colum index. |
|
|
|
|
* @return the value at (i, j). |
|
|
|
|
*/ |
|
|
|
|
@SuppressWarnings("fallthrough") |
|
|
|
@ -315,9 +312,8 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>getColumn</code> returns one of three columns specified by the |
|
|
|
|
* parameter. This column is returned as a float array of length 4. |
|
|
|
|
* |
|
|
|
|
* @param i |
|
|
|
|
* the column to retrieve. Must be between 0 and 3. |
|
|
|
|
* |
|
|
|
|
* @param i the column to retrieve. Must be between 0 and 3. |
|
|
|
|
* @return the column specified by the index. |
|
|
|
|
*/ |
|
|
|
|
public float[] getColumn(int i) { |
|
|
|
@ -327,9 +323,8 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>getColumn</code> returns one of three columns specified by the |
|
|
|
|
* parameter. This column is returned as a float[4]. |
|
|
|
|
* |
|
|
|
|
* @param i |
|
|
|
|
* the column to retrieve. Must be between 0 and 3. |
|
|
|
|
* |
|
|
|
|
* @param i the column to retrieve. Must be between 0 and 3. |
|
|
|
|
* @param store |
|
|
|
|
* the float array to store the result in. if null, a new one |
|
|
|
|
* is created. |
|
|
|
@ -372,12 +367,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* <code>setColumn</code> sets a particular column of this matrix to that |
|
|
|
|
* represented by the provided vector. |
|
|
|
|
* |
|
|
|
|
* @param i |
|
|
|
|
* the column to set. |
|
|
|
|
* |
|
|
|
|
* @param i the column to set. |
|
|
|
|
* @param column |
|
|
|
|
* the data to set. |
|
|
|
|
*/ |
|
|
|
@ -422,11 +415,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>set</code> places a given value into the matrix at the given |
|
|
|
|
* position. If the position is invalid a <code>JmeException</code> is |
|
|
|
|
* thrown. |
|
|
|
|
* |
|
|
|
|
* @param i |
|
|
|
|
* the row index. |
|
|
|
|
* @param j |
|
|
|
|
* the colum index. |
|
|
|
|
* |
|
|
|
|
* @param i the row index. |
|
|
|
|
* @param j the colum index. |
|
|
|
|
* @param value |
|
|
|
|
* the value for (i, j). |
|
|
|
|
*/ |
|
|
|
@ -502,7 +493,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>set</code> sets the values of this matrix from an array of |
|
|
|
|
* values. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param matrix |
|
|
|
|
* the matrix to set the value to. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -531,8 +522,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
m32 = matrix[3][2]; |
|
|
|
|
m33 = matrix[3][3]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the values of this matrix |
|
|
|
|
*/ |
|
|
|
@ -588,7 +578,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>set</code> sets the values of this matrix from an array of |
|
|
|
|
* values assuming that the data is rowMajor order; |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param matrix |
|
|
|
|
* the matrix to set the value to. |
|
|
|
|
*/ |
|
|
|
@ -599,7 +589,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>set</code> sets the values of this matrix from an array of |
|
|
|
|
* values; |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param matrix |
|
|
|
|
* the matrix to set the value to. |
|
|
|
|
* @param rowMajor |
|
|
|
@ -657,7 +647,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>transpose</code> locally transposes this Matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return this object for chaining. |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f transposeLocal() { |
|
|
|
@ -691,7 +681,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>toFloatBuffer</code> returns a FloatBuffer object that contains |
|
|
|
|
* the matrix data. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return matrix data as a FloatBuffer. |
|
|
|
|
*/ |
|
|
|
|
public FloatBuffer toFloatBuffer() { |
|
|
|
@ -701,7 +691,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>toFloatBuffer</code> returns a FloatBuffer object that contains the |
|
|
|
|
* matrix data. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param columnMajor |
|
|
|
|
* if true, this buffer should be filled with column major data, |
|
|
|
|
* otherwise it will be filled row major. |
|
|
|
@ -718,6 +708,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>fillFloatBuffer</code> fills a FloatBuffer object with |
|
|
|
|
* the matrix data. |
|
|
|
|
* |
|
|
|
|
* @param fb the buffer to fill, must be correct size |
|
|
|
|
* @return matrix data as a FloatBuffer. |
|
|
|
|
*/ |
|
|
|
@ -728,7 +719,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>fillFloatBuffer</code> fills a FloatBuffer object with the matrix |
|
|
|
|
* data. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param fb |
|
|
|
|
* the buffer to fill, starting at current position. Must have |
|
|
|
|
* room for 16 more floats. |
|
|
|
@ -753,7 +744,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
TempVars vars = TempVars.get(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fillFloatArray(vars.matrixWrite, columnMajor); |
|
|
|
|
fb.put(vars.matrixWrite, 0, 16); |
|
|
|
|
|
|
|
|
@ -764,16 +754,16 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
public void fillFloatArray(float[] f, boolean columnMajor) { |
|
|
|
|
if (columnMajor) { |
|
|
|
|
f[ 0] = m00; |
|
|
|
|
f[ 1] = m10; |
|
|
|
|
f[ 2] = m20; |
|
|
|
|
f[ 3] = m30; |
|
|
|
|
f[ 4] = m01; |
|
|
|
|
f[ 5] = m11; |
|
|
|
|
f[ 6] = m21; |
|
|
|
|
f[ 7] = m31; |
|
|
|
|
f[ 8] = m02; |
|
|
|
|
f[ 9] = m12; |
|
|
|
|
f[0] = m00; |
|
|
|
|
f[1] = m10; |
|
|
|
|
f[2] = m20; |
|
|
|
|
f[3] = m30; |
|
|
|
|
f[4] = m01; |
|
|
|
|
f[5] = m11; |
|
|
|
|
f[6] = m21; |
|
|
|
|
f[7] = m31; |
|
|
|
|
f[8] = m02; |
|
|
|
|
f[9] = m12; |
|
|
|
|
f[10] = m22; |
|
|
|
|
f[11] = m32; |
|
|
|
|
f[12] = m03; |
|
|
|
@ -781,16 +771,16 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
f[14] = m23; |
|
|
|
|
f[15] = m33; |
|
|
|
|
} else { |
|
|
|
|
f[ 0] = m00; |
|
|
|
|
f[ 1] = m01; |
|
|
|
|
f[ 2] = m02; |
|
|
|
|
f[ 3] = m03; |
|
|
|
|
f[ 4] = m10; |
|
|
|
|
f[ 5] = m11; |
|
|
|
|
f[ 6] = m12; |
|
|
|
|
f[ 7] = m13; |
|
|
|
|
f[ 8] = m20; |
|
|
|
|
f[ 9] = m21; |
|
|
|
|
f[0] = m00; |
|
|
|
|
f[1] = m01; |
|
|
|
|
f[2] = m02; |
|
|
|
|
f[3] = m03; |
|
|
|
|
f[4] = m10; |
|
|
|
|
f[5] = m11; |
|
|
|
|
f[6] = m12; |
|
|
|
|
f[7] = m13; |
|
|
|
|
f[8] = m20; |
|
|
|
|
f[9] = m21; |
|
|
|
|
f[10] = m22; |
|
|
|
|
f[11] = m23; |
|
|
|
|
f[12] = m30; |
|
|
|
@ -802,6 +792,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>readFloatBuffer</code> reads value for this matrix from a FloatBuffer. |
|
|
|
|
* |
|
|
|
|
* @param fb the buffer to read from, must be correct size |
|
|
|
|
* @return this data as a FloatBuffer. |
|
|
|
|
*/ |
|
|
|
@ -811,9 +802,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>readFloatBuffer</code> reads value for this matrix from a FloatBuffer. |
|
|
|
|
* |
|
|
|
|
* @param fb the buffer to read from, must be correct size |
|
|
|
|
* @param columnMajor if true, this buffer should be filled with column |
|
|
|
|
* major data, otherwise it will be filled row major. |
|
|
|
|
* major data, otherwise it will be filled row major. |
|
|
|
|
* @return this data as a FloatBuffer. |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f readFloatBuffer(FloatBuffer fb, boolean columnMajor) { |
|
|
|
@ -859,7 +851,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>loadIdentity</code> sets this matrix to the identity matrix, |
|
|
|
|
* namely all zeros with ones along the diagonal. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public void loadIdentity() { |
|
|
|
|
m01 = m02 = m03 = 0.0f; |
|
|
|
@ -869,7 +860,8 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
m00 = m11 = m22 = m33 = 1.0f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void fromFrustum(float near, float far, float left, float right, float top, float bottom, boolean parallel) { |
|
|
|
|
public void fromFrustum(float near, float far, float left, float right, |
|
|
|
|
float top, float bottom, boolean parallel) { |
|
|
|
|
loadIdentity(); |
|
|
|
|
if (parallel) { |
|
|
|
|
// scale
|
|
|
|
@ -893,7 +885,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
// A
|
|
|
|
|
m02 = (right + left) / (right - left); |
|
|
|
|
|
|
|
|
|
// B
|
|
|
|
|
// B
|
|
|
|
|
m12 = (top + bottom) / (top - bottom); |
|
|
|
|
|
|
|
|
|
// C
|
|
|
|
@ -908,7 +900,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>fromAngleAxis</code> sets this matrix4f to the values specified |
|
|
|
|
* by an angle and an axis of rotation. This method creates an object, so |
|
|
|
|
* use fromAngleNormalAxis if your axis is already normalized. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param angle |
|
|
|
|
* the angle to rotate (in radians). |
|
|
|
|
* @param axis |
|
|
|
@ -922,7 +914,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>fromAngleNormalAxis</code> sets this matrix4f to the values |
|
|
|
|
* specified by an angle and a normalized axis of rotation. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param angle |
|
|
|
|
* the angle to rotate (in radians). |
|
|
|
|
* @param axis |
|
|
|
@ -958,7 +950,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies this matrix by a scalar. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param scalar |
|
|
|
|
* the scalar to multiply this matrix by. |
|
|
|
|
*/ |
|
|
|
@ -998,7 +990,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>mult</code> multiplies this matrix with another matrix. The |
|
|
|
|
* result matrix will then be returned. This matrix will be on the left hand |
|
|
|
|
* side, while the parameter matrix will be on the right. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param in2 |
|
|
|
|
* the matrix to multiply this matrix by. |
|
|
|
|
* @return the resultant matrix |
|
|
|
@ -1011,7 +1003,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>mult</code> multiplies this matrix with another matrix. The |
|
|
|
|
* result matrix will then be returned. This matrix will be on the left hand |
|
|
|
|
* side, while the parameter matrix will be on the right. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param in2 |
|
|
|
|
* the matrix to multiply this matrix by. |
|
|
|
|
* @param store |
|
|
|
@ -1095,7 +1087,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
+ m32 * in2.m23 |
|
|
|
|
+ m33 * in2.m33; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store.m00 = m[0]; |
|
|
|
|
store.m01 = m[1]; |
|
|
|
|
store.m02 = m[2]; |
|
|
|
@ -1118,10 +1109,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies this matrix with another matrix. The |
|
|
|
|
* results are stored internally and a handle to this matrix will |
|
|
|
|
* results are stored internally and a handle to this matrix will |
|
|
|
|
* then be returned. This matrix will be on the left hand |
|
|
|
|
* side, while the parameter matrix will be on the right. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param in2 |
|
|
|
|
* the matrix to multiply this matrix by. |
|
|
|
|
* @return the resultant matrix |
|
|
|
@ -1133,7 +1124,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies a vector about a rotation matrix. The |
|
|
|
|
* resulting vector is returned as a new Vector3f. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* vec to multiply against. |
|
|
|
|
* @return the rotated vector. |
|
|
|
@ -1145,7 +1136,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies a vector about a rotation matrix and adds |
|
|
|
|
* translation. The resulting vector is returned. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* vec to multiply against. |
|
|
|
|
* @param store |
|
|
|
@ -1211,7 +1202,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* vec to multiply against. |
|
|
|
|
* |
|
|
|
|
* @return the rotated vector. |
|
|
|
|
*/ |
|
|
|
|
public Vector4f multAcross(Vector4f vec) { |
|
|
|
@ -1296,11 +1286,11 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* <code>mult</code> multiplies a vector about a rotation matrix and adds |
|
|
|
|
* translation. The w value is returned as a result of |
|
|
|
|
* multiplying the last column of the matrix by 1.0 |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* vec to multiply against. |
|
|
|
|
* @param store |
|
|
|
|
* a vector to store the result in. |
|
|
|
|
* a vector to store the result in. |
|
|
|
|
* @return the W value |
|
|
|
|
*/ |
|
|
|
|
public float multProj(Vector3f vec, Vector3f store) { |
|
|
|
@ -1314,7 +1304,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies a vector about a rotation matrix. The |
|
|
|
|
* resulting vector is returned. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* vec to multiply against. |
|
|
|
|
* @param store |
|
|
|
@ -1371,9 +1361,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies an array of 4 floats against this rotation |
|
|
|
|
* <code>mult</code> multiplies an array of 4 floats against this rotation |
|
|
|
|
* matrix. The results are stored directly in the array. (vec4f x mat4f) |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec4f |
|
|
|
|
* float array (size 4) to multiply against the matrix. |
|
|
|
|
* @return the vec4f for chaining. |
|
|
|
@ -1395,9 +1385,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>mult</code> multiplies an array of 4 floats against this rotation |
|
|
|
|
* <code>mult</code> multiplies an array of 4 floats against this rotation |
|
|
|
|
* matrix. The results are stored directly in the array. (vec4f x mat4f) |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec4f |
|
|
|
|
* float array (size 4) to multiply against the matrix. |
|
|
|
|
* @return the vec4f for chaining. |
|
|
|
@ -1420,7 +1410,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Inverts this matrix as a new Matrix4f. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return The new inverse matrix |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f invert() { |
|
|
|
@ -1429,7 +1419,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Inverts this matrix and stores it in the given store. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return The store |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f invert(Matrix4f store) { |
|
|
|
@ -1480,7 +1470,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Inverts this matrix locally. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return this |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f invertLocal() { |
|
|
|
@ -1545,7 +1535,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns a new matrix representing the adjoint of this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return The adjoint matrix |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f adjoint() { |
|
|
|
@ -1581,7 +1571,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Places the adjoint of this matrix in store (creates store if null.) |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param store |
|
|
|
|
* The matrix to store the result in. If null, a new matrix is created. |
|
|
|
|
* @return store |
|
|
|
@ -1626,7 +1616,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>determinant</code> generates the determinate of this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return the determinate |
|
|
|
|
*/ |
|
|
|
|
public float determinant() { |
|
|
|
@ -1648,7 +1638,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets all of the values in this matrix to zero. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return this matrix |
|
|
|
|
*/ |
|
|
|
|
public Matrix4f zero() { |
|
|
|
@ -1682,7 +1672,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>add</code> adds the values of a parameter matrix to this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param mat |
|
|
|
|
* the matrix to add to this. |
|
|
|
|
*/ |
|
|
|
@ -1738,18 +1728,18 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
mat.m20 = m20; |
|
|
|
|
mat.m21 = m21; |
|
|
|
|
mat.m22 = m22; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieves the scale vector from the matrix. |
|
|
|
|
* |
|
|
|
|
* @return the scale vector |
|
|
|
|
*/ |
|
|
|
|
public Vector3f toScaleVector() { |
|
|
|
|
Vector3f result = new Vector3f(); |
|
|
|
|
this.toScaleVector(result); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Retrieves the scale vector from the matrix. |
|
|
|
|
* |
|
|
|
|
* @return the scale vector |
|
|
|
|
*/ |
|
|
|
|
public Vector3f toScaleVector() { |
|
|
|
|
Vector3f result = new Vector3f(); |
|
|
|
|
this.toScaleVector(result); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieves the scale vector from the matrix and stores it into a given |
|
|
|
@ -1759,16 +1749,16 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* @return the store vector |
|
|
|
|
*/ |
|
|
|
|
public Vector3f toScaleVector(Vector3f store) { |
|
|
|
|
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); |
|
|
|
|
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); |
|
|
|
|
store.set(scaleX, scaleY, scaleZ); |
|
|
|
|
return store; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the scale. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param x |
|
|
|
|
* the X scale |
|
|
|
|
* @param y |
|
|
|
@ -1805,7 +1795,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the scale. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param scale |
|
|
|
|
* the scale vector to set |
|
|
|
|
*/ |
|
|
|
@ -1815,7 +1805,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>setTranslation</code> will set the matrix's translation values. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param translation |
|
|
|
|
* the new values for the translation. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -1833,13 +1823,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <code>setTranslation</code> will set the matrix's translation values. |
|
|
|
|
* |
|
|
|
|
* @param x |
|
|
|
|
* value of the translation on the x axis |
|
|
|
|
* @param y |
|
|
|
|
* value of the translation on the y axis |
|
|
|
|
* @param z |
|
|
|
|
* value of the translation on the z axis |
|
|
|
|
* |
|
|
|
|
* @param x value of the translation on the x axis |
|
|
|
|
* @param y value of the translation on the y axis |
|
|
|
|
* @param z value of the translation on the z axis |
|
|
|
|
*/ |
|
|
|
|
public void setTranslation(float x, float y, float z) { |
|
|
|
|
m03 = x; |
|
|
|
@ -1862,7 +1849,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>setInverseTranslation</code> will set the matrix's inverse |
|
|
|
|
* translation values. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param translation |
|
|
|
|
* the new values for the inverse translation. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -1883,7 +1870,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* three axes (x, y, z). Where each axis has a specified rotation in |
|
|
|
|
* degrees. These rotations are expressed in a single <code>Vector3f</code> |
|
|
|
|
* object. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param angles |
|
|
|
|
* the angles to rotate. |
|
|
|
|
*/ |
|
|
|
@ -1919,7 +1906,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>setRotationQuaternion</code> builds a rotation from a |
|
|
|
|
* <code>Quaternion</code>. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param quat |
|
|
|
|
* the quaternion to build the rotation from. |
|
|
|
|
* @throws NullPointerException |
|
|
|
@ -1932,7 +1919,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>setInverseRotationRadians</code> builds an inverted rotation from |
|
|
|
|
* Euler angles that are in radians. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param angles |
|
|
|
|
* the Euler angles in radians. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -1969,7 +1956,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
/** |
|
|
|
|
* <code>setInverseRotationDegrees</code> builds an inverted rotation from |
|
|
|
|
* Euler angles that are in degrees. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param angles |
|
|
|
|
* the Euler angles in degrees. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -1988,10 +1975,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* <code>inverseTranslateVect</code> translates a given Vector3f by the |
|
|
|
|
* translation part of this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* the Vector3f data to be translated. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -2009,10 +1995,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* <code>inverseTranslateVect</code> translates a given Vector3f by the |
|
|
|
|
* translation part of this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param data |
|
|
|
|
* the Vector3f to be translated. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -2025,10 +2010,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* <code>inverseTranslateVect</code> translates a given Vector3f by the |
|
|
|
|
* translation part of this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param data |
|
|
|
|
* the Vector3f to be translated. |
|
|
|
|
* @throws JmeException |
|
|
|
@ -2041,10 +2025,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* <code>inverseRotateVect</code> rotates a given Vector3f by the rotation |
|
|
|
|
* part of this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param vec |
|
|
|
|
* the Vector3f to be rotated. |
|
|
|
|
*/ |
|
|
|
@ -2072,7 +2055,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
* 0.0 1.0 0.0 0.0 <br> |
|
|
|
|
* 0.0 0.0 1.0 0.0 <br> |
|
|
|
|
* 0.0 0.0 0.0 1.0 <br>]<br> |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return the string representation of this object. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -2118,11 +2101,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* <code>hashCode</code> returns the hash code value as an integer and is |
|
|
|
|
* supported for the benefit of hashing based collection classes such as |
|
|
|
|
* Hashtable, HashMap, HashSet etc. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @return the hashcode for this instance of Matrix4f. |
|
|
|
|
* @see java.lang.Object#hashCode() |
|
|
|
|
*/ |
|
|
|
@ -2279,7 +2261,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Apply a scale to this matrix. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @param scale |
|
|
|
|
* the scale to apply |
|
|
|
|
*/ |
|
|
|
|