aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-14 08:05:07 +0100
committerSven Gothel <[email protected]>2014-03-14 08:05:07 +0100
commit70979247aad156418c32959bbf4962f175191ec2 (patch)
tree8b2bb8304424c77374c207748a54e42dcab4be01 /src/jogl/classes/com/jogamp/opengl/util
parentb3fb80b4e03818f1f7dfdddd1ffcb01e6a0a8acc (diff)
Quaternion: Fix and enhance class incl. Extensive Unit Tests (all passed)
- Add documentation incl references (Matrix-FAQ, Euclideanspace, ..) - Compared w/ other impl., i.e. WildMagic, Ardor3D, .. and added missing functionality incl unit tests. - PMVMatrix: Added convenient Quaternion 'hooks' - glRotate(Quaternion) - glLoadMatrix(Quaternion)
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
index 2001f8cdf..2d88f7937 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
@@ -48,6 +48,7 @@ import com.jogamp.common.nio.Buffers;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.FloatStack;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Quaternion;
import com.jogamp.opengl.math.geom.Frustum;
/**
@@ -535,6 +536,14 @@ public class PMVMatrix implements GLMatrixFunc {
m.position(spos);
}
+ /**
+ * Load the current matrix with the values of the given {@link Quaternion}'s rotation {@link Quaternion#toMatrix(float[], int) matrix representation}.
+ */
+ public final void glLoadMatrix(final Quaternion quat) {
+ quat.toMatrix(tmpMatrix, 0);
+ glLoadMatrixf(tmpMatrix, 0);
+ }
+
@Override
public final void glPopMatrix() {
final FloatStack stack;
@@ -637,6 +646,14 @@ public class PMVMatrix implements GLMatrixFunc {
glMultMatrixf(matrixRot, 0);
}
+ /**
+ * Rotate the current matrix with the given {@link Quaternion}'s rotation {@link Quaternion#toMatrix(float[], int) matrix representation}.
+ */
+ public final void glRotate(final Quaternion quat) {
+ quat.toMatrix(tmpMatrix, 0);
+ glMultMatrixf(tmpMatrix, 0);
+ }
+
@Override
public final void glScalef(final float x, final float y, final float z) {
// Scale matrix (Any Order):