From: Caspian Rychlik-P. <ci...@us...> - 2002-08-24 21:26:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector In directory usw-pr-cvs1:/tmp/cvs-serv12723/src/java/org/lwjgl/vector Modified Files: Matrix2f.java Matrix4f.java Matrix3f.java Log Message: Load & store into FloatBuffers Index: Matrix2f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix2f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix2f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Matrix2f.java 24 Aug 2002 21:12:31 -0000 1.3 +++ Matrix2f.java 24 Aug 2002 21:26:47 -0000 1.4 @@ -75,6 +75,37 @@ } /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix2f load(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + */ + public void store(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m01); + buf.put(m11); + } + + + + /** * Add two matrices together and place the result in a third matrix. * @param left The left source matrix * @param right The right source matrix @@ -165,14 +196,14 @@ } /** - * Multiply a Vector by a matrix and return the result in a destination + * Transform a Vector by a matrix and return the result in a destination * vector. * @param left The left matrix * @param right The right vector * @param dest The destination vector, or null if a new one is to be created * @return the destination vector */ - public static Vector2f mul(Matrix2f left, Vector2f right, Vector2f dest) { + public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) { Vector2f temp = null; Index: Matrix4f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix4f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix4f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Matrix4f.java 24 Aug 2002 21:12:31 -0000 1.3 +++ Matrix4f.java 24 Aug 2002 21:26:47 -0000 1.4 @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + /** * Holds a 4x4 float matrix. * @@ -124,6 +126,61 @@ return this; } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix4f load(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m30 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m31 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + m32 = buf.get(); + m03 = buf.get(); + m13 = buf.get(); + m23 = buf.get(); + m33 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + */ + public void store(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m30); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m31); + buf.put(m02); + buf.put(m12); + buf.put(m22); + buf.put(m32); + buf.put(m03); + buf.put(m13); + buf.put(m23); + buf.put(m33); + } + + /** * Add two matrices together and place the result in a third matrix. * @param left The left source matrix @@ -253,14 +310,14 @@ } /** - * Multiply a Vector by a matrix and return the result in a destination + * Transform a Vector by a matrix and return the result in a destination * vector. * @param left The left matrix * @param right The right vector * @param dest The destination vector, or null if a new one is to be created * @return the destination vector */ - public static Vector4f mul(Matrix4f left, Vector4f right, Vector4f dest) { + public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest) { Vector4f temp = null; Index: Matrix3f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix3f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix3f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Matrix3f.java 24 Aug 2002 21:12:31 -0000 1.3 +++ Matrix3f.java 24 Aug 2002 21:26:47 -0000 1.4 @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + /** * $Id$ * @@ -77,6 +79,47 @@ return this; } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix3f load(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + */ + public void store(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m02); + buf.put(m12); + buf.put(m22); + } + + /** * Add two matrices together and place the result in a third matrix. @@ -193,14 +236,14 @@ } /** - * Multiply a Vector by a matrix and return the result in a destination + * Transform a Vector by a matrix and return the result in a destination * vector. * @param left The left matrix * @param right The right vector * @param dest The destination vector, or null if a new one is to be created * @return the destination vector */ - public static Vector3f mul(Matrix3f left, Vector3f right, Vector3f dest) { + public static Vector3f transform(Matrix3f left, Vector3f right, Vector3f dest) { Vector3f temp = null; |