diff --git a/src/java/org/lwjgl/vector/Matrix2f.java b/src/java/org/lwjgl/vector/Matrix2f.java index 71922777..33630ef3 100644 --- a/src/java/org/lwjgl/vector/Matrix2f.java +++ b/src/java/org/lwjgl/vector/Matrix2f.java @@ -74,6 +74,37 @@ public class Matrix2f { 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 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 @@ -165,14 +196,14 @@ public class Matrix2f { } /** - * 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; diff --git a/src/java/org/lwjgl/vector/Matrix3f.java b/src/java/org/lwjgl/vector/Matrix3f.java index 48ae3b85..9cf4bd47 100644 --- a/src/java/org/lwjgl/vector/Matrix3f.java +++ b/src/java/org/lwjgl/vector/Matrix3f.java @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + /** * $Id$ * @@ -77,6 +79,47 @@ public class Matrix3f { 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 @@ public class Matrix3f { } /** - * 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; diff --git a/src/java/org/lwjgl/vector/Matrix4f.java b/src/java/org/lwjgl/vector/Matrix4f.java index 51cf1053..dc9ebd8f 100644 --- a/src/java/org/lwjgl/vector/Matrix4f.java +++ b/src/java/org/lwjgl/vector/Matrix4f.java @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + /** * Holds a 4x4 float matrix. * @@ -124,6 +126,61 @@ public class Matrix4f { 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 @@ public class Matrix4f { } /** - * 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;