In com.jme.math package,
Some classes’ set() methods are declared as void while other set() methods return itself for chaining
[patch]
Index: src/core/com/jme3/math/Matrix3f.java
===================================================================
— src/core/com/jme3/math/Matrix3f.java (revision 5882)
+++ src/core/com/jme3/math/Matrix3f.java (working copy)
@@ -137,8 +137,9 @@
*
-
@param matrix
-
the matrix to copy.<br />
-
* @return this<br />
*/
- public void set(Matrix3f matrix) {
- public Matrix3f set(Matrix3f matrix) {
if (null == matrix) {
loadIdentity();
} else {
@@ -152,6 +153,7 @@
m21 = matrix.m21;
m22 = matrix.m22;
}
-
return this;<br />
}
/**
@@ -399,12 +401,13 @@
-
the column to set.<br />
-
@param column
-
the data to set.<br />
-
* @return this<br />
*/
- public void setColumn(int i, Vector3f column) {
- public Matrix3f setColumn(int i, Vector3f column) {
if (column == null) {
logger.warning(“Column is null. Ignoring.”);
-
return;<br />
-
return this;<br />
}
switch (i) {
case 0:
@@ -426,6 +429,7 @@
logger.warning(“Invalid column index.”);
throw new IllegalArgumentException("Invalid column index. " + i);
}
-
return this;<br />
}
@@ -438,12 +442,13 @@
-
the row to set.<br />
-
@param row
-
the data to set.<br />
-
* @return this<br />
*/
- public void setRow(int i, Vector3f row) {
- public Matrix3f setRow(int i, Vector3f row) {
if (row == null) {
logger.warning(“Row is null. Ignoring.”);
-
return;<br />
-
return this;<br />
}
switch (i) {
case 0:
@@ -465,6 +470,7 @@
logger.warning(“Invalid row index.”);
throw new IllegalArgumentException("Invalid row index. " + i);
}
-
return this;<br />
}
/**
@@ -478,26 +484,27 @@
-
the colum index.<br />
-
@param value
-
the value for (i, j).<br />
-
* @return this<br />
*/
- public void set(int i, int j, float value) {
- public Matrix3f set(int i, int j, float value) {
switch (i) {
case 0:
switch (j) {
-
case 0: m00 = value; return;<br />
-
case 1: m01 = value; return;<br />
-
case 2: m02 = value; return;<br />
-
case 0: m00 = value; return this;<br />
-
case 1: m01 = value; return this;<br />
-
case 2: m02 = value; return this;<br />
}
case 1:
switch (j) {
-
case 0: m10 = value; return;<br />
-
case 1: m11 = value; return;<br />
-
case 2: m12 = value; return;<br />
-
case 0: m10 = value; return this;<br />
-
case 1: m11 = value; return this;<br />
-
case 2: m12 = value; return this;<br />
}
case 2:
switch (j) {
-
case 0: m20 = value; return;<br />
-
case 1: m21 = value; return;<br />
-
case 2: m22 = value; return;<br />
-
case 0: m20 = value; return this;<br />
-
case 1: m21 = value; return this;<br />
-
case 2: m22 = value; return this;<br />
}
}
@@ -514,8 +521,9 @@
-
the new values of the matrix.<br />
-
@throws JmeException
-
if the array is not of size 9.<br />
-
* @return this<br />
*/
- public void set(float[][] matrix) {
- public Matrix3f set(float[][] matrix) {
if (matrix.length != 3 || matrix[0].length != 3) { throw new IllegalArgumentException(
“Array must be of size 9.”); }
@@ -528,6 +536,8 @@
m20 = matrix[2][0];
m21 = matrix[2][1];
m22 = matrix[2][2];
+
-
return this;<br />
}
/**
@@ -560,9 +570,10 @@
*
-
@param matrix
-
the matrix to set the value to.<br />
-
* @return this<br />
*/
- public void set(float[] matrix) {
-
set(matrix, true);<br />
- public Matrix3f set(float[] matrix) {
-
return set(matrix, true);<br />
}
/**
@@ -573,8 +584,9 @@
-
the matrix to set the value to.<br />
-
@param rowMajor
-
whether the incoming data is in row or column major order.<br />
-
* @return this<br />
*/
- public void set(float[] matrix, boolean rowMajor) {
- public Matrix3f set(float[] matrix, boolean rowMajor) {
if (matrix.length != 9) throw new IllegalArgumentException(
“Array must be of size 9.”);
@@ -599,6 +611,7 @@
m21 = matrix[5];
m22 = matrix[8];
}
-
return this;<br />
}
/**
@@ -609,9 +622,10 @@
*
-
@param quaternion
-
the quaternion to create a rotational matrix from.<br />
-
* @return this<br />
*/
- public void set(Quaternion quaternion) {
-
quaternion.toRotationMatrix(this);<br />
- public Matrix3f set(Quaternion quaternion) {
-
return quaternion.toRotationMatrix(this);<br />
}
/**
Index: src/core/com/jme3/math/ColorRGBA.java
===================================================================
— src/core/com/jme3/math/ColorRGBA.java (revision 5882)
+++ src/core/com/jme3/math/ColorRGBA.java (working copy)
@@ -182,12 +182,14 @@
-
@param g the green component of this color.
-
@param b the blue component of this color.
-
@param a the alpha component of this color.
-
* @return this<br />
*/
- public void set(float r, float g, float b, float a) {
- public ColorRGBA set(float r, float g, float b, float a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
-
return this;<br />
}
/
Index: src/core/com/jme3/math/Transform.java
===================================================================
— src/core/com/jme3/math/Transform.java (revision 5882)
+++ src/core/com/jme3/math/Transform.java (working copy)
@@ -74,17 +74,21 @@
/
- Sets this rotation to the given Quaternion value.
-
@param rot The new rotation for this matrix.
-
* @return this<br />
*/
- public void setRotation(Quaternion rot) {
- public Transform setRotation(Quaternion rot) {
this.rot.set(rot);
-
return this;<br />
}
/**
- Sets this translation to the given value.
-
@param trans The new translation for this matrix.
-
* @return this<br />
*/
- public void setTranslation(Vector3f trans) {
- public Transform setTranslation(Vector3f trans) {
this.translation.set(trans);
-
return this;<br />
}
/
@@ -98,17 +102,21 @@
/
- Sets this scale to the given value.
-
@param scale The new scale for this matrix.
-
* @return this<br />
*/
- public void setScale(Vector3f scale) {
- public Transform setScale(Vector3f scale) {
this.scale.set(scale);
-
return this;<br />
}
/**
- Sets this scale to the given value.
-
@param scale The new scale for this matrix.
-
* @return this<br />
*/
- public void setScale(float scale) {
- public Transform setScale(float scale) {
this.scale.set(scale, scale, scale);
-
return this;<br />
}
/**
@@ -198,9 +206,11 @@
-
@param x This matrix’s new x translation.
-
@param y This matrix’s new y translation.
-
@param z This matrix’s new z translation.
-
* @return this<br />
*/
- public void setTranslation(float x,float y, float z) {
- public Transform setTranslation(float x,float y, float z) {
translation.set(x,y,z);
-
return this;<br />
}
/**
@@ -208,9 +218,11 @@
-
@param x This matrix’s new x scale.
-
@param y This matrix’s new y scale.
-
@param z This matrix’s new z scale.
-
* @return this<br />
*/
- public void setScale(float x, float y, float z) {
- public Transform setScale(float x, float y, float z) {
scale.set(x,y,z);
-
return this;<br />
}
public Vector3f transformVector(final Vector3f in, Vector3f store){
@@ -249,11 +261,13 @@
/**
- Sets this matrix to be equal to the given matrix.
-
@param matrixQuat The matrix to be equal to.
-
* @return this<br />
*/
- public void set(Transform matrixQuat) {
- public Transform set(Transform matrixQuat) {
this.translation.set(matrixQuat.translation);
this.rot.set(matrixQuat.rot);
this.scale.set(matrixQuat.scale);
-
return this;<br />
}
public void write(JmeExporter e) throws IOException {
Index: src/core/com/jme3/math/Matrix4f.java
===================================================================
— src/core/com/jme3/math/Matrix4f.java (revision 5882)
+++ src/core/com/jme3/math/Matrix4f.java (working copy)
@@ -383,12 +383,13 @@
-
the column to set.<br />
-
@param column
-
the data to set.<br />
-
* @return this<br />
*/
- public void setColumn(int i, float[] column) {
- public Matrix4f setColumn(int i, float[] column) {
if (column == null) {
logger.warning(“Column is null. Ignoring.”);
-
return;<br />
-
return this;<br />
}
switch (i) {
case 0:
@@ -418,7 +419,9 @@
default:
logger.warning(“Invalid column index.”);
throw new IllegalArgumentException("Invalid column index. " + i);
-
} }<br />
-
}<br />
-
return this;<br />
- }
/**
-
set
places a given value into the matrix at the given
@@ -431,36 +434,37 @@
-
the colum index.<br />
-
@param value
-
the value for (i, j).<br />
-
* @return this<br />
*/
- public void set(int i, int j, float value) {
- public Matrix4f set(int i, int j, float value) {
switch (i) {
case 0:
switch (j) {
-
case 0: m00 = value; return;<br />
-
case 1: m01 = value; return;<br />
-
case 2: m02 = value; return;<br />
-
case 3: m03 = value; return;<br />
-
case 0: m00 = value; return this;<br />
-
case 1: m01 = value; return this;<br />
-
case 2: m02 = value; return this;<br />
-
case 3: m03 = value; return this;<br />
}
case 1:
switch (j) {
-
case 0: m10 = value; return;<br />
-
case 1: m11 = value; return;<br />
-
case 2: m12 = value; return;<br />
-
case 3: m13 = value; return;<br />
-
case 0: m10 = value; return this;<br />
-
case 1: m11 = value; return this;<br />
-
case 2: m12 = value; return this;<br />
-
case 3: m13 = value; return this;<br />
}
case 2:
switch (j) {
-
case 0: m20 = value; return;<br />
-
case 1: m21 = value; return;<br />
-
case 2: m22 = value; return;<br />
-
case 3: m23 = value; return;<br />
-
case 0: m20 = value; return this;<br />
-
case 1: m21 = value; return this;<br />
-
case 2: m22 = value; return this;<br />
-
case 3: m23 = value; return this;<br />
}
case 3:
switch (j) {
-
case 0: m30 = value; return;<br />
-
case 1: m31 = value; return;<br />
-
case 2: m32 = value; return;<br />
-
case 3: m33 = value; return;<br />
-
case 0: m30 = value; return this;<br />
-
case 1: m31 = value; return this;<br />
-
case 2: m32 = value; return this;<br />
-
case 3: m33 = value; return this;<br />
}
}
@@ -474,10 +478,11 @@
*
-
@param matrix
-
the matrix to set the value to.<br />
-
* @return this<br />
-
@throws JmeException
-
if the array is not of size 16.<br />
*/
- public void set(float[][] matrix) {
- public Matrix4f set(float[][] matrix) {
if (matrix.length != 4 || matrix[0].length != 4) { throw new IllegalArgumentException(
“Array must be of size 16.”); }
@@ -497,6 +502,8 @@
m31 = matrix[3][1];
m32 = matrix[3][2];
m33 = matrix[3][3];
+
-
return this;<br />
}
/**
@@ -504,6 +511,7 @@
*
-
@param matrix
-
the matrix to read the value from.<br />
-
* @return this<br />
*/
public Matrix4f set(Matrix4f matrix) {
m00 = matrix.m00; m01 = matrix.m01; m02 = matrix.m02; m03 = matrix.m03;
@@ -519,9 +527,10 @@
*
-
@param matrix
-
the matrix to set the value to.<br />
-
* @return this<br />
*/
- public void set(float[] matrix) {
-
set(matrix, true);<br />
- public Matrix4f set(float[] matrix) {
-
return set(matrix, true);<br />
}
/**
@@ -532,8 +541,9 @@
-
the matrix to set the value to.<br />
-
@param rowMajor
-
whether the incoming data is in row or column major order.<br />
-
* @return this<br />
*/
- public void set(float[] matrix, boolean rowMajor) {
- public Matrix4f set(float[] matrix, boolean rowMajor) {
if (matrix.length != 16) throw new IllegalArgumentException(
“Array must be of size 16.”);
@@ -572,6 +582,7 @@
m32 = matrix[11];
m33 = matrix[15];
}
-
return this;<br />
}
public Matrix4f transpose() {
@@ -1475,16 +1486,34 @@
}
- public void setScale(float x, float y, float z){
- /**
-
* <code>setScale</code> will set the matrix's scale values.<br />
-
* @param x<br />
-
* value of the scale on the x axis<br />
-
* @param y<br />
-
* value of the scale on the y axis<br />
-
* @param z<br />
-
* value of the scale on the z axis<br />
-
* @return this<br />
-
*/<br />
- public Matrix4f setScale(float x, float y, float z){
m00 *= x;
m11 *= y;
m22 *= z;
-
return this;<br />
}
- public void setScale(Vector3f scale){
- /**
-
* <code>setScale</code> will set the matrix's scale values.<br />
-
* @param scale<br />
-
* value of the scale<br />
-
* @return this<br />
-
*/<br />
- public Matrix4f setScale(Vector3f scale){
m00 *= scale.x;
m11 *= scale.y;
m22 *= scale.z;
-
return this;<br />
}
/**
@@ -1492,15 +1521,17 @@
*
-
@param translation
-
the new values for the translation.<br />
-
* @return this<br />
-
@throws JmeException
-
if translation is not size 3.<br />
*/
- public void setTranslation(float[] translation) {
- public Matrix4f setTranslation(float[] translation) {
if (translation.length != 3) { throw new IllegalArgumentException(
“Translation size must be 3.”); }
m03 = translation[0];
m13 = translation[1];
m23 = translation[2];
-
return this;<br />
}
/**
@@ -1512,11 +1543,13 @@
-
value of the translation on the y axis<br />
-
@param z
-
value of the translation on the z axis<br />
-
* @return this<br />
*/
- public void setTranslation(float x, float y, float z) {
- public Matrix4f setTranslation(float x, float y, float z) {
m03 = x;
m13 = y;
m23 = z;
-
return this;<br />
}
/**
@@ -1524,11 +1557,13 @@
*
-
@param translation
-
the new values for the translation.<br />
-
* @return this<br />
*/
- public void setTranslation(Vector3f translation) {
- public Matrix4f setTranslation(Vector3f translation) {
m03 = translation.x;
m13 = translation.y;
m23 = translation.z;
-
return this;<br />
}
/**
@@ -1537,15 +1572,17 @@
*
-
@param translation
-
the new values for the inverse translation.<br />
-
* @return this<br />
-
@throws JmeException
-
if translation is not size 3.<br />
*/
- public void setInverseTranslation(float[] translation) {
- public Matrix4f setInverseTranslation(float[] translation) {
if (translation.length != 3) { throw new IllegalArgumentException(
“Translation size must be 3.”); }
m03 = -translation[0];
m13 = -translation[1];
m23 = -translation[2];
-
return this;<br />
}
/**
@@ -1592,11 +1629,12 @@
*
-
@param quat
-
the quaternion to build the rotation from.<br />
-
* @return this<br />
-
@throws NullPointerException
-
if quat is null.<br />
*/
- public void setRotationQuaternion(Quaternion quat) {
-
quat.toRotationMatrix(this);<br />
- public Matrix4f setRotationQuaternion(Quaternion quat) {
-
return quat.toRotationMatrix(this);<br />
}
/**
@@ -1605,10 +1643,11 @@
*
-
@param angles
-
the Euler angles in radians.<br />
-
* @return this<br />
-
@throws JmeException
-
if angles is not size 3.<br />
*/
- public void setInverseRotationRadians(float[] angles) {
- public Matrix4f setInverseRotationRadians(float[] angles) {
if (angles.length != 3) { throw new IllegalArgumentException(
“Angles must be of size 3.”); }
double cr = FastMath.cos(angles[0]);
@@ -1632,6 +1671,8 @@
m02 = (float) (crsp * cy + sr * sy);
m12 = (float) (crsp * sy - sr * cy);
m22 = (float) (cr * cp);
+
-
return this;<br />
}
/**
@@ -1640,17 +1681,18 @@
*
-
@param angles
-
the Euler angles in degrees.<br />
-
* @return this<br />
-
@throws JmeException
-
if angles is not size 3.<br />
*/
- public void setInverseRotationDegrees(float[] angles) {
- public Matrix4f setInverseRotationDegrees(float[] angles) {
if (angles.length != 3) { throw new IllegalArgumentException(
“Angles must be of size 3.”); }
float vec[] = new float[3];
vec[0] = (angles[0] * FastMath.RAD_TO_DEG);
vec[1] = (angles[1] * FastMath.RAD_TO_DEG);
vec[2] = (angles[2] * FastMath.RAD_TO_DEG);
-
setInverseRotationRadians(vec);<br />
-
return setInverseRotationRadians(vec);<br />
}
/**
Index: src/core/com/jme3/math/Quaternion.java
===================================================================
— src/core/com/jme3/math/Quaternion.java (revision 5882)
+++ src/core/com/jme3/math/Quaternion.java (working copy)
@@ -133,12 +133,14 @@
-
the z value of the quaternion.<br />
-
@param w
-
the w value of the quaternion.<br />
-
* @return this<br />
*/
- public void set(float x, float y, float z, float w) {
- public Quaternion set(float x, float y, float z, float w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
-
return this;<br />
}
/**
@@ -148,7 +150,7 @@
*
-
@param q
-
The Quaternion to copy values from.<br />
-
* @return this for chaining<br />
-
* @return this<br />
*/
public Quaternion set(Quaternion q) {
this.x = q.x;
[/patch]