diff options
190 files changed, 3511 insertions, 2421 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml index ee95eb642..e0dcc10ea 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -90,6 +90,9 @@ <property name="java.part.gluegen-gl-rt" value="com/jogamp/gluegen/runtime/opengl/*"/> + <property name="java.part.core.math" + value="com/jogamp/math/**"/> + <property name="java.part.core.shadercode" value="jogamp/opengl/shader/* jogamp/opengl/shader/bin/**"/> @@ -100,7 +103,7 @@ value="com/jogamp/opengl/util/* jogamp/opengl/util/* com/jogamp/opengl/util/glsl/* jogamp/opengl/util/glsl/* ${java.part.core.shadercode} ${java.part.core.assets}"/> <property name="java.part.core" - value="${java.part.gluegen-gl-rt} com/jogamp/opengl/* com/jogamp/opengl/fixedfunc/* com/jogamp/opengl/math/** jogamp/opengl/* ${java.part.core.util}"/> + value="${java.part.gluegen-gl-rt} ${java.part.core.math} com/jogamp/opengl/* com/jogamp/opengl/fixedfunc/* jogamp/opengl/* ${java.part.core.util}"/> <property name="java.part.core.exclude" value="com/jogamp/opengl/Debug* com/jogamp/opengl/Trace* com/jogamp/opengl/util/AWTAnimatorImpl* com/jogamp/opengl/util/PNG*"/> diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 566d19840..f714c9b2f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -583,24 +583,24 @@ function testawtswt() { # # Math # -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary32NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary64NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestMatrix4f01NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestMatrix4f02MulNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestMatrix4f03InversionNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestMatrix4fMatrixMulNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestMatrix4fProject01NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestMatrix4fProject02NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVTransform01NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestQuaternion01NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestVec3f01NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestBinary16NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestBinary32NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestBinary64NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestFloatUtil01NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestGluUnprojectFloatNOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestGluUnprojectDoubleNOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestMatrix4f01NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestMatrix4f02MulNOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestMatrix4f03InversionNOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestMatrix4fMatrixMulNOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestMatrix4fProject01NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestMatrix4fProject02NOUI $* +testnoawt com.jogamp.opengl.test.junit.math.TestPMVMatrix01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.math.TestPMVMatrix02NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestPMVMatrix03NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestPMVTransform01NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestQuaternion01NOUI $* +#testnoawt com.jogamp.opengl.test.junit.math.TestVec3f01NOUI $* # @@ -1009,7 +1009,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.demos.graph.ui.UIGraphDemoU01a $* #testnoawt com.jogamp.opengl.demos.graph.ui.UILayoutGrid01 $* #testnoawt com.jogamp.opengl.demos.graph.ui.UILayoutBox01 $* -testnoawt com.jogamp.opengl.demos.graph.ui.FontView01 $* +#testnoawt com.jogamp.opengl.demos.graph.ui.FontView01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT21 $* #testnoawt com.jogamp.opengl.demos.av.MovieCube $* @@ -1038,7 +1038,7 @@ testnoawt com.jogamp.opengl.demos.graph.ui.FontView01 $* # GLDrawableFactory.createOffscreenDrawable(..) # -#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT +#testnoawt com.jogamp.opengl.test.junit.math.TestPMVMatrix01NEWT #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java index c95d8447d..7fe8f821c 100644 --- a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java +++ b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java @@ -48,6 +48,11 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -61,11 +66,6 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.graph.TextRendererGLELBase; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; @@ -466,7 +466,7 @@ public class MovieSBSStereo implements StereoGLEventListener { final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); pmvMatrix = new PMVMatrix(); reshapePMV(viewPort.width(), viewPort.height()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } @@ -494,8 +494,8 @@ public class MovieSBSStereo implements StereoGLEventListener { System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]); final Vec3f winLB = new Vec3f(); final Vec3f winRT = new Vec3f(); - pmvMatrix.gluProject(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); - pmvMatrix.gluProject(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); + pmvMatrix.mapObjToWin(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); + pmvMatrix.mapObjToWin(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); System.err.println("XXX0: win LB: "+winLB); System.err.println("XXX0: win RT: "+winRT); } diff --git a/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java b/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java index 1097b37d8..d54498228 100644 --- a/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/av/StereoDemo01.java @@ -45,14 +45,14 @@ import com.jogamp.opengl.demos.util.QuitAdapter; import jogamp.opengl.util.stereo.GenericStereoDevice; import com.jogamp.common.net.Uri; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.opengl.util.stereo.StereoDeviceUtil; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.util.av.GLMediaPlayer; diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java index 235957c06..7de905d02 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java @@ -24,6 +24,10 @@ import java.nio.FloatBuffer; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.VersionUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.nativewindow.NativeWindow; import com.jogamp.newt.Window; import com.jogamp.newt.event.GestureHandler; @@ -49,9 +53,6 @@ import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.GearsObject; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.PMVMatrix; @@ -182,7 +183,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen public void setUseMappedBuffers(final boolean v) { useMappedBuffers = v; } public void setValidateBuffers(final boolean v) { validateBuffers = v; } - public PMVMatrix getPMVMatrix() { + public PMVMatrix4f getPMVMatrix() { return pmvMatrix; } @@ -239,9 +240,9 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); st.attachObject("pmvMatrix", pmvMatrix); - pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvitMat()); // P, Mv, Mvi and Mvit + pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvit()); // P, Mv, Mvi and Mvit st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java index 15f146a26..9b539ed61 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java @@ -31,6 +31,7 @@ import java.nio.FloatBuffer; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.VersionUtil; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -51,7 +52,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.demos.PointsDemo; import com.jogamp.opengl.demos.util.CommandlineOptions; @@ -121,7 +121,7 @@ public class PointsDemoES2 extends PointsDemo { pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java b/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java index da8235c8f..db35b6dc4 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/RedSquareES2.java @@ -126,7 +126,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java index 5aa43b073..70981a53d 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceCubeES2.java @@ -38,8 +38,8 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.common.os.Platform; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -225,7 +225,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { pmvMatrix = new PMVMatrix(); reshapePMV(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } diff --git a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java index 8496f3ee8..a8064db08 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/TextureSequenceES2.java @@ -31,6 +31,9 @@ package com.jogamp.opengl.demos.es2; import java.nio.FloatBuffer; import com.jogamp.common.os.Platform; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; @@ -40,9 +43,6 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -169,7 +169,7 @@ public class TextureSequenceES2 implements GLEventListener { final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); pmvMatrix = new PMVMatrix(); reshapePMV(viewPort.width(), viewPort.height()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } @@ -205,8 +205,8 @@ public class TextureSequenceES2 implements GLEventListener { System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]); final Vec3f winLB = new Vec3f(); final Vec3f winRT = new Vec3f(); - pmvMatrix.gluProject(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); - pmvMatrix.gluProject(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); + pmvMatrix.mapObjToWin(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB); + pmvMatrix.mapObjToWin(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT); System.err.println("XXX0: win LB: "+winLB); System.err.println("XXX0: win RT: "+winRT); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java index 866d6623d..1f49bf8f5 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener00.java @@ -33,10 +33,11 @@ import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Vec4f; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.Vec4f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.util.PMVMatrix; @@ -117,11 +118,10 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java index e5699a2d6..413adca80 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener01.java @@ -32,12 +32,13 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Vec4f; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.geom.plane.Path2F; -import com.jogamp.graph.geom.plane.WindingRule; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.plane.Path2F; +import com.jogamp.math.geom.plane.WindingRule; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.util.PMVMatrix; @@ -282,11 +283,10 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java index 42b42a719..a802ce386 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURegionGLListener10.java @@ -41,6 +41,7 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.opengl.util.PMVMatrix; @@ -123,11 +124,10 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java index 8655def4a..ebc8846e3 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPURendererListenerBase01.java @@ -39,23 +39,22 @@ import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * @@ -110,7 +109,8 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { public final float getZTran() { return zTran; } public final float getXTran() { return xTran; } public final float getYTran() { return yTran; } - public final float getAngle() { return ang; } + public final float getAngleDeg() { return ang; } + public final float getAngleRad() { return FloatUtil.adegToRad(ang); } public final int[] getSampleCount() { return sampleCount; } public final float[] getPosition() { return position; } @@ -149,20 +149,19 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { getRenderer().init(gl); } - public static void mapWin2ObjectCoords(final PMVMatrix pmv, final Recti view, + public static void mapWin2ObjectCoords(final PMVMatrix4f pmv, final Recti view, final float zNear, final float zFar, final float orthoX, final float orthoY, final float orthoDist, final float[] winZ, final Vec3f objPos) { winZ[0] = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar); - pmv.gluUnProject(orthoX, orthoY, winZ[0], view, objPos); + pmv.mapWinToObj(orthoX, orthoY, winZ[0], view, objPos); } @Override public void reshape(final GLAutoDrawable drawable, final int xstart, final int ystart, final int width, final int height) { - final PMVMatrix pmv = renderer.getMatrix(); + final PMVMatrix4f pmv = renderer.getMatrix(); renderer.reshapePerspective(FloatUtil.QUARTER_PI, width, height, zNear, zFar); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + pmv.loadMvIdentity(); System.err.printf("Reshape: zNear %f, zFar %f%n", zNear, zFar); System.err.printf("Reshape: Frustum: %s%n", pmv.getFrustum()); { diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java index 0c85ca1a0..25eae1156 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextNewtDemo.java @@ -30,7 +30,6 @@ package com.jogamp.opengl.demos.graph; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.geom.AABBox; import java.io.File; import java.io.IOException; @@ -40,6 +39,7 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; diff --git a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java index a5fac1270..16d8aa1db 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/GPUTextRendererListenerBase01.java @@ -35,7 +35,6 @@ import com.jogamp.opengl.GLAnimatorControl; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; @@ -46,14 +45,13 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; /** * @@ -302,9 +300,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; final RegionRenderer renderer = getRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); final float pixelSizeFName = FontScale.toPixels(fontSizeFName, dpiV); final float pixelSizeHead = FontScale.toPixels(fontSizeHead, dpiV); @@ -315,7 +312,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB renderer.enable(gl, true); if( drawFPS ) { - pmv.glPushMatrix(); + pmv.pushMv(); final float pixelSizeFPS = FontScale.toPixels(fontSizeFPS, dpiV); final float lfps, tfps; final GLAnimatorControl animator = drawable.getAnimator(); @@ -336,58 +333,58 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB drawable.getChosenGLCapabilities().getAlphaBits()); // bottom, half line up - pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); + pmv.translateMv(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeFPS; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // No cache, keep region alive! TextRegionUtil.drawString3D(gl, regionFPS.clear(gl), renderer, font, text, null, sampleCountFPS, tempT1, tempT2); - pmv.glPopMatrix(); + pmv.popMv(); } // float dx = width - ( fontNameBox.getWidth() + font.getAdvanceWidth( Glyph.ID_SPACE ) ) * pixelSizeFName; float dx = width - ( fontNameBox.getWidth() + 2 * font.getAdvanceWidth( font.getGlyphID('X') ) ) * pixelSizeFName; float dy = height - fontNameBox.getHeight() * pixelSizeFName; { - pmv.glPushMatrix(); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.pushMv(); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeFName; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // System.err.printf("FontN: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); textRegionUtil.drawString3D(gl, renderer, font, fontName, null, getSampleCount()); - pmv.glPopMatrix(); + pmv.popMv(); } dx = 10f; dy += -fontNameBox.getHeight() * pixelSizeFName - 10f; if(null != headtext) { - pmv.glPushMatrix(); + pmv.pushMv(); // System.err.printf("Head: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeHead; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // pmv.glTranslatef(x0, y1, z0); textRegionUtil.drawString3D(gl, renderer, font, headtext, null, getSampleCount()); - pmv.glPopMatrix(); + pmv.popMv(); } dy += ( -headbox.getHeight() - font.getLineHeight() ) * pixelSizeCenter; { - pmv.glPushMatrix(); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.pushMv(); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); // System.err.printf("Bottom: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); { final float sxy = nearPlaneS * pixelSizeCenter; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } renderer.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); @@ -407,7 +404,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRegionUtil.drawString3D(gl, renderer, font, userString.toString(), null, getSampleCount()); } } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); } @@ -488,7 +485,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB public boolean isUserInputMode() { return userInput; } void dumpMatrix(final boolean bbox) { - System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngle() +" fontSize "+fontSizeCenter); + System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngleDeg() +" fontSize "+fontSizeCenter); if(bbox) { System.err.println("bbox em: "+font.getMetricBounds(text2)); System.err.println("bbox px: "+font.getMetricBounds(text2).scale( nearPlaneS * FontScale.toPixels(fontSizeCenter, dpiV) ) ); diff --git a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java index 438457993..1f89fb40e 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java +++ b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java @@ -32,7 +32,6 @@ import java.io.IOException; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; @@ -42,9 +41,9 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; -import com.jogamp.opengl.util.PMVMatrix; public abstract class TextRendererGLELBase implements GLEventListener { public final int renderModes; @@ -53,7 +52,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { protected final float[] staticRGBAColor = new float[] { 1f, 1f, 1f, 1f }; private boolean exclusivePMVMatrix = true; - private PMVMatrix sharedPMVMatrix = null; + private PMVMatrix4f sharedPMVMatrix = null; private RegionRenderer.GLCallback enableCallback=null, disableCallback=null; protected RegionRenderer renderer = null; protected TextRegionUtil textRenderUtil = null; @@ -105,7 +104,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { * Must be called before {@link #init(GLAutoDrawable)}. * </p> */ - public void setSharedPMVMatrix(final PMVMatrix pmv) { + public void setSharedPMVMatrix(final PMVMatrix4f pmv) { this.sharedPMVMatrix = pmv; } @@ -125,7 +124,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { public final TextRegionUtil getTextRenderUtil() { return textRenderUtil; } public int[] getVBAASampleCount() { return this.vbaaSampleCount; } - public PMVMatrix getMatrix() { return renderer.getMatrix(); }; + public PMVMatrix4f getMatrix() { return renderer.getMatrix(); }; public boolean isMatrixShared() { return !exclusivePMVMatrix; }; @Override @@ -249,18 +248,17 @@ public abstract class TextRendererGLELBase implements GLEventListener { dx += sxy * font.getAdvanceWidth('X') * column; dy -= sxy * lineHeight * ( row + 1 ); - final PMVMatrix pmvMatrix = getMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmvMatrix = getMatrix(); if( !exclusivePMVMatrix ) { - pmvMatrix.glPushMatrix(); + pmvMatrix.pushMv(); } else { - pmvMatrix.glLoadIdentity(); + pmvMatrix.loadMvIdentity(); } - pmvMatrix.glTranslatef(dx, dy, tz); + pmvMatrix.translateMv(dx, dy, tz); if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { - pmvMatrix.glScalef(sxy, -1f*sxy, 1.0f); + pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f); } else { - pmvMatrix.glScalef(sxy, sxy, 1.0f); + pmvMatrix.scaleMv(sxy, sxy, 1.0f); } renderer.enable(gl, true); if( cacheRegion ) { @@ -273,7 +271,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { renderer.enable(gl, false); if( !exclusivePMVMatrix ) { - pmvMatrix.glPopMatrix(); + pmvMatrix.popMv(); } lastRow = row + newLineCount; } @@ -299,25 +297,24 @@ public abstract class TextRendererGLELBase implements GLEventListener { dx += sxy * font.getAdvanceWidth('X') * column; dy -= sxy * lineHeight * ( row + 1 ); - final PMVMatrix pmvMatrix = getMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmvMatrix = getMatrix(); if( !exclusivePMVMatrix ) { - pmvMatrix.glPushMatrix(); + pmvMatrix.pushMv(); } else { - pmvMatrix.glLoadIdentity(); + pmvMatrix.loadMvIdentity(); } - pmvMatrix.glTranslatef(dx, dy, tz); + pmvMatrix.translateMv(dx, dy, tz); if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { - pmvMatrix.glScalef(sxy, -1f*sxy, 1.0f); + pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f); } else { - pmvMatrix.glScalef(sxy, sxy, 1.0f); + pmvMatrix.scaleMv(sxy, sxy, 1.0f); } renderer.enable(gl, true); region.draw(gl, renderer, vbaaSampleCount); renderer.enable(gl, false); if( !exclusivePMVMatrix ) { - pmvMatrix.glPopMatrix(); + pmvMatrix.popMv(); } } } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java index de4d616ba..c045342a1 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java @@ -51,6 +51,8 @@ import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.GlyphShape; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.Vec2i; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -67,8 +69,6 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.Vec2i; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; /** diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java index d515896b8..f22177a18 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java @@ -37,9 +37,18 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; import com.jogamp.graph.ui.shapes.CrossHair; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec2i; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -52,17 +61,7 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec2i; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Graph + GraphUI integration demo @@ -238,20 +237,19 @@ public class UIGraphDemoU01a { shape.setScale(s, s, 1f); } } - private void setMatrix(final PMVMatrix pmv, final Recti viewport) { - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); + private void setMatrix(final PMVMatrix4f pmv, final Recti viewport) { + pmv.loadPIdentity(); final float ratio = (float)viewport.width()/(float)viewport.height(); if( projOrthoWin ) { worldDim.setX( viewport.width() ); worldDim.setY( worldDim.x() / ratio ); // adjust aspect ratio - pmv.glOrthof(0, worldDim.x(), 0, worldDim.y(), zNear, zFar); + pmv.orthoP(0, worldDim.x(), 0, worldDim.y(), zNear, zFar); // similar: renderer.reshapeOrtho(viewport.width(), viewport.height(), zNear, zFar); } else if( projOrtho ) { worldDim.setY( worldDim.x() / ratio ); // adjust aspect ratio - pmv.glOrthof(-worldDim.x()/2f, worldDim.x()/2f, -worldDim.y()/2f, worldDim.y()/2f, zNear, zFar); + pmv.orthoP(-worldDim.x()/2f, worldDim.x()/2f, -worldDim.y()/2f, worldDim.y()/2f, zNear, zFar); } else { - pmv.gluPerspective(angle, ratio, zNear, zFar); + pmv.perspectiveP(angle, ratio, zNear, zFar); { final Vec3f obj00Coord = new Vec3f(); final Vec3f obj11Coord = new Vec3f(); @@ -264,15 +262,14 @@ public class UIGraphDemoU01a { worldDim.set(planeBox.getWidth(), planeBox.getHeight()); } } - pmv.glTranslatef(0f, 0f, sceneDist); // nose to plane + pmv.translateP(0f, 0f, sceneDist); // nose to plane - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + pmv.loadMvIdentity(); winToPlaneCoord(pmv, viewport, zNear, zFar, winOrigin.x(), winOrigin.y(), -sceneDist, worldOrigin); { - final Matrix4f p = pmv.getPMat(); - final Matrix4f mv = pmv.getMvMat(); + final Matrix4f p = pmv.getP(); + final Matrix4f mv = pmv.getMv(); System.err.println("Reshape VP: "+viewport); System.err.println("Reshape P :"); System.err.println(p.toString()); System.err.println("Reshape Mv:"); System.err.println(mv.toString()); @@ -280,14 +277,14 @@ public class UIGraphDemoU01a { System.err.println("Window Origin: "+winOrigin); System.err.println("World Origin : "+worldOrigin); } - pmv.glTranslatef(worldOrigin.x(), worldOrigin.y(), 0); // move to custom origin + pmv.translateMv(worldOrigin.x(), worldOrigin.y(), 0); // move to custom origin } - public static void winToPlaneCoord(final PMVMatrix pmv, final Recti viewport, + public static void winToPlaneCoord(final PMVMatrix4f pmv, final Recti viewport, final float zNear, final float zFar, final float winX, final float winY, final float objOrthoZ, final Vec3f objPos) { final float winZ = FloatUtil.getOrthoWinZ(objOrthoZ, zNear, zFar); - pmv.gluUnProject(winX, winY, winZ, viewport, objPos); + pmv.mapWinToObj(winX, winY, winZ, viewport, objPos); } @Override @@ -297,30 +294,29 @@ public class UIGraphDemoU01a { gl.glClearColor(1f, 1f, 1f, 1f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmv = renderer.getMatrix(); if( onceAtDisplay ) { - final Matrix4f p = pmv.getPMat(); - final Matrix4f mv = pmv.getMvMat(); + final Matrix4f p = pmv.getP(); + final Matrix4f mv = pmv.getMv(); System.err.println("Display.0: P :"); System.err.println(p.toString()); System.err.println("Display.0: Mv:"); System.err.println(mv.toString()); } renderer.enable(gl, true); { - pmv.glPushMatrix(); + pmv.pushMv(); drawText(gl, pmv, " Hello JogAmp Users!"); - pmv.glPopMatrix(); + pmv.popMv(); } if( !textOnly ) { - pmv.glPushMatrix(); - shape.setTransform(pmv); + pmv.pushMv(); + shape.setMvTransform(pmv); shape.draw(gl, renderer, sampleCount); if( onceAtDisplay ) { - final Matrix4f p = pmv.getPMat(); - final Matrix4f mv = pmv.getMvMat(); + final Matrix4f p = pmv.getP(); + final Matrix4f mv = pmv.getMv(); System.err.println("Display.1: P :"); System.err.println(p.toString()); System.err.println("Display.1: Mv:"); System.err.println(mv.toString()); System.err.println("Display.1: Shape bounds "+shape.getBounds(drawable.getGLProfile())); @@ -328,12 +324,12 @@ public class UIGraphDemoU01a { final Recti shapePort = shape.getSurfacePort(pmv, renderer.getViewport(), new Recti()); System.err.println("Display.1: Shape SurfacePort "+shapePort); } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); onceAtDisplay = false; } - private void drawText(final GL2ES2 gl, final PMVMatrix pmv, final String text) { + private void drawText(final GL2ES2 gl, final PMVMatrix4f pmv, final String text) { final AffineTransform tempT1 = new AffineTransform(); final AffineTransform tempT2 = new AffineTransform(); @@ -341,8 +337,8 @@ public class UIGraphDemoU01a { final float full_width_s = worldDim.x() / txt_box_em.getWidth(); final float full_height_s = worldDim.y() / txt_box_em.getHeight(); final float txt_scale = full_width_s < full_height_s ? full_width_s * normWidgetSize : full_height_s * normWidgetSize; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, textRegion.clear(gl), renderer, font, text, text_color, sampleCount, tempT1, tempT2); if( onceAtDisplay ) { @@ -351,7 +347,7 @@ public class UIGraphDemoU01a { System.err.println("XXX: txt_scale: "+txt_scale); System.err.println("XXX: txt_box_em "+txt_box_em); System.err.println("XXX: txt_box_r "+txt_box_r); - final AABBox textPort = txt_box_r.mapToWindow(new AABBox(), pmv.getPMvMat(), renderer.getViewport(), true /* useCenterZ */); + final AABBox textPort = txt_box_r.mapToWindow(new AABBox(), pmv.getPMv(), renderer.getViewport(), true /* useCenterZ */); System.err.println("Display.1: Shape TextPort "+textPort); final Font.GlyphVisitor visitor = new Font.GlyphVisitor() { diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java index 1da3ec886..396e5b07b 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutBox01.java @@ -35,7 +35,6 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; @@ -45,6 +44,11 @@ import com.jogamp.graph.ui.layout.Margin; import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.graph.ui.shapes.BaseButton; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; @@ -56,10 +60,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; /** diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java index 2e97c839a..ac2663c43 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UILayoutGrid01.java @@ -33,7 +33,6 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; @@ -43,6 +42,11 @@ import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -52,10 +56,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.graph.ui.util.Tooltips; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; /** diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java index 08e5ba7fd..9ab65d3d7 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java @@ -37,6 +37,9 @@ import com.jogamp.graph.font.FontSet; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -44,11 +47,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement within one main function. @@ -125,7 +124,7 @@ public class UISceneDemo00 { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - shape.getScaledWidth(); - final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = shape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -172,7 +171,7 @@ public class UISceneDemo00 { static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height. @@ -181,9 +180,7 @@ public class UISceneDemo00 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy, sxy, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy, sxy, 1f); } }; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java index 83092d366..3f0bbce1c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java @@ -36,8 +36,10 @@ import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; -import com.jogamp.graph.ui.Scene.PMVMatrixSetup; import com.jogamp.graph.ui.shapes.GLButton; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -47,11 +49,7 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.es2.GearsES2; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement. @@ -133,7 +131,7 @@ public class UISceneDemo01 { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - shape.getScaledWidth(); - final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = shape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -180,7 +178,7 @@ public class UISceneDemo01 { static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 100 for the greater of width and height. @@ -189,9 +187,7 @@ public class UISceneDemo01 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy / 100f, sxy / 100f, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy / 100f, sxy / 100f, 1f); } }; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java index 10803e256..c6e09fa5c 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java @@ -38,6 +38,9 @@ import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.GLButton; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -46,10 +49,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement. @@ -134,7 +134,7 @@ public class UISceneDemo01b { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - shape.getScaledWidth(); - final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = shape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = shape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -173,8 +173,8 @@ public class UISceneDemo01b { shape.getRotation().rotateByAngleY(rad); } System.err.println("Shape "+shape); - final PMVMatrix pmv = new PMVMatrix(); - shape.setTransform(pmv); + final PMVMatrix4f pmv = new PMVMatrix4f(); + shape.setMvTransform(pmv); System.err.println("Shape "+pmv); } } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java index f2fe509b2..3e5ee2171 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java @@ -36,6 +36,8 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; @@ -46,9 +48,7 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent Shape, Scene attached to GLWindow showing simple linear Shape movement. @@ -210,7 +210,7 @@ public class UISceneDemo02 { final float end_pos = sceneBox.getMinX() + ( destText.getText().length() == 0 ? 0 : destText.getScaledWidth() ); movingGlyph.moveTo(start_pos, 0f, 0f); - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final int[] destTextSizePx = destText.getSurfaceSize(scene, pmv, new int[2]); // [px] final int[] movingGlyphSizePx = movingGlyph.getSurfaceSize(scene, pmv, new int[2]); // [px] final float[] movingGlyphPixPerShapeUnit = movingGlyph.getPixelPerShapeUnit(movingGlyphSizePx, new float[2]); // [px]/[shapeUnit] diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java index b288ddb48..4a42209ae 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java @@ -50,6 +50,11 @@ import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -69,11 +74,6 @@ import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java index 6f720cb3e..f1bdb1e08 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java @@ -43,6 +43,10 @@ import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.CrossHair; import com.jogamp.graph.ui.shapes.GLButton; import com.jogamp.graph.ui.shapes.MediaButton; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -56,12 +60,7 @@ import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.es2.GearsES2; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; @@ -202,7 +201,7 @@ public class UISceneDemo10 { } static void testProject(final Scene scene, final Shape shape, final int glWinX, final int glWinY) { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final Vec3f objPos = shape.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, new Vec3f()); System.err.printf("MM1: winToObjCoord: obj %s%n", objPos); final int[] glWinPos = shape.shapeToWinCoord(scene.getPMVMatrixSetup(), scene.getViewport(), objPos, pmv, new int[2]); @@ -268,7 +267,7 @@ public class UISceneDemo10 { } static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height. @@ -277,9 +276,7 @@ public class UISceneDemo10 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy, sxy, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy, sxy, 1f); } }; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java index 120ab6203..140ce2e3a 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java @@ -41,6 +41,9 @@ import com.jogamp.graph.ui.layout.Alignment; import com.jogamp.graph.ui.layout.Gap; import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.shapes.Button; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; @@ -48,11 +51,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.demos.util.CommandlineOptions; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; /** * Res independent {@link Shape}s in a {@link Group} using a {@link GridLayout}, contained within a Scene attached to GLWindow. @@ -158,7 +157,7 @@ public class UISceneDemo11 { final float min_obj = sceneBox.getMinX(); final float max_obj = sceneBox.getMaxX() - mobileShape.getScaledWidth(); - final int[] shapeSizePx = mobileShape.getSurfaceSize(scene, new PMVMatrix(), new int[2]); // [px] + final int[] shapeSizePx = mobileShape.getSurfaceSize(scene, new PMVMatrix4f(), new int[2]); // [px] final float[] pixPerShapeUnit = mobileShape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit] final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm] @@ -208,7 +207,7 @@ public class UISceneDemo11 { } static class MyPMVMatrixSetup extends Scene.DefaultPMVMatrixSetup { @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { super.set(pmv, viewport); // Scale (back) to have normalized plane dimensions, 1 for the greater of width and height. @@ -217,9 +216,7 @@ public class UISceneDemo11 { final float sx = planeBox0.getWidth(); final float sy = planeBox0.getHeight(); final float sxy = sx > sy ? sx : sy; - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glScalef(sxy, sxy, 1f); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.scaleP(sxy, sxy, 1f); } }; } diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java index 6204cd501..837d5770d 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java @@ -56,6 +56,10 @@ import com.jogamp.graph.ui.shapes.GLButton; import com.jogamp.graph.ui.shapes.ImageButton; import com.jogamp.graph.ui.shapes.Label; import com.jogamp.graph.ui.shapes.MediaButton; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.ui.shapes.BaseButton; import com.jogamp.nativewindow.ScalableSurface; import com.jogamp.newt.Display; @@ -85,11 +89,7 @@ import com.jogamp.opengl.demos.graph.FontSetDemos; import com.jogamp.opengl.demos.graph.MSAATool; import com.jogamp.opengl.demos.util.CommandlineOptions; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayer.EventMask; import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; @@ -435,7 +435,7 @@ public class UISceneDemo20 implements GLEventListener { final com.jogamp.openal.sound3d.Source aSource) { AABBox worldBounds; { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); worldBounds = scene.getBounds(pmv, shape); } context.makeCurrent(true); @@ -793,7 +793,7 @@ public class UISceneDemo20 implements GLEventListener { if( e.getPointerCount() == 1 ) { final AABBox worldBounds; { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); worldBounds = scene.getBounds(pmv, shapeEvent.shape); } actionText = String.format((Locale)null, "Pos %s", worldBounds.getCenter()); @@ -1168,7 +1168,7 @@ public class UISceneDemo20 implements GLEventListener { if( e.getPointerCount() == 1 ) { final AABBox worldBounds; { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); worldBounds = scene.getBounds(pmv, shapeEvent.shape); } actionText = String.format((Locale)null, "Pos %s", worldBounds.getCenter()); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java index cc918c9fe..e34e2dec7 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java @@ -42,12 +42,6 @@ import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.demos.graph.MSAATool; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -55,10 +49,16 @@ import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.CrossHair; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -70,7 +70,6 @@ import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * Basic UIShape and Type Rendering demo. @@ -224,10 +223,9 @@ public class UIShapeDemo01 implements GLEventListener { rRenderer.reshapePerspective(FloatUtil.QUARTER_PI, width, height, zNear, zFar); // rRenderer.reshapeOrtho(width, height, zNear, zFar); - final PMVMatrix pmv = rRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = rRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); if( drawable instanceof Window ) { ((Window)drawable).setTitle(UIShapeDemo01.class.getSimpleName()+": "+drawable.getSurfaceWidth()+" x "+drawable.getSurfaceHeight()); @@ -237,9 +235,9 @@ public class UIShapeDemo01 implements GLEventListener { final int[] sampleCount = { 4 }; private void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final Shape shape) { - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glPushMatrix(); - shape.setTransform(pmv); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.pushMv(); + shape.setMvTransform(pmv); shape.draw(gl, renderer, sampleCount); if( once ) { System.err.println("draw.0: "+shape); @@ -248,7 +246,7 @@ public class UIShapeDemo01 implements GLEventListener { final int[] winPos = shape.shapeToWinCoord(pmv, renderer.getViewport(), shape.getPosition(), new int[2]); System.err.println("draw.2: winCoord "+winPos[0]+" x "+winPos[1]); } - pmv.glPopMatrix(); + pmv.popMv(); } @Override @@ -259,7 +257,7 @@ public class UIShapeDemo01 implements GLEventListener { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); + final PMVMatrix4f pmv = renderer.getMatrix(); renderer.enable(gl, true); drawShape(gl, renderer, button); drawShape(gl, renderer, crossHair); @@ -273,14 +271,14 @@ public class UIShapeDemo01 implements GLEventListener { final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar); final Vec3f objCoord0 = new Vec3f(); final Vec3f objCoord1 = new Vec3f(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord0); } } glWinX = drawable.getSurfaceWidth(); glWinY = drawable.getSurfaceHeight(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1); } @@ -290,9 +288,9 @@ public class UIShapeDemo01 implements GLEventListener { final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2); final float full_width_s = full_width_o / txt_box_em.getWidth(); final float txt_scale = full_width_s/2f; - pmv.glPushMatrix(); - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.pushMv(); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, new Vec4f( 0, 0, 0, 1 ), sampleCount, tempT1, tempT2); if( once ) { final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); @@ -302,7 +300,7 @@ public class UIShapeDemo01 implements GLEventListener { System.err.println("XXX: txt_box_rg "+txt_box_r); once = false; } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); } @@ -384,10 +382,9 @@ public class UIShapeDemo01 implements GLEventListener { System.err.println("\n\nMouse: "+e); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); // flip to GL window coordinates, origin bottom-left final Recti viewport = renderer.getViewport(new Recti()); @@ -395,8 +392,8 @@ public class UIShapeDemo01 implements GLEventListener { final int glWinY = viewport.height() - e.getY() - 1; { - pmv.glPushMatrix(); - button.setTransform(pmv); + pmv.pushMv(); + button.setMvTransform(pmv); System.err.println("\n\nButton: "+button); final Vec3f objPos = button.winToShapeCoord(pmv, viewport, glWinX, glWinY, new Vec3f()); @@ -409,11 +406,11 @@ public class UIShapeDemo01 implements GLEventListener { System.err.println("Button: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); } - pmv.glPopMatrix(); + pmv.popMv(); } { - pmv.glPushMatrix(); - crossHair.setTransform(pmv); + pmv.pushMv(); + crossHair.setMvTransform(pmv); final Vec3f objPosC = crossHair.getBounds().getCenter(); System.err.println("\n\nCrossHair: "+crossHair); @@ -439,7 +436,7 @@ public class UIShapeDemo01 implements GLEventListener { final int[] surfaceSize = crossHair.getSurfaceSize(pmv, viewport, new int[2]); System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - pmv.glPopMatrix(); + pmv.popMv(); } return true; } } ); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java index ecd7b1ccf..b89082d6d 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java @@ -39,10 +39,16 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.CrossHair; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -66,15 +72,8 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.demos.graph.MSAATool; import com.jogamp.opengl.demos.graph.ui.testshapes.Glyph03FreeMonoRegular_M; import com.jogamp.opengl.demos.util.MiscUtils; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * Basic UIShape and Type Rendering demo. @@ -257,11 +256,11 @@ public class UITypeDemo01 implements GLEventListener { final int[] sampleCount = { 4 }; - private void drawShape(final GL2ES2 gl, final PMVMatrix pmv, final RegionRenderer renderer, final Shape shape) { - pmv.glPushMatrix(); - shape.setTransform(pmv); + private void drawShape(final GL2ES2 gl, final PMVMatrix4f pmv, final RegionRenderer renderer, final Shape shape) { + pmv.pushMv(); + shape.setMvTransform(pmv); shape.draw(gl, renderer, sampleCount); - pmv.glPopMatrix(); + pmv.popMv(); } @Override @@ -272,16 +271,15 @@ public class UITypeDemo01 implements GLEventListener { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); renderer.enable(gl, true); { - pmv.glPushMatrix(); - pmv.glScalef(0.8f, 0.8f, 1f); + pmv.pushMv(); + pmv.scaleMv(0.8f, 0.8f, 1f); drawShape(gl, pmv, renderer, testObj); - pmv.glPopMatrix(); + pmv.popMv(); } drawShape(gl, pmv, renderer, crossHair); { @@ -294,14 +292,14 @@ public class UITypeDemo01 implements GLEventListener { final float winZ = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar); final Vec3f objCoord0 = new Vec3f(); final Vec3f objCoord1 = new Vec3f(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord0) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord0); } } glWinX = drawable.getSurfaceWidth(); glWinY = drawable.getSurfaceHeight(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { + if( pmv.mapWinToObj(glWinX, glWinY, winZ, renderer.getViewport(), objCoord1) ) { if( once ) { System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%s]%n", glWinX, glWinY, winZ, objCoord1); } @@ -309,7 +307,7 @@ public class UITypeDemo01 implements GLEventListener { full_width_o = objCoord1.x() - objCoord0.x(); full_height_o = objCoord1.y() - objCoord0.y(); } - pmv.glPushMatrix(); + pmv.pushMv(); final Font.Glyph glyph; if( Glyph.ID_UNKNOWN < glyph_id ) { @@ -325,8 +323,8 @@ public class UITypeDemo01 implements GLEventListener { final float full_width_s = full_width_o / txt_box_em.getWidth(); final float full_height_s = full_height_o / txt_box_em.getHeight(); final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); if( null != glyph.getShape() ) { final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null, glyph.getShape()); region.addOutlineShape(glyph.getShape(), null, fg_color); @@ -346,8 +344,8 @@ public class UITypeDemo01 implements GLEventListener { final float full_width_s = full_width_o / txt_box_em.getWidth(); final float full_height_s = full_height_o / txt_box_em.getHeight(); final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + pmv.scaleMv(txt_scale, txt_scale, 1f); + pmv.translateMv(-txt_box_em.getWidth(), 0f, 0f); final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, fg_color, sampleCount, tempT1, tempT2); if( once ) { final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); @@ -359,7 +357,7 @@ public class UITypeDemo01 implements GLEventListener { System.err.println("XXX: txt_box_rg "+txt_box_r); } } - pmv.glPopMatrix(); + pmv.popMv(); if( once ) { try { printScreen(drawable); @@ -454,10 +452,9 @@ public class UITypeDemo01 implements GLEventListener { System.err.println("\n\nMouse: "+e); final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(xTran, yTran, zTran); // flip to GL window coordinates, origin bottom-left final Recti viewport = renderer.getViewport(new Recti()); @@ -465,8 +462,8 @@ public class UITypeDemo01 implements GLEventListener { final int glWinY = viewport.height() - e.getY() - 1; { - pmv.glPushMatrix(); - crossHair.setTransform(pmv); + pmv.pushMv(); + crossHair.setMvTransform(pmv); final Vec3f objPosC = crossHair.getBounds().getCenter(); System.err.println("\n\nCrossHair: "+crossHair); @@ -493,7 +490,7 @@ public class UITypeDemo01 implements GLEventListener { final int[] surfaceSize = crossHair.getSurfaceSize(pmv, viewport, new int[2]); System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - pmv.glPopMatrix(); + pmv.popMv(); } return true; } } ); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java b/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java index 5af14cb45..9b8b8cbdb 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph01UbuntuLight_o.java @@ -28,8 +28,8 @@ package com.jogamp.opengl.demos.graph.ui.testshapes; import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.geom.plane.Winding; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.math.geom.plane.Winding; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java b/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java index aaf1bba20..08fa684f4 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/util/Tooltips.java @@ -33,10 +33,10 @@ import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.shapes.Button; import com.jogamp.graph.ui.shapes.Label; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.texture.TextureSequence; public class Tooltips { diff --git a/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java b/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java index f0c2f9df4..d6cbacd18 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java +++ b/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java @@ -36,20 +36,20 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.Group.Layout; import com.jogamp.graph.ui.shapes.GlyphShape; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; /** * Group of animated {@link Shape}s including other static {@link Shape}s, optionally utilizing a {@link Group.Layout}. @@ -304,13 +304,13 @@ public class AnimGroup extends Group { /** * Add a new {@link Set} with an empty {@link ShapeData} container. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * only, without a shape's {@link #setTransform(PMVMatrix)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * only, without a shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * </p> * @param pixPerMM monitor pixel per millimeter for accurate animation * @param glp used {@link GLProfile} - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * @param viewport the int[4] viewport * @param accel translation acceleration in [m]/[s*s] * @param velocity translation velocity in [m]/[s] @@ -322,21 +322,21 @@ public class AnimGroup extends Group { * @return a new {@link Set} instance */ public Set addAnimSet(final float pixPerMM, - final GLProfile glp, final PMVMatrix pmv, final Recti viewport, - final float accel, final float velocity, - final float ang_accel, final float ang_velo, - final LerpFunc lerp, final Shape refShape) + final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, + final float accel, final float velocity, + final float ang_accel, final float ang_velo, + final LerpFunc lerp, final Shape refShape) { final Set as; refShape.validate(glp); - pmv.glPushMatrix(); + pmv.pushMv(); { - refShape.setTransform(pmv); + refShape.setMvTransform(pmv); as = new Set(pixPerMM, refShape.getPixelPerShapeUnit(pmv, viewport, new float[2]), refShape, accel, velocity, ang_accel, ang_velo, new ArrayList<ShapeData>(), new AABBox(), lerp); } - pmv.glPopMatrix(); + pmv.popMv(); animSets.add(as); return as; } @@ -345,13 +345,13 @@ public class AnimGroup extends Group { * Add a new {@link Set} with {@link ShapeData} for each {@link GlyphShape}, moving towards its target position * using a generic displacement via {@link ShapeSetup} to determine each {@link ShapeData}'s starting position. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * only, without a shape's {@link #setTransform(PMVMatrix)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * only, without a shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * </p> * @param pixPerMM monitor pixel per millimeter for accurate animation * @param glp used {@link GLProfile} - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * @param viewport the int[4] viewport * @param renderModes used {@link GLRegion#create(GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence) region render-modes} * @param font {@link Font} to be used for resulting {@link GlyphShape}s @@ -367,10 +367,10 @@ public class AnimGroup extends Group { * @return newly created and added {@link Set} */ public final Set addGlyphSet(final float pixPerMM, - final GLProfile glp, final PMVMatrix pmv, final Recti viewport, final int renderModes, - final Font font, final char refChar, final CharSequence text, final float fontScale, - final float accel, final float velocity, final float ang_accel, final float ang_velo, - final LerpFunc lerp, final ShapeSetup op) + final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, + final Font font, final char refChar, final CharSequence text, final float fontScale, + final float accel, final float velocity, final float ang_accel, final float ang_velo, + final LerpFunc lerp, final ShapeSetup op) { final Set as; { @@ -379,13 +379,13 @@ public class AnimGroup extends Group { final GlyphShape refShape = new GlyphShape(renderModes, font, refChar, 0, 0); refShape.setScale(fontScale, fontScale, 1f); refShape.validate(glp); - pmv.glPushMatrix(); + pmv.pushMv(); { - refShape.setTransform(pmv); + refShape.setMvTransform(pmv); as = new Set(pixPerMM, refShape.getPixelPerShapeUnit(pmv, viewport, new float[2]), refShape, accel, velocity, ang_accel, ang_velo, allShapes, sourceBounds, lerp); } - pmv.glPopMatrix(); + pmv.popMv(); } animSets.add(as); @@ -424,13 +424,13 @@ public class AnimGroup extends Group { * The start-position is randomly chosen within given {@link AABBox} glyphBox. * </p> * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * only, without a shape's {@link #setTransform(PMVMatrix)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * only, without a shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * </p> * @param pixPerMM monitor pixel per millimeter for accurate animation * @param glp used {@link GLProfile} - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * @param viewport the int[4] viewport * @param renderModes used {@link GLRegion#create(GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence) region render-modes} * @param font {@link Font} to be used for resulting {@link GlyphShape}s @@ -448,7 +448,7 @@ public class AnimGroup extends Group { * @return newly created and added {@link Set} */ public final Set addGlyphSetRandom01(final float pixPerMM, - final GLProfile glp, final PMVMatrix pmv, final Recti viewport, final int renderModes, + final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, final Font font, final CharSequence text, final float fontScale, final Vec4f fgCol, final float accel, final float velocity, final float ang_accel, final float ang_velo, final AABBox animBox, final boolean z_only, final Random random, final LerpFunc lerp) @@ -473,13 +473,13 @@ public class AnimGroup extends Group { * Add a new {@link Set} with {@link ShapeData} for each {@link GlyphShape}, implementing<br/> * horizontal continuous scrolling while repeating the given {@code text}. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * only, without a shape's {@link #setTransform(PMVMatrix)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * only, without a shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * </p> * @param pixPerMM monitor pixel per millimeter for accurate animation * @param glp used {@link GLProfile} - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}. * @param viewport the int[4] viewport * @param renderModes used {@link GLRegion#create(GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence) region render-modes} * @param font {@link Font} to be used for resulting {@link GlyphShape}s @@ -491,7 +491,7 @@ public class AnimGroup extends Group { * @return newly created and added {@link Set} */ public final Set addGlyphSetHorizScroll01(final float pixPerMM, - final GLProfile glp, final PMVMatrix pmv, final Recti viewport, final int renderModes, + final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, final Font font, final CharSequence text, final float fontScale, final Vec4f fgCol, final float velocity, final AABBox animBox, final float y_offset) { diff --git a/src/graphui/classes/com/jogamp/graph/ui/Container.java b/src/graphui/classes/com/jogamp/graph/ui/Container.java index 845d41c0c..bc1e6d94f 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Container.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Container.java @@ -32,10 +32,9 @@ import java.util.Comparator; import java.util.List; import com.jogamp.graph.ui.Shape.Visitor2; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.ui.Shape.Visitor1; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; /** * Container interface of UI {@link Shape}s @@ -71,9 +70,9 @@ public interface Container { boolean contains(Shape s); - AABBox getBounds(final PMVMatrix pmv, Shape shape); + AABBox getBounds(final PMVMatrix4f pmv, Shape shape); - /** Enable or disable {@link PMVMatrix#getFrustum()} culling per {@link Shape}. Default is disabled. */ + /** Enable or disable {@link PMVMatrix4f#getFrustum()} culling per {@link Shape}. Default is disabled. */ void setFrustumCullingEnabled(final boolean v); /** Return whether {@link #setFrustumCullingEnabled(boolean) frustum culling} is enabled. */ @@ -86,7 +85,7 @@ public interface Container { * @param action * @return true to signal operation complete, i.e. {@code shape} found, otherwise false */ - boolean forOne(final PMVMatrix pmv, final Shape shape, final Runnable action); + boolean forOne(final PMVMatrix4f pmv, final Shape shape, final Runnable action); /** * Traverses through the graph and apply {@link Visitor1#visit(Shape)} for each, stop if it returns true. @@ -96,21 +95,21 @@ public interface Container { boolean forAll(Visitor1 v); /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix)} for each, stop if it returns true. + * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each, stop if it returns true. * @param pmv * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix)} returned true, otherwise false + * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false */ - boolean forAll(final PMVMatrix pmv, Visitor2 v); + boolean forAll(final PMVMatrix4f pmv, Visitor2 v); /** - * Traverses through the graph and apply {@link Visitor#visit(Shape, PMVMatrix)} for each, stop if it returns true. + * Traverses through the graph and apply {@link Visitor#visit(Shape, PMVMatrix4f)} for each, stop if it returns true. * * Each {@link Container} level is sorted using {@code sortComp} * @param sortComp * @param pmv * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix)} returned true, otherwise false + * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false */ - boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix pmv, final Visitor2 v); + boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v); }
\ No newline at end of file diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java index 46f2d0a5b..971136ec8 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java @@ -35,10 +35,10 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.ui.layout.Padding; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.util.texture.TextureSequence; /** diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index 6ddfa9700..8a50d19f3 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -37,12 +37,12 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; import jogamp.graph.ui.TreeTool; @@ -64,14 +64,14 @@ public class Group extends Shape implements Container { * According to the implemented layout, method * - may scale the {@Link Shape}s * - may move the {@Link Shape}s - * - may reuse the given {@link PMVMatrix} `pmv` + * - may reuse the given {@link PMVMatrix4f} `pmv` * - must update the given {@link AABBox} `box` * </p> * @param g the {@link Group} to layout * @param box the bounding box of {@link Group} to be updated by this method. - * @param pmv a {@link PMVMatrix} which can be reused. + * @param pmv a {@link PMVMatrix4f} which can be reused. */ - void layout(final Group g, final AABBox box, final PMVMatrix pmv); + void layout(final Group g, final AABBox box, final PMVMatrix4f pmv); } private final List<Shape> shapes = new CopyOnWriteArrayList<Shape>(); @@ -207,7 +207,7 @@ public class Group extends Shape implements Container { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final Vec4f rgba) { - final PMVMatrix pmv = renderer.getMatrix(); + final PMVMatrix4f pmv = renderer.getMatrix(); final Object[] shapesS = shapes.toArray(); Arrays.sort(shapesS, (Comparator)Shape.ZAscendingComparator); @@ -215,8 +215,8 @@ public class Group extends Shape implements Container { for(int i=0; i<shapeCount; i++) { final Shape shape = (Shape) shapesS[i]; if( shape.isEnabled() ) { - pmv.glPushMatrix(); - shape.setTransform(pmv); + pmv.pushMv(); + shape.setMvTransform(pmv); if( !doFrustumCulling || !pmv.getFrustum().isAABBoxOutside( shape.getBounds() ) ) { if( null == rgba ) { @@ -225,7 +225,7 @@ public class Group extends Shape implements Container { shape.draw(gl, renderer, sampleCount); } } - pmv.glPopMatrix(); + pmv.popMv(); } } if( null != border ) { @@ -257,7 +257,7 @@ public class Group extends Shape implements Container { GraphShape firstGS = null; // box has been reset - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); if( null != layouter ) { for(final Shape s : shapes) { if( needsRMs && null == firstGS && s instanceof GraphShape ) { @@ -282,10 +282,10 @@ public class Group extends Shape implements Container { } else { s.validate(glp); } - pmv.glPushMatrix(); - s.setTransform(pmv); - s.getBounds().transformMv(pmv, tsbox); - pmv.glPopMatrix(); + pmv.pushMv(); + s.setMvTransform(pmv); + s.getBounds().transform(pmv.getMv(), tsbox); + pmv.popMv(); box.resize(tsbox); } } @@ -329,15 +329,15 @@ public class Group extends Shape implements Container { } @Override - public AABBox getBounds(final PMVMatrix pmv, final Shape shape) { + public AABBox getBounds(final PMVMatrix4f pmv, final Shape shape) { pmv.reset(); - setTransform(pmv); + setMvTransform(pmv); final AABBox res = new AABBox(); if( null == shape ) { return res; } forOne(pmv, shape, () -> { - shape.getBounds().transformMv(pmv, res); + shape.getBounds().transform(pmv.getMv(), res); }); return res; } @@ -348,7 +348,7 @@ public class Group extends Shape implements Container { } @Override - public boolean forOne(final PMVMatrix pmv, final Shape shape, final Runnable action) { + public boolean forOne(final PMVMatrix4f pmv, final Shape shape, final Runnable action) { return TreeTool.forOne(shapes, pmv, shape, action); } @@ -358,12 +358,12 @@ public class Group extends Shape implements Container { } @Override - public boolean forAll(final PMVMatrix pmv, final Visitor2 v) { + public boolean forAll(final PMVMatrix4f pmv, final Visitor2 v) { return TreeTool.forAll(shapes, pmv, v); } @Override - public boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix pmv, final Visitor2 v) { + public boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v) { return TreeTool.forSortedAll(sortComp, shapes, pmv, v); } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index c9b28b78a..53ee7537e 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -52,7 +52,13 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.ui.Shape.Visitor2; -import com.jogamp.graph.ui.Scene.PMVMatrixSetup; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Ray; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.ui.Shape.Visitor1; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.InputEvent; @@ -61,15 +67,8 @@ import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.PinchToZoomGesture; import com.jogamp.newt.event.GestureHandler.GestureEvent; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Ray; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.graph.ui.TreeTool; @@ -93,7 +92,7 @@ import jogamp.graph.ui.TreeTool; * - {@link GLEventListener#dispose(GLAutoDrawable)} * </p> * <p> - * {@link #setPMVMatrixSetup(PMVMatrixSetup)} maybe used to provide a custom {@link PMVMatrix} setup. + * {@link #setPMVMatrixSetup(PMVMatrixSetup)} maybe used to provide a custom {@link PMVMatrix4f} setup. * </p> * @see Shape */ @@ -141,7 +140,7 @@ public final class Scene implements Container, GLEventListener { private final int[] sampleCount = new int[1]; - /** Describing the bounding box in shape's object model-coordinates of the near-plane parallel at its scene-distance, post {@link #translate(PMVMatrix)} */ + /** Describing the bounding box in shape's object model-coordinates of the near-plane parallel at its scene-distance, post {@link #translate(PMVMatrix4f)} */ private final AABBox planeBox = new AABBox(0f, 0f, 0f, 0f, 0f, 0f); private volatile Shape activeShape = null; @@ -395,13 +394,13 @@ public final class Scene implements Container, GLEventListener { } /** - * Reshape scene using {@link #setupMatrix(PMVMatrix, int, int, int, int)} using {@link PMVMatrixSetup}. + * Reshape scene using {@link #setupMatrix(PMVMatrix4f, int, int, int, int)} using {@link PMVMatrixSetup}. * <p> * {@inheritDoc} * </p> * @see PMVMatrixSetup * @see #setPMVMatrixSetup(PMVMatrixSetup) - * @see #setupMatrix(PMVMatrix, int, int, int, int) + * @see #setupMatrix(PMVMatrix4f, int, int, int, int) * @see #getBounds() * @see #getBoundsCenter() */ @@ -440,8 +439,7 @@ public final class Scene implements Container, GLEventListener { sampleCount0 = sampleCount; } - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmv = renderer.getMatrix(); if( glSelect ) { renderer.enable(gl, true, RegionRenderer.defaultBlendDisable, RegionRenderer.defaultBlendDisable); @@ -456,8 +454,8 @@ public final class Scene implements Container, GLEventListener { final Shape shape = (Shape)shapes[i]; // System.err.println("Id "+i+": "+uiShape); if( shape.isEnabled() ) { - pmv.glPushMatrix(); - shape.setTransform(pmv); + pmv.pushMv(); + shape.setMvTransform(pmv); if( !doFrustumCulling || !pmv.getFrustum().isAABBoxOutside( shape.getBounds() ) ) { if( glSelect ) { @@ -470,7 +468,7 @@ public final class Scene implements Container, GLEventListener { shape.draw(gl, renderer, sampleCount0); } } - pmv.glPopMatrix(); + pmv.popMv(); } } if( glSelect ) { @@ -537,8 +535,8 @@ public final class Scene implements Container, GLEventListener { * <p> * Method performs on current thread and returns after probing every {@link Shape}. * </p> - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link Shape#setTransform(PMVMatrix) shape-transformed} and can be reused by the caller and runnable. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link Shape#setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller and runnable. * @param glWinX window X coordinate, bottom-left origin * @param glWinY window Y coordinate, bottom-left origin * @param objPos storage for found object position in model-space of found {@link Shape} @@ -546,7 +544,7 @@ public final class Scene implements Container, GLEventListener { * @param runnable the action to perform if {@link Shape} was found * @return picked Shape if any or null as stored in {@code shape} */ - public Shape pickShape(final PMVMatrix pmv, final int glWinX, final int glWinY, final Vec3f objPos, final Shape[] shape, final Runnable runnable) { + public Shape pickShape(final PMVMatrix4f pmv, final int glWinX, final int glWinY, final Vec3f objPos, final Shape[] shape, final Runnable runnable) { setupMatrix(pmv); final float winZ0 = 0f; @@ -560,8 +558,8 @@ public final class Scene implements Container, GLEventListener { final Ray ray = new Ray(); shape[0] = null; - forSortedAll(Shape.ZAscendingComparator, pmv, (final Shape s, final PMVMatrix pmv2) -> { - final boolean ok = s.isInteractive() && pmv.gluUnProjectRay(glWinX, glWinY, winZ0, winZ1, viewport, ray); + forSortedAll(Shape.ZAscendingComparator, pmv, (final Shape s, final PMVMatrix4f pmv2) -> { + final boolean ok = s.isInteractive() && pmv.mapWinToRay(glWinX, glWinY, winZ0, winZ1, viewport, ray); if( ok ) { final AABBox sbox = s.getBounds(); if( sbox.intersectsRay(ray) ) { @@ -604,11 +602,11 @@ public final class Scene implements Container, GLEventListener { final Shape s = pickShapeGLImpl(drawable, glWinX, glWinY); shape[0] = s; if( null != s ) { - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glPushMatrix(); - s.setTransform(pmv); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.pushMv(); + s.setMvTransform(pmv); final boolean ok = null != shape[0].winToShapeCoord(getMatrix(), getViewport(), glWinX, glWinY, objPos); - pmv.glPopMatrix(); + pmv.popMv(); if( ok ) { runnable.run(); } @@ -661,12 +659,12 @@ public final class Scene implements Container, GLEventListener { * @param shape * @param glWinX in GL window coordinates, origin bottom-left * @param glWinY in GL window coordinates, origin bottom-left - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link Shape#setTransform(PMVMatrix) shape-transformed} and can be reused by the caller and runnable. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link Shape#setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller and runnable. * @param objPos resulting object position * @param runnable action */ - public void winToShapeCoord(final Shape shape, final int glWinX, final int glWinY, final PMVMatrix pmv, final Vec3f objPos, final Runnable runnable) { + public void winToShapeCoord(final Shape shape, final int glWinX, final int glWinY, final PMVMatrix4f pmv, final Vec3f objPos, final Runnable runnable) { if( null == shape ) { return; } @@ -680,38 +678,38 @@ public final class Scene implements Container, GLEventListener { } @Override - public AABBox getBounds(final PMVMatrix pmv, final Shape shape) { + public AABBox getBounds(final PMVMatrix4f pmv, final Shape shape) { final AABBox res = new AABBox(); if( null == shape ) { return res; } setupMatrix(pmv); forOne(pmv, shape, () -> { - shape.getBounds().transformMv(pmv, res); + shape.getBounds().transform(pmv.getMv(), res); }); return res; } /** * Traverses through the graph up until {@code shape} and apply {@code action} on it. - * @param pmv {@link PMVMatrix}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix)} + * @param pmv {@link PMVMatrix4f}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix4f)} * @param shape * @param action * @return true to signal operation complete, i.e. {@code shape} found, otherwise false */ @Override - public boolean forOne(final PMVMatrix pmv, final Shape shape, final Runnable action) { + public boolean forOne(final PMVMatrix4f pmv, final Shape shape, final Runnable action) { return TreeTool.forOne(shapes, pmv, shape, action); } /** - * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix)} for each, stop if it returns true. - * @param pmv {@link PMVMatrix}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix)} + * Traverses through the graph and apply {@link Visitor2#visit(Shape, PMVMatrix4f)} for each, stop if it returns true. + * @param pmv {@link PMVMatrix4f}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix4f)} * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix)} returned true, otherwise false + * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false */ @Override - public boolean forAll(final PMVMatrix pmv, final Visitor2 v) { + public boolean forAll(final PMVMatrix4f pmv, final Visitor2 v) { return TreeTool.forAll(shapes, pmv, v); } @@ -726,27 +724,27 @@ public final class Scene implements Container, GLEventListener { } /** - * Traverses through the graph and apply {@link Visitor#visit(Shape, PMVMatrix)} for each, stop if it returns true. + * Traverses through the graph and apply {@link Visitor#visit(Shape, PMVMatrix4f)} for each, stop if it returns true. * * Each {@link Container} level is sorted using {@code sortComp} * @param sortComp * @param pmv * @param v - * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix)} returned true, otherwise false + * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false */ @Override - public boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix pmv, final Visitor2 v) { + public boolean forSortedAll(final Comparator<Shape> sortComp, final PMVMatrix4f pmv, final Visitor2 v) { return TreeTool.forSortedAll(sortComp, shapes, pmv, v); } /** - * Interface providing {@link #set(PMVMatrix, Recti) a method} to - * setup {@link PMVMatrix}'s {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}. + * Interface providing {@link #set(PMVMatrix4f, Recti) a method} to + * setup {@link PMVMatrix4f}'s {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}. * <p> * At the end of operations, the {@link GLMatrixFunc#GL_MODELVIEW} matrix has to be selected. * </p> * <p> - * Implementation is being called by {@link Scene#setupMatrix(PMVMatrix, int, int, int, int)} + * Implementation is being called by {@link Scene#setupMatrix(PMVMatrix4f, int, int, int, int)} * and hence {@link Scene#reshape(GLAutoDrawable, int, int, int, int)}. * </p> * <p> @@ -768,28 +766,28 @@ public final class Scene implements Container, GLEventListener { float getZFar(); /** - * Setup {@link PMVMatrix}'s {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}. + * Setup {@link PMVMatrix4f}'s {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW}. * <p> * See {@link PMVMatrixSetup} for details. * </p> * <p> * At the end of operations, the {@link GLMatrixFunc#GL_MODELVIEW} matrix is selected. * </p> - * @param pmv the {@link PMVMatrix} to setup + * @param pmv the {@link PMVMatrix4f} to setup * @param viewport Rect4i viewport */ - void set(PMVMatrix pmv, Recti viewport); + void set(PMVMatrix4f pmv, Recti viewport); /** * Optional method to set the {@link Scene#getBounds()} {@link AABBox}, maybe a {@code nop} if not desired. * <p> - * Will be called by {@link Scene#reshape(GLAutoDrawable, int, int, int, int)} after {@link #set(PMVMatrix, Recti)}. + * Will be called by {@link Scene#reshape(GLAutoDrawable, int, int, int, int)} after {@link #set(PMVMatrix4f, Recti)}. * </p> * @param planeBox the {@link AABBox} to define - * @param pmv the {@link PMVMatrix}, already setup via {@link #set(PMVMatrix, Recti)}. + * @param pmv the {@link PMVMatrix4f}, already setup via {@link #set(PMVMatrix4f, Recti)}. * @param viewport Rect4i viewport */ - void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, Recti viewport); + void setPlaneBox(final AABBox planeBox, final PMVMatrix4f pmv, Recti viewport); } /** Return the default or {@link #setPMVMatrixSetup(PMVMatrixSetup)} {@link PMVMatrixSetup}. */ @@ -799,21 +797,21 @@ public final class Scene implements Container, GLEventListener { public final void setPMVMatrixSetup(final PMVMatrixSetup setup) { pmvMatrixSetup = setup; } /** - * Setup {@link PMVMatrix} {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} - * by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix, Recti)}. - * @param pmv the {@link PMVMatrix} to setup + * Setup {@link PMVMatrix4f} {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} + * by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix4f, Recti)}. + * @param pmv the {@link PMVMatrix4f} to setup * @param Recti viewport */ - public void setupMatrix(final PMVMatrix pmv, final Recti viewport) { + public void setupMatrix(final PMVMatrix4f pmv, final Recti viewport) { pmvMatrixSetup.set(pmv, viewport); } /** - * Setup {@link PMVMatrix} {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} - * using implicit {@link #getViewport()} surface dimension by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix, Recti)}. - * @param pmv the {@link PMVMatrix} to setup + * Setup {@link PMVMatrix4f} {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} + * using implicit {@link #getViewport()} surface dimension by calling {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#set(PMVMatrix4f, Recti)}. + * @param pmv the {@link PMVMatrix4f} to setup */ - public void setupMatrix(final PMVMatrix pmv) { + public void setupMatrix(final PMVMatrix4f pmv) { final Recti viewport = renderer.getViewport(); setupMatrix(pmv, viewport); } @@ -829,8 +827,8 @@ public final class Scene implements Container, GLEventListener { /** Returns the {@link #getViewport()}'s height, set after initial {@link #reshape(GLAutoDrawable, int, int, int, int)}. */ public int getHeight() { return renderer.getHeight(); } - /** Borrow the current {@link PMVMatrix}. */ - public PMVMatrix getMatrix() { return renderer.getMatrix(); } + /** Borrow the current {@link PMVMatrix4f}. */ + public PMVMatrix4f getMatrix() { return renderer.getMatrix(); } /** * Describing the scene's object model-dimensions of the plane at scene-distance covering the visible viewport rectangle. @@ -841,7 +839,7 @@ public final class Scene implements Container, GLEventListener { * {@link AABBox#getWidth()} and {@link AABBox#getHeight()} define scene's dimension covered by surface size. * </p> * <p> - * {@link AABBox} is setup via {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#setPlaneBox(AABBox, PMVMatrix, Recti)}. + * {@link AABBox} is setup via {@link #getPMVMatrixSetup()}'s {@link PMVMatrixSetup#setPlaneBox(AABBox, PMVMatrix4f, Recti)}. * </p> * <p> * The default {@link PMVMatrixSetup} implementation scales to normalized plane dimensions, 1 for the greater of width and height. @@ -870,12 +868,12 @@ public final class Scene implements Container, GLEventListener { * @param objPos float[3] storage for object coord result * @param winZ */ - public static void winToPlaneCoord(final PMVMatrix pmv, final Recti viewport, + public static void winToPlaneCoord(final PMVMatrix4f pmv, final Recti viewport, final float zNear, final float zFar, final float winX, final float winY, final float objOrthoZ, final Vec3f objPos) { final float winZ = FloatUtil.getOrthoWinZ(objOrthoZ, zNear, zFar); - pmv.gluUnProject(winX, winY, winZ, viewport, objPos); + pmv.mapWinToObj(winX, winY, winZ, viewport, objPos); } /** @@ -888,7 +886,7 @@ public final class Scene implements Container, GLEventListener { * @param objSceneSize Vec2f storage for object surface size result */ public void surfaceToPlaneSize(final Recti viewport, final float zNear, final float zFar, final float objOrthoDist, final Vec2f objSceneSize) { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); setupMatrix(pmv, viewport); { final Vec3f obj00Coord = new Vec3f(); @@ -935,7 +933,7 @@ public final class Scene implements Container, GLEventListener { // flip to GL window coordinates final int glWinX = e.getX(); final int glWinY = getHeight() - e.getY() - 1; - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final Vec3f objPos = new Vec3f(); winToShapeCoord(shape, glWinX, glWinY, pmv, objPos, () -> { shape.dispatchGestureEvent(gh, glWinX, glWinY, pmv, renderer.getViewport(), objPos); @@ -966,7 +964,7 @@ public final class Scene implements Container, GLEventListener { * @param glWinY in GL window coordinates, origin bottom-left */ final void dispatchMouseEventPickShape(final MouseEvent e, final int glWinX, final int glWinY) { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final Vec3f objPos = new Vec3f(); final Shape[] shape = { null }; if( null == pickShape(pmv, glWinX, glWinY, objPos, shape, () -> { @@ -985,7 +983,7 @@ public final class Scene implements Container, GLEventListener { * @param glWinY in GL window coordinates, origin bottom-left */ final void dispatchMouseEventForShape(final Shape shape, final MouseEvent e, final int glWinX, final int glWinY) { - final PMVMatrix pmv = new PMVMatrix(); + final PMVMatrix4f pmv = new PMVMatrix4f(); final Vec3f objPos = new Vec3f(); winToShapeCoord(shape, glWinX, glWinY, pmv, objPos, () -> { shape.dispatchMouseEvent(e, glWinX, glWinY, objPos); }); } @@ -1199,7 +1197,7 @@ public final class Scene implements Container, GLEventListener { /** * Default implementation of {@link Scene.PMVMatrixSetup}, - * implementing {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti)} as follows: + * implementing {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)} as follows: * <ul> * <li>{@link GLMatrixFunc#GL_PROJECTION} Matrix * <ul> @@ -1279,19 +1277,17 @@ public final class Scene implements Container, GLEventListener { } @Override - public void set(final PMVMatrix pmv, final Recti viewport) { + public void set(final PMVMatrix4f pmv, final Recti viewport) { final float ratio = (float) viewport.width() / (float) viewport.height(); - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); - pmv.gluPerspective(angle, ratio, zNear, zFar); - pmv.glTranslatef(0f, 0f, scene_dist); + pmv.loadPIdentity(); + pmv.perspectiveP(angle, ratio, zNear, zFar); + pmv.translateMv(0f, 0f, scene_dist); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + pmv.loadMvIdentity(); } @Override - public void setPlaneBox(final AABBox planeBox, final PMVMatrix pmv, final Recti viewport) { + public void setPlaneBox(final AABBox planeBox, final PMVMatrix4f pmv, final Recti viewport) { final float orthoDist = -scene_dist; final Vec3f obj00Coord = new Vec3f(); final Vec3f obj11Coord = new Vec3f(); diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index 843c73384..cdec75019 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -36,6 +36,15 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.ui.layout.Padding; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.event.GestureHandler.GestureEvent; import com.jogamp.newt.event.GestureHandler.GestureListener; import com.jogamp.newt.event.MouseAdapter; @@ -43,15 +52,6 @@ import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.PinchToZoomGesture; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; /** * Generic Shape, potentially using a Graph via {@link GraphShape} or other means of representing content. @@ -101,10 +101,10 @@ public abstract class Shape { /** * Visitor method * @param s the {@link Shape} to process - * @param pmv the {@link PMVMatrix} setup from the {@link Scene} down to the {@link Shape} + * @param pmv the {@link PMVMatrix4f} setup from the {@link Scene} down to the {@link Shape} * @return true to signal operation complete and to stop traversal, otherwise false */ - boolean visit(Shape s, final PMVMatrix pmv); + boolean visit(Shape s, final PMVMatrix4f pmv); } /** @@ -283,7 +283,7 @@ public abstract class Shape { public final void onToggle(final Listener l) { onToggleListener = l; } public final void onClicked(final Listener l) { onClickedListener = l; } - /** Move to scaled position. Position ends up in PMVMatrix unmodified. */ + /** Move to scaled position. Position ends up in PMVMatrix4f unmodified. */ public final Shape moveTo(final float tx, final float ty, final float tz) { position.set(tx, ty, tz); if( null != onMoveListener ) { @@ -292,7 +292,7 @@ public abstract class Shape { return this; } - /** Move to scaled position. Position ends up in PMVMatrix unmodified. */ + /** Move to scaled position. Position ends up in PMVMatrix4f unmodified. */ public final Shape moveTo(final Vec3f t) { position.set(t); if( null != onMoveListener ) { @@ -301,7 +301,7 @@ public abstract class Shape { return this; } - /** Move about scaled distance. Position ends up in PMVMatrix unmodified. */ + /** Move about scaled distance. Position ends up in PMVMatrix4f unmodified. */ public final Shape move(final float dtx, final float dty, final float dtz) { position.add(dtx, dty, dtz); if( null != onMoveListener ) { @@ -310,7 +310,7 @@ public abstract class Shape { return this; } - /** Move about scaled distance. Position ends up in PMVMatrix unmodified. */ + /** Move about scaled distance. Position ends up in PMVMatrix4f unmodified. */ public final Shape move(final Vec3f dt) { position.add(dt); if( null != onMoveListener ) { @@ -501,7 +501,7 @@ public abstract class Shape { /** * Renders the shape. * <p> - * {@link #setTransform(PMVMatrix)} is expected to be completed beforehand. + * {@link #setMvTransform(PMVMatrix4f)} is expected to be completed beforehand. * </p> * @param gl the current GL object * @param renderer {@link RegionRenderer} which might be used for Graph Curve Rendering, also source of {@link RegionRenderer#getMatrix()} and {@link RegionRenderer#getViewport()}. @@ -586,7 +586,7 @@ public abstract class Shape { } /** - * Setup the pre-selected {@link GLMatrixFunc#GL_MODELVIEW} {@link PMVMatrix} for this object. + * Setup the {@link PMVMatrix4f#getMv() modelview matrix} of the given {@link PMVMatrix4f} for this object. * - Scale shape from its center position * - Rotate shape around optional scaled pivot, see {@link #setRotationPivot(float[])}), otherwise rotate around its scaled center (default) * <p> @@ -598,98 +598,98 @@ public abstract class Shape { * @see #moveTo(float, float, float) * @see #setScale(float, float, float) */ - public void setTransform(final PMVMatrix pmv) { + public void setMvTransform(final PMVMatrix4f pmv) { final boolean hasScale = !scale.isEqual(Vec3f.ONE); final boolean hasRotate = !rotation.isIdentity(); final boolean hasRotPivot = null != rotPivot; final Vec3f ctr = box.getCenter(); final boolean sameScaleRotatePivot = hasScale && hasRotate && ( !hasRotPivot || rotPivot.isEqual(ctr) ); - pmv.glTranslatef(position.x(), position.y(), position.z()); // translate, scaled + pmv.translateMv(position.x(), position.y(), position.z()); // translate, scaled if( sameScaleRotatePivot ) { // Scale shape from its center position and rotate around its center - pmv.glTranslatef(ctr.x()*scale.x(), ctr.y()*scale.y(), ctr.z()*scale.z()); // add-back center, scaled - pmv.glRotate(rotation); - pmv.glScalef(scale.x(), scale.y(), scale.z()); - pmv.glTranslatef(-ctr.x(), -ctr.y(), -ctr.z()); // move to center + pmv.translateMv(ctr.x()*scale.x(), ctr.y()*scale.y(), ctr.z()*scale.z()); // add-back center, scaled + pmv.rotateMv(rotation); + pmv.scaleMv(scale.x(), scale.y(), scale.z()); + pmv.translateMv(-ctr.x(), -ctr.y(), -ctr.z()); // move to center } else if( hasRotate || hasScale ) { if( hasRotate ) { if( hasRotPivot ) { // Rotate shape around its scaled pivot - pmv.glTranslatef(rotPivot.x()*scale.x(), rotPivot.y()*scale.y(), rotPivot.z()*scale.z()); // pivot back from rot-pivot, scaled - pmv.glRotate(rotation); - pmv.glTranslatef(-rotPivot.x()*scale.x(), -rotPivot.y()*scale.y(), -rotPivot.z()*scale.z()); // pivot to rot-pivot, scaled + pmv.translateMv(rotPivot.x()*scale.x(), rotPivot.y()*scale.y(), rotPivot.z()*scale.z()); // pivot back from rot-pivot, scaled + pmv.rotateMv(rotation); + pmv.translateMv(-rotPivot.x()*scale.x(), -rotPivot.y()*scale.y(), -rotPivot.z()*scale.z()); // pivot to rot-pivot, scaled } else { // Rotate shape around its scaled center - pmv.glTranslatef(ctr.x()*scale.x(), ctr.y()*scale.y(), ctr.z()*scale.z()); // pivot back from center-pivot, scaled - pmv.glRotate(rotation); - pmv.glTranslatef(-ctr.x()*scale.x(), -ctr.y()*scale.y(), -ctr.z()*scale.z()); // pivot to center-pivot, scaled + pmv.translateMv(ctr.x()*scale.x(), ctr.y()*scale.y(), ctr.z()*scale.z()); // pivot back from center-pivot, scaled + pmv.rotateMv(rotation); + pmv.translateMv(-ctr.x()*scale.x(), -ctr.y()*scale.y(), -ctr.z()*scale.z()); // pivot to center-pivot, scaled } } if( hasScale ) { // Scale shape from its center position - pmv.glTranslatef(ctr.x()*scale.x(), ctr.y()*scale.y(), ctr.z()*scale.z()); // add-back center, scaled - pmv.glScalef(scale.x(), scale.y(), scale.z()); - pmv.glTranslatef(-ctr.x(), -ctr.y(), -ctr.z()); // move to center + pmv.translateMv(ctr.x()*scale.x(), ctr.y()*scale.y(), ctr.z()*scale.z()); // add-back center, scaled + pmv.scaleMv(scale.x(), scale.y(), scale.z()); + pmv.translateMv(-ctr.x(), -ctr.y(), -ctr.z()); // move to center } } } /** - * {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) Setup} the given {@link PMVMatrix} - * and apply this shape's {@link #setTransform(PMVMatrix) transformation}. + * {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) Setup} the given {@link PMVMatrix4f} + * and apply this shape's {@link #setMvTransform(PMVMatrix4f) transformation}. * </p> - * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}. - * @param viewport used viewport for {@link PMVMatrix#gluProject(float, float, float, int[], float[])} - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. - * @return the given {@link PMVMatrix} for chaining - * @see Scene.PMVMatrixSetup#set(PMVMatrix, Recti) - * @see #setTransform(PMVMatrix) - * @see #setPMVMatrix(Scene, PMVMatrix) - */ - public PMVMatrix setPMVMatrix(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final PMVMatrix pmv) { + * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} given {@link PMVMatrix4f} {@code pmv}. + * @param viewport used viewport for {@link PMVMatrix4f#mapObjToWin(Vec3f, Recti, Vec3f)} + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. + * @return the given {@link PMVMatrix4f} for chaining + * @see Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) + * @see #setMvTransform(PMVMatrix4f) + * @see #setPMVMatrix(Scene, PMVMatrix4f) + */ + public PMVMatrix4f setPMVMatrix(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final PMVMatrix4f pmv) { pmvMatrixSetup.set(pmv, viewport); - setTransform(pmv); + setMvTransform(pmv); return pmv; } /** - * {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) Setup} the given {@link PMVMatrix} - * and apply this shape's {@link #setTransform(PMVMatrix) transformation}. + * {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) Setup} the given {@link PMVMatrix4f} + * and apply this shape's {@link #setMvTransform(PMVMatrix4f) transformation}. * </p> * @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport. - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. - * @return the given {@link PMVMatrix} for chaining - * @see Scene.PMVMatrixSetup#set(PMVMatrix, Recti) - * @see #setTransform(PMVMatrix) - * @see #setPMVMatrix(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix) - */ - public PMVMatrix setPMVMatrix(final Scene scene, final PMVMatrix pmv) { + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. + * @return the given {@link PMVMatrix4f} for chaining + * @see Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) + * @see #setMvTransform(PMVMatrix4f) + * @see #setPMVMatrix(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix4f) + */ + public PMVMatrix4f setPMVMatrix(final Scene scene, final PMVMatrix4f pmv) { return setPMVMatrix(scene.getPMVMatrixSetup(), scene.getViewport(), pmv); } /** * Retrieve surface (view) port of this shape, i.e. lower x/y position and size. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * including this shape's {@link #setTransform(PMVMatrix)}. See {@link #setPMVMatrix(Scene, PMVMatrix)}. + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link #setPMVMatrix(Scene, PMVMatrix4f)}. * </p> - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix4f)}. * @param viewport the int[4] viewport * @param surfacePort Recti target surface port - * @return given Recti {@code surfacePort} for successful gluProject(..) operation, otherwise {@code null} + * @return given Recti {@code surfacePort} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} */ - public Recti getSurfacePort(final PMVMatrix pmv, final Recti viewport, final Recti surfacePort) { + public Recti getSurfacePort(final PMVMatrix4f pmv, final Recti viewport, final Recti surfacePort) { final Vec3f winCoordHigh = new Vec3f(); final Vec3f winCoordLow = new Vec3f(); final Vec3f high = box.getHigh(); final Vec3f low = box.getLow(); - final Matrix4f matPMv = pmv.getPMvMat(); + final Matrix4f matPMv = pmv.getPMv(); if( Matrix4f.mapObjToWin(high, matPMv, viewport, winCoordHigh) ) { if( Matrix4f.mapObjToWin(low, matPMv, viewport, winCoordLow) ) { surfacePort.setX( (int)Math.abs( winCoordLow.x() ) ); @@ -705,25 +705,25 @@ public abstract class Shape { /** * Retrieve surface (view) size in pixels of this shape. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * including this shape's {@link #setTransform(PMVMatrix)}. See {@link #setPMVMatrix(Scene, PMVMatrix)}. + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link #setPMVMatrix(Scene, PMVMatrix4f)}. * </p> - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix4f)}. * @param viewport the int[4] viewport * @param surfaceSize int[2] target surface size - * @return given int[2] {@code surfaceSize} in pixels for successful gluProject(..) operation, otherwise {@code null} - * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[]) - * @see #getSurfaceSize(Scene, PMVMatrix, int[]) + * @return given int[2] {@code surfaceSize} in pixels for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} + * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix4f, int[]) + * @see #getSurfaceSize(Scene, PMVMatrix4f, int[]) */ - public int[/*2*/] getSurfaceSize(final PMVMatrix pmv, final Recti viewport, final int[/*2*/] surfaceSize) { + public int[/*2*/] getSurfaceSize(final PMVMatrix4f pmv, final Recti viewport, final int[/*2*/] surfaceSize) { // System.err.println("Shape::getSurfaceSize.VP "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]); final Vec3f winCoordHigh = new Vec3f(); final Vec3f winCoordLow = new Vec3f(); final Vec3f high = box.getHigh(); final Vec3f low = box.getLow(); - final Matrix4f matPMv = pmv.getPMvMat(); + final Matrix4f matPMv = pmv.getPMv(); if( Matrix4f.mapObjToWin(high, matPMv, viewport, winCoordHigh) ) { if( Matrix4f.mapObjToWin(low, matPMv, viewport, winCoordLow) ) { surfaceSize[0] = (int)Math.abs(winCoordHigh.x() - winCoordLow.x()); @@ -737,47 +737,47 @@ public abstract class Shape { /** * Retrieve surface (view) size in pixels of this shape. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> - * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}. - * @param viewport used viewport for {@link PMVMatrix#gluProject(float, float, float, int[], float[])} - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} given {@link PMVMatrix4f} {@code pmv}. + * @param viewport used viewport for {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param surfaceSize int[2] target surface size - * @return given int[2] {@code surfaceSize} in pixels for successful gluProject(..) operation, otherwise {@code null} - * @see #getSurfaceSize(PMVMatrix, Recti, int[]) - * @see #getSurfaceSize(Scene, PMVMatrix, int[]) + * @return given int[2] {@code surfaceSize} in pixels for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} + * @see #getSurfaceSize(PMVMatrix4f, Recti, int[]) + * @see #getSurfaceSize(Scene, PMVMatrix4f, int[]) */ - public int[/*2*/] getSurfaceSize(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final PMVMatrix pmv, final int[/*2*/] surfaceSize) { + public int[/*2*/] getSurfaceSize(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final PMVMatrix4f pmv, final int[/*2*/] surfaceSize) { return getSurfaceSize(setPMVMatrix(pmvMatrixSetup, viewport, pmv), viewport, surfaceSize); } /** * Retrieve surface (view) size in pixels of this shape. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> * @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport. - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param surfaceSize int[2] target surface size - * @return given int[2] {@code surfaceSize} in pixels for successful gluProject(..) operation, otherwise {@code null} - * @see #getSurfaceSize(PMVMatrix, Recti, int[]) - * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[]) + * @return given int[2] {@code surfaceSize} in pixels for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} + * @see #getSurfaceSize(PMVMatrix4f, Recti, int[]) + * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix4f, int[]) */ - public int[/*2*/] getSurfaceSize(final Scene scene, final PMVMatrix pmv, final int[/*2*/] surfaceSize) { + public int[/*2*/] getSurfaceSize(final Scene scene, final PMVMatrix4f pmv, final int[/*2*/] surfaceSize) { return getSurfaceSize(scene.getPMVMatrixSetup(), scene.getViewport(), pmv, surfaceSize); } /** * Retrieve pixel per scaled shape-coordinate unit, i.e. [px]/[obj]. - * @param shapeSizePx int[2] shape size in pixel as retrieved via e.g. {@link #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[])} + * @param shapeSizePx int[2] shape size in pixel as retrieved via e.g. {@link #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix4f, int[])} * @param pixPerShape float[2] pixel scaled per shape-coordinate unit result storage * @return given float[2] {@code pixPerShape} - * @see #getPixelPerShapeUnit(Scene, PMVMatrix, float[]) - * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix, int[]) + * @see #getPixelPerShapeUnit(Scene, PMVMatrix4f, float[]) + * @see #getSurfaceSize(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, PMVMatrix4f, int[]) * @see #getScaledWidth() * @see #getScaledHeight() */ @@ -790,20 +790,20 @@ public abstract class Shape { /** * Retrieve pixel per scaled shape-coordinate unit, i.e. [px]/[obj]. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * including this shape's {@link #setTransform(PMVMatrix)}. See {@link #setPMVMatrix(Scene, PMVMatrix)}. + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link #setPMVMatrix(Scene, PMVMatrix4f)}. * </p> - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix4f)}. * @param viewport the int[4] viewport * @param pixPerShape float[2] pixel per scaled shape-coordinate unit result storage - * @return given float[2] {@code pixPerShape} for successful gluProject(..) operation, otherwise {@code null} + * @return given float[2] {@code pixPerShape} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} * @see #getPixelPerShapeUnit(int[], float[]) - * @see #getSurfaceSize(Scene, PMVMatrix, int[]) + * @see #getSurfaceSize(Scene, PMVMatrix4f, int[]) * @see #getScaledWidth() * @see #getScaledHeight() */ - public float[] getPixelPerShapeUnit(final PMVMatrix pmv, final Recti viewport, final float[] pixPerShape) { + public float[] getPixelPerShapeUnit(final PMVMatrix4f pmv, final Recti viewport, final float[] pixPerShape) { final int[] shapeSizePx = new int[2]; if( null != getSurfaceSize(pmv, viewport, shapeSizePx) ) { return getPixelPerShapeUnit(shapeSizePx, pixPerShape); @@ -815,20 +815,20 @@ public abstract class Shape { /** * Retrieve pixel per scaled shape-coordinate unit, i.e. [px]/[obj]. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> * @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport. - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param pixPerShape float[2] pixel per scaled shape-coordinate unit result storage - * @return given float[2] {@code pixPerShape} for successful gluProject(..) operation, otherwise {@code null} + * @return given float[2] {@code pixPerShape} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} * @see #getPixelPerShapeUnit(int[], float[]) - * @see #getSurfaceSize(Scene, PMVMatrix, int[]) + * @see #getSurfaceSize(Scene, PMVMatrix4f, int[]) * @see #getScaledWidth() * @see #getScaledHeight() */ - public float[] getPixelPerShapeUnit(final Scene scene, final PMVMatrix pmv, final float[] pixPerShape) { + public float[] getPixelPerShapeUnit(final Scene scene, final PMVMatrix4f pmv, final float[] pixPerShape) { final int[] shapeSizePx = new int[2]; if( null != getSurfaceSize(scene, pmv, shapeSizePx) ) { return getPixelPerShapeUnit(shapeSizePx, pixPerShape); @@ -840,23 +840,23 @@ public abstract class Shape { /** * Map given object coordinate relative to this shape to window coordinates. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * including this shape's {@link #setTransform(PMVMatrix)}. See {@link #setPMVMatrix(Scene, PMVMatrix)}. + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link #setPMVMatrix(Scene, PMVMatrix4f)}. * </p> - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix4f)}. * @param viewport the viewport * @param objPos object position relative to this shape's center * @param glWinPos int[2] target window position of objPos relative to this shape - * @return given int[2] {@code glWinPos} for successful gluProject(..) operation, otherwise {@code null} - * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, float[], PMVMatrix, int[]) - * @see #shapeToWinCoord(Scene, float[], PMVMatrix, int[]) + * @return given int[2] {@code glWinPos} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} + * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, float[], PMVMatrix4f, int[]) + * @see #shapeToWinCoord(Scene, float[], PMVMatrix4f, int[]) */ - public int[/*2*/] shapeToWinCoord(final PMVMatrix pmv, final Recti viewport, final Vec3f objPos, final int[/*2*/] glWinPos) { + public int[/*2*/] shapeToWinCoord(final PMVMatrix4f pmv, final Recti viewport, final Vec3f objPos, final int[/*2*/] glWinPos) { // System.err.println("Shape::objToWinCoordgetSurfaceSize.VP "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]); final Vec3f winCoord = new Vec3f(); - if( pmv.gluProject(objPos, viewport, winCoord) ) { + if( pmv.mapObjToWin(objPos, viewport, winCoord) ) { glWinPos[0] = (int)(winCoord.x()); glWinPos[1] = (int)(winCoord.y()); return glWinPos; @@ -867,64 +867,66 @@ public abstract class Shape { /** * Map given object coordinate relative to this shape to window coordinates. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> - * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}. - * @param viewport used viewport for {@link PMVMatrix#gluProject(Vec3f, Recti, Vec3f)} + * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} given {@link PMVMatrix4f} {@code pmv}. + * @param viewport used viewport for {@link PMVMatrix4f#mapObjToWin(Vec3f, Recti, Vec3f)} * @param objPos object position relative to this shape's center - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param glWinPos int[2] target window position of objPos relative to this shape - * @return given int[2] {@code glWinPos} for successful gluProject(..) operation, otherwise {@code null} - * @see #shapeToWinCoord(PMVMatrix, Recti, float[], int[]) - * @see #shapeToWinCoord(Scene, float[], PMVMatrix, int[]) + * @return given int[2] {@code glWinPos} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} + * @see #shapeToWinCoord(PMVMatrix4f, Recti, float[], int[]) + * @see #shapeToWinCoord(Scene, float[], PMVMatrix4f, int[]) */ - public int[/*2*/] shapeToWinCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final Vec3f objPos, final PMVMatrix pmv, final int[/*2*/] glWinPos) { + public int[/*2*/] shapeToWinCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final Vec3f objPos, final PMVMatrix4f pmv, final int[/*2*/] glWinPos) { return this.shapeToWinCoord(setPMVMatrix(pmvMatrixSetup, viewport, pmv), viewport, objPos, glWinPos); } /** * Map given object coordinate relative to this shape to window coordinates. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> * @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport. * @param objPos object position relative to this shape's center - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param glWinPos int[2] target window position of objPos relative to this shape - * @return given int[2] {@code glWinPos} for successful gluProject(..) operation, otherwise {@code null} - * @see #shapeToWinCoord(PMVMatrix, Recti, float[], int[]) - * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, float[], PMVMatrix, int[]) + * @return given int[2] {@code glWinPos} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} operation, otherwise {@code null} + * @see #shapeToWinCoord(PMVMatrix4f, Recti, float[], int[]) + * @see #shapeToWinCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, float[], PMVMatrix4f, int[]) */ - public int[/*2*/] shapeToWinCoord(final Scene scene, final Vec3f objPos, final PMVMatrix pmv, final int[/*2*/] glWinPos) { + public int[/*2*/] shapeToWinCoord(final Scene scene, final Vec3f objPos, final PMVMatrix4f pmv, final int[/*2*/] glWinPos) { return this.shapeToWinCoord(scene.getPMVMatrixSetup(), scene.getViewport(), objPos, pmv, glWinPos); } /** * Map given gl-window-coordinates to object coordinates relative to this shape and its z-coordinate. * <p> - * The given {@link PMVMatrix} has to be setup properly for this object, + * The given {@link PMVMatrix4f} has to be setup properly for this object, * i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene - * including this shape's {@link #setTransform(PMVMatrix)}. See {@link #setPMVMatrix(Scene, PMVMatrix)}. + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. See {@link #setPMVMatrix(Scene, PMVMatrix4f)}. * </p> - * @param pmv well formed {@link PMVMatrix}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix)}. + * @param pmv well formed {@link PMVMatrix4f}, e.g. could have been setup via {@link Shape#setPMVMatrix(Scene, PMVMatrix4f)}. * @param viewport the Rect4i viewport * @param glWinX in GL window coordinates, origin bottom-left * @param glWinY in GL window coordinates, origin bottom-left * @param objPos target object position of glWinX/glWinY relative to this shape - * @return given {@code objPos} for successful gluProject(..) and gluUnProject(..) operation, otherwise {@code null} - * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, int, int, PMVMatrix, float[]) - * @see #winToShapeCoord(Scene, int, int, PMVMatrix, float[]) + * @return given {@code objPos} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} + * and {@link Matrix4f#mapWinToObj(float, float, float, float, Matrix4f, Recti, Vec3f, Vec3f) gluUnProject(..)} + * operation, otherwise {@code null} + * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, int, int, PMVMatrix4f, float[]) + * @see #winToShapeCoord(Scene, int, int, PMVMatrix4f, float[]) */ - public Vec3f winToShapeCoord(final PMVMatrix pmv, final Recti viewport, final int glWinX, final int glWinY, final Vec3f objPos) { + public Vec3f winToShapeCoord(final PMVMatrix4f pmv, final Recti viewport, final int glWinX, final int glWinY, final Vec3f objPos) { final Vec3f ctr = box.getCenter(); - if( Matrix4f.mapObjToWin(ctr, pmv.getPMvMat(), viewport, objPos) ) { + if( Matrix4f.mapObjToWin(ctr, pmv.getPMv(), viewport, objPos) ) { final float winZ = objPos.z(); - if( Matrix4f.mapWinToObj(glWinX, glWinY, winZ, pmv.getPMviMat(), viewport, objPos) ) { + if( Matrix4f.mapWinToObj(glWinX, glWinY, winZ, pmv.getPMvi(), viewport, objPos) ) { return objPos; } } @@ -934,41 +936,45 @@ public abstract class Shape { /** * Map given gl-window-coordinates to object coordinates relative to this shape and its z-coordinate. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> - * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} given {@link PMVMatrix} {@code pmv}. - * @param viewport used viewport for {@link PMVMatrix#gluUnProject(float, float, float, Recti, Vec3f)} + * @param pmvMatrixSetup {@link Scene.PMVMatrixSetup} to {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} given {@link PMVMatrix4f} {@code pmv}. + * @param viewport used viewport for {@link PMVMatrix4f#mapWinToObj(float, float, float, Recti, Vec3f)} * @param glWinX in GL window coordinates, origin bottom-left * @param glWinY in GL window coordinates, origin bottom-left - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param objPos target object position of glWinX/glWinY relative to this shape - * @return given {@code objPos} for successful gluProject(..) and gluUnProject(..) operation, otherwise {@code null} - * @see #winToShapeCoord(PMVMatrix, Recti, int, int, float[]) - * @see #winToShapeCoord(Scene, int, int, PMVMatrix, float[]) + * @return given {@code objPos} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} + * and {@link Matrix4f#mapWinToObj(float, float, float, float, Matrix4f, Recti, Vec3f, Vec3f) gluUnProject(..)} + * operation, otherwise {@code null} + * @see #winToShapeCoord(PMVMatrix4f, Recti, int, int, float[]) + * @see #winToShapeCoord(Scene, int, int, PMVMatrix4f, float[]) */ - public Vec3f winToShapeCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final int glWinX, final int glWinY, final PMVMatrix pmv, final Vec3f objPos) { + public Vec3f winToShapeCoord(final Scene.PMVMatrixSetup pmvMatrixSetup, final Recti viewport, final int glWinX, final int glWinY, final PMVMatrix4f pmv, final Vec3f objPos) { return this.winToShapeCoord(setPMVMatrix(pmvMatrixSetup, viewport, pmv), viewport, glWinX, glWinY, objPos); } /** * Map given gl-window-coordinates to object coordinates relative to this shape and its z-coordinate. * <p> - * The given {@link PMVMatrix} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) setup} properly for this shape - * including this shape's {@link #setTransform(PMVMatrix)}. + * The given {@link PMVMatrix4f} will be {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) setup} properly for this shape + * including this shape's {@link #setMvTransform(PMVMatrix4f)}. * </p> * @param scene {@link Scene} to retrieve {@link Scene.PMVMatrixSetup} and the viewport. * @param glWinX in GL window coordinates, origin bottom-left * @param glWinY in GL window coordinates, origin bottom-left - * @param pmv a new {@link PMVMatrix} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix, Recti) be setup}, - * {@link #setTransform(PMVMatrix) shape-transformed} and can be reused by the caller. + * @param pmv a new {@link PMVMatrix4f} which will {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti) be setup}, + * {@link #setMvTransform(PMVMatrix4f) shape-transformed} and can be reused by the caller. * @param objPos target object position of glWinX/glWinY relative to this shape - * @return given {@code objPos} for successful gluProject(..) and gluUnProject(..) operation, otherwise {@code null} - * @see #winToShapeCoord(PMVMatrix, Recti, int, int, float[]) - * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, int, int, PMVMatrix, float[]) + * @return given {@code objPos} for successful {@link Matrix4f#mapObjToWin(Vec3f, Matrix4f, Recti, Vec3f) gluProject(..)} + * and {@link Matrix4f#mapWinToObj(float, float, float, float, Matrix4f, Recti, Vec3f, Vec3f) gluUnProject(..)} + * operation, otherwise {@code null} + * @see #winToShapeCoord(PMVMatrix4f, Recti, int, int, float[]) + * @see #winToShapeCoord(com.jogamp.graph.ui.Scene.PMVMatrixSetup, Recti, int, int, PMVMatrix4f, float[]) */ - public Vec3f winToShapeCoord(final Scene scene, final int glWinX, final int glWinY, final PMVMatrix pmv, final Vec3f objPos) { + public Vec3f winToShapeCoord(final Scene scene, final int glWinX, final int glWinY, final PMVMatrix4f pmv, final Vec3f objPos) { return this.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, objPos); } @@ -1473,11 +1479,11 @@ public abstract class Shape { * @param e original Newt {@link GestureEvent} * @param glWinX x-position in OpenGL model space * @param glWinY y-position in OpenGL model space - * @param pmv well formed PMVMatrix for this shape + * @param pmv well formed PMVMatrix4f for this shape * @param viewport the viewport * @param objPos object position of mouse event relative to this shape */ - /* pp */ final void dispatchGestureEvent(final GestureEvent e, final int glWinX, final int glWinY, final PMVMatrix pmv, final Recti viewport, final Vec3f objPos) { + /* pp */ final void dispatchGestureEvent(final GestureEvent e, final int glWinX, final int glWinY, final PMVMatrix4f pmv, final Recti viewport, final Vec3f objPos) { if( interactive && resizable && e instanceof PinchToZoomGesture.ZoomEvent ) { final PinchToZoomGesture.ZoomEvent ze = (PinchToZoomGesture.ZoomEvent) e; final float pixels = ze.getDelta() * ze.getScale(); // diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java index 05e3189ae..16e3441a3 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java @@ -31,11 +31,11 @@ import java.util.List; import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Shape; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; /** * GraphUI Stack {@link Group.Layout}. @@ -171,7 +171,7 @@ public class BoxLayout implements Group.Layout { } @Override - public void layout(final Group g, final AABBox box, final PMVMatrix pmv) { + public void layout(final Group g, final AABBox box, final PMVMatrix4f pmv) { final boolean hasCellWidth = !FloatUtil.isZero(cellSize.x()); final boolean hasCellHeight = !FloatUtil.isZero(cellSize.y()); final boolean isCenteredHoriz = hasCellWidth && alignment.isSet(Alignment.Bit.CenterHoriz); @@ -184,10 +184,10 @@ public class BoxLayout implements Group.Layout { final Shape s = shapes.get(i); // measure size - pmv.glPushMatrix(); - s.setTransform(pmv); - s.getBounds().transformMv(pmv, sbox); - pmv.glPopMatrix(); + pmv.pushMv(); + s.setMvTransform(pmv); + s.getBounds().transform(pmv.getMv(), sbox); + pmv.popMv(); final int x = 0, y = 0; if( TRACE_LAYOUT ) { diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/Gap.java b/src/graphui/classes/com/jogamp/graph/ui/layout/Gap.java index 61d93c03c..b29245ef0 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/Gap.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/Gap.java @@ -27,7 +27,7 @@ */ package com.jogamp.graph.ui.layout; -import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.math.FloatUtil; /** * GraphUI CSS property Gap, spacing between (grid) cells not belonging to the element. diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java b/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java index 3afe093f3..aa5a24637 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java @@ -31,11 +31,11 @@ import java.util.List; import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Shape; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; /** * GraphUI Grid {@link Group.Layout}. @@ -159,9 +159,9 @@ public class GridLayout implements Group.Layout { /** Returns given {@link Order}. */ public Order getOrder() { return order; } - /** Returns column count after {@link #layout(Group, AABBox, PMVMatrix)}. */ + /** Returns column count after {@link #layout(Group, AABBox, PMVMatrix4f)}. */ public int getColumnCount() { return col_count; } - /** Returns row count after {@link #layout(Group, AABBox, PMVMatrix)}. */ + /** Returns row count after {@link #layout(Group, AABBox, PMVMatrix4f)}. */ public int getRowCount() { return row_count; } /** Returns the preset cell size */ public Vec2f getCellSize() { return cellSize; } @@ -180,7 +180,7 @@ public class GridLayout implements Group.Layout { } @Override - public void layout(final Group g, final AABBox box, final PMVMatrix pmv) { + public void layout(final Group g, final AABBox box, final PMVMatrix4f pmv) { final boolean hasCellWidth = !FloatUtil.isZero(cellSize.x()); final boolean hasCellHeight = !FloatUtil.isZero(cellSize.y()); final boolean isCenteredHoriz = hasCellWidth && alignment.isSet(Alignment.Bit.CenterHoriz); @@ -207,11 +207,11 @@ public class GridLayout implements Group.Layout { for(int i=0; i < shapes.size(); ++i) { final Shape s = shapes.get(i); // measure size - pmv.glPushMatrix(); - s.setTransform(pmv); - final AABBox sbox = s.getBounds().transformMv(pmv, new AABBox()); + pmv.pushMv(); + s.setMvTransform(pmv); + final AABBox sbox = s.getBounds().transform(pmv.getMv(), new AABBox()); sboxes[i] = sbox; - pmv.glPopMatrix(); + pmv.popMv(); final float shapeWidthU = sbox.getWidth(); final float shapeHeightU = sbox.getHeight(); diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/Margin.java b/src/graphui/classes/com/jogamp/graph/ui/layout/Margin.java index 72d366ae2..629d3bb7b 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/Margin.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/Margin.java @@ -27,7 +27,7 @@ */ package com.jogamp.graph.ui.layout; -import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.math.FloatUtil; /** * GraphUI CSS property Margin, space between or around elements and not included in the element's size. diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java b/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java index 25caf57dc..f686e8498 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java +++ b/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java @@ -27,7 +27,7 @@ */ package com.jogamp.graph.ui.layout; -import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.math.FloatUtil; /** * GraphUI CSS property Padding, space belonging to the element and included in the element's size. diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java index 474cc0a6a..cdf6cb161 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java @@ -35,16 +35,16 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.Scene.PMVMatrixSetup; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.graph.ui.shapes.Label0; diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java index ade147e50..4cdf4f613 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java @@ -34,12 +34,12 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.texture.TextureSequence; /** diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java index 54105e85a..dbce45a6d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java @@ -29,7 +29,6 @@ package com.jogamp.graph.ui.shapes; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.texture.TextureSequence; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; @@ -38,8 +37,9 @@ import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; -import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; /** * A GraphUI text label {@link GraphShape} diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java index 7f9375fc6..02ecd406c 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java @@ -32,9 +32,9 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.ui.GraphShape; import com.jogamp.graph.ui.Shape; +import com.jogamp.math.geom.AABBox; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.texture.TextureSequence; /** diff --git a/src/graphui/classes/jogamp/graph/ui/TreeTool.java b/src/graphui/classes/jogamp/graph/ui/TreeTool.java index c5701d6e2..d43c6c7f7 100644 --- a/src/graphui/classes/jogamp/graph/ui/TreeTool.java +++ b/src/graphui/classes/jogamp/graph/ui/TreeTool.java @@ -36,7 +36,7 @@ import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Shape; import com.jogamp.graph.ui.Shape.Visitor1; import com.jogamp.graph.ui.Shape.Visitor2; -import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.math.util.PMVMatrix4f; /** Generic static {@link Shape} tree traversal tools, utilized by {@link Scene} and {@link Container} implementations. */ public class TreeTool { @@ -48,24 +48,24 @@ public class TreeTool { * @param action * @return true to signal operation complete, i.e. {@code shape} found, otherwise false */ - public static boolean forOne(final List<Shape> shapes, final PMVMatrix pmv, final Shape shape, final Runnable action) { + public static boolean forOne(final List<Shape> shapes, final PMVMatrix4f pmv, final Shape shape, final Runnable action) { for(int i=0; i<shapes.size(); ++i) { final Shape s = shapes.get(i); if( s.equals(shape) ) { - pmv.glPushMatrix(); - s.setTransform(pmv); + pmv.pushMv(); + s.setMvTransform(pmv); action.run(); - pmv.glPopMatrix(); + pmv.popMv(); return true; } else if( s instanceof Container ) { final Container c = (Container)s; if( !c.contains(shape) ) { // fast-path: skip container continue; } - pmv.glPushMatrix(); - s.setTransform(pmv); + pmv.pushMv(); + s.setMvTransform(pmv); final boolean res = c.forOne(pmv, shape, action); - pmv.glPopMatrix(); + pmv.popMv(); if( !res ) { throw new InternalError("Not found "+shape+" in "+c+", but contained"); } return true; } @@ -99,17 +99,17 @@ public class TreeTool { * @param v * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix)} returned true, otherwise false */ - public static boolean forAll(final List<Shape> shapes, final PMVMatrix pmv, final Visitor2 v) { + public static boolean forAll(final List<Shape> shapes, final PMVMatrix4f pmv, final Visitor2 v) { for(int i=0; i<shapes.size(); ++i) { final Shape s = shapes.get(i); - pmv.glPushMatrix(); - s.setTransform(pmv); + pmv.pushMv(); + s.setMvTransform(pmv); boolean res = v.visit(s, pmv); if( !res && s instanceof Container ) { final Container c = (Container)s; res = c.forAll(pmv, v); } - pmv.glPopMatrix(); + pmv.popMv(); if( res ) { return true; } @@ -127,20 +127,20 @@ public class TreeTool { * @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix)} returned true, otherwise false */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public static boolean forSortedAll(final Comparator<Shape> sortComp, final List<Shape> shapes, final PMVMatrix pmv, final Visitor2 v) { + public static boolean forSortedAll(final Comparator<Shape> sortComp, final List<Shape> shapes, final PMVMatrix4f pmv, final Visitor2 v) { final Object[] shapesS = shapes.toArray(); Arrays.sort(shapesS, (Comparator)sortComp); for(int i=0; i<shapesS.length; ++i) { final Shape s = (Shape)shapesS[i]; - pmv.glPushMatrix(); - s.setTransform(pmv); + pmv.pushMv(); + s.setMvTransform(pmv); boolean res = v.visit(s, pmv); if( !res && s instanceof Container ) { final Container c = (Container)s; res = c.forSortedAll(sortComp, pmv, v); } - pmv.glPopMatrix(); + pmv.popMv(); if( res ) { return true; } diff --git a/src/graphui/classes/jogamp/graph/ui/shapes/Label0.java b/src/graphui/classes/jogamp/graph/ui/shapes/Label0.java index 3809c3a07..2ee370dea 100644 --- a/src/graphui/classes/jogamp/graph/ui/shapes/Label0.java +++ b/src/graphui/classes/jogamp/graph/ui/shapes/Label0.java @@ -30,10 +30,10 @@ package jogamp.graph.ui.shapes; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; public class Label0 { protected Font font; diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index 644f428cd..2da0f6850 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -36,14 +36,14 @@ import com.jogamp.graph.curve.tess.Triangulator; import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.graph.geom.plane.Path2F; -import com.jogamp.graph.geom.plane.Winding; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.math.Vert2fImmutable; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; +import com.jogamp.math.VectorUtil; +import com.jogamp.math.Vert2fImmutable; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.geom.plane.Path2F; +import com.jogamp.math.geom.plane.Winding; /** * A Generic shape objects which is defined by a list of Outlines. @@ -671,7 +671,7 @@ public final class OutlineShape implements Comparable<OutlineShape> { * @param y point (P1) * @param z point (P1) * @see Path2F#moveTo(float, float) - * @see #addPath(com.jogamp.graph.geom.plane.Path2F.Iterator, boolean) + * @see #addPath(com.jogamp.math.geom.plane.Path2F.Iterator, boolean) * @see <a href="#windingrules">see winding rules</a> */ public final void moveTo(final float x, final float y, final float z) { @@ -691,7 +691,7 @@ public final class OutlineShape implements Comparable<OutlineShape> { * @param y final point (P1) * @param z final point (P1) * @see Path2F#lineTo(float, float) - * @see #addPath(com.jogamp.graph.geom.plane.Path2F.Iterator, boolean) + * @see #addPath(com.jogamp.math.geom.plane.Path2F.Iterator, boolean) * @see <a href="#windingrules">see winding rules</a> */ public final void lineTo(final float x, final float y, final float z) { @@ -708,7 +708,7 @@ public final class OutlineShape implements Comparable<OutlineShape> { * @param y2 final interpolated control point (P2) * @param z2 quadratic parametric control point (P2) * @see Path2F#quadTo(float, float, float, float) - * @see #addPath(com.jogamp.graph.geom.plane.Path2F.Iterator, boolean) + * @see #addPath(com.jogamp.math.geom.plane.Path2F.Iterator, boolean) * @see <a href="#windingrules">see winding rules</a> */ public final void quadTo(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) { @@ -729,7 +729,7 @@ public final class OutlineShape implements Comparable<OutlineShape> { * @param y3 final interpolated control point (P3) * @param z3 final interpolated control point (P3) * @see Path2F#cubicTo(float, float, float, float, float, float) - * @see #addPath(com.jogamp.graph.geom.plane.Path2F.Iterator, boolean) + * @see #addPath(com.jogamp.math.geom.plane.Path2F.Iterator, boolean) * @see <a href="#windingrules">see winding rules</a> */ public final void cubicTo(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2, final float x3, final float y3, final float z3) { @@ -741,7 +741,7 @@ public final class OutlineShape implements Comparable<OutlineShape> { /** * Closes the current sub-path segment by drawing a straight line back to the coordinates of the last moveTo. If the path is already closed then this method has no effect. * @see Path2F#closePath() - * @see #addPath(com.jogamp.graph.geom.plane.Path2F.Iterator, boolean) + * @see #addPath(com.jogamp.math.geom.plane.Path2F.Iterator, boolean) */ public final void closePath() { if ( 0 < getLastOutline().getVertexCount() ) { diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java index 1a21ea74f..c8d9223af 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java @@ -1,6 +1,6 @@ package com.jogamp.graph.curve; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.plane.AffineTransform; public class OutlineShapeXForm { public final OutlineShape shape; diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 66ef3da6e..93b05aefa 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -40,17 +40,17 @@ import jogamp.opengl.Debug; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.Frustum; +import com.jogamp.math.geom.plane.AffineTransform; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Clock; import com.jogamp.common.util.PerfCounterCtrl; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.opengl.GLCapabilitiesImmutable; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.math.geom.Frustum; import com.jogamp.opengl.util.texture.TextureSequence; /** diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java index d25ab4311..47f8e1b2a 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -35,8 +35,6 @@ import com.jogamp.opengl.util.GLArrayDataEditable; import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.GLArrayDataWrapper;
import com.jogamp.opengl.GLProfile;
-import com.jogamp.opengl.math.Vec3f;
-import com.jogamp.opengl.math.Vec4f;
import jogamp.graph.curve.opengl.VBORegion2PMSAAES2;
import jogamp.graph.curve.opengl.VBORegion2PVBAAES2;
@@ -44,11 +42,12 @@ import jogamp.graph.curve.opengl.VBORegionSPES2; import jogamp.graph.curve.opengl.shader.AttributeNames;
import jogamp.opengl.Debug;
-import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.TextureSequence;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.font.Font;
+import com.jogamp.math.Vec3f;
+import com.jogamp.math.Vec4f;
import java.io.PrintStream;
import java.nio.FloatBuffer;
@@ -508,7 +507,7 @@ public abstract class GLRegion extends Region { * {@link RegionRenderer#create(Vertex.Factory<? extends Vertex>, RenderState, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback) created}
* with the appropriate {@link RegionRenderer.GLCallback callbacks}.
* </p>
- * @param matrix current {@link PMVMatrix}.
+ * @param gl current {@link GL2ES2}.
* @param renderer the {@link RegionRenderer} to be used
* @param sampleCount desired multisampling sample count for vbaa- or msaa-rendering.
* Use -1 for glSelect mode, pass1 w/o any color texture nor channel, use static select color only.
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java index 6fbedf809..7e3a7ff30 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -34,9 +34,6 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLES2; import com.jogamp.opengl.GLException; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec4f; import jogamp.graph.curve.opengl.shader.AttributeNames; import jogamp.graph.curve.opengl.shader.UniformNames; @@ -46,10 +43,12 @@ import com.jogamp.opengl.GLRendererQuirks; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.TextureSequence; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.common.os.Platform; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.curve.Region; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec4f; +import com.jogamp.math.util.PMVMatrix4f; /** * OpenGL {@link Region} renderer @@ -177,7 +176,7 @@ public final class RegionRenderer { * For example, instances {@link #defaultBlendEnable} and {@link #defaultBlendDisable} * can be utilized to enable and disable {@link GL#GL_BLEND}. * </p> - * @param sharedPMVMatrix optional shared {@link PMVMatrix} to be used for the {@link RenderState} composition. + * @param sharedPMVMatrix optional shared {@link PMVMatrix4f} to be used for the {@link RenderState} composition. * @param enableCallback optional {@link GLCallback}, if not <code>null</code> will be issued at * {@link #init(GL2ES2) init(gl)} and {@link #enable(GL2ES2, boolean) enable(gl, true)}. * @param disableCallback optional {@link GLCallback}, if not <code>null</code> will be issued at @@ -185,7 +184,7 @@ public final class RegionRenderer { * @return an instance of Region Renderer * @see #enable(GL2ES2, boolean) */ - public static RegionRenderer create(final PMVMatrix sharedPMVMatrix, + public static RegionRenderer create(final PMVMatrix4f sharedPMVMatrix, final GLCallback enableCallback, final GLCallback disableCallback) { return new RegionRenderer(sharedPMVMatrix, enableCallback, disableCallback); } @@ -221,7 +220,7 @@ public final class RegionRenderer { this(null, enableCallback, disableCallback); } - protected RegionRenderer(final PMVMatrix sharedPMVMatrix, + protected RegionRenderer(final PMVMatrix4f sharedPMVMatrix, final GLCallback enableCallback, final GLCallback disableCallback) { this.rs = new RenderState(sharedPMVMatrix); @@ -290,8 +289,8 @@ public final class RegionRenderer { // RenderState forwards // - /** Borrow the current {@link PMVMatrix}. */ - public final PMVMatrix getMatrix() { return rs.getMatrix(); } + /** Borrow the current {@link PMVMatrix4f}. */ + public final PMVMatrix4f getMatrix() { return rs.getMatrix(); } public final float getWeight() { return rs.getWeight(); } @@ -357,7 +356,7 @@ public final class RegionRenderer { } /** - * No PMVMatrix operation is performed here. + * No PMVMatrix4f operation is performed here. */ public final void reshapeNotify(final int x, final int y, final int width, final int height) { viewport.set(x, y, width, height); @@ -374,10 +373,9 @@ public final class RegionRenderer { public final void reshapePerspective(final float angle_rad, final int width, final int height, final float near, final float far) { reshapeNotify(0, 0, width, height); final float ratio = (float)width/(float)height; - final PMVMatrix p = getMatrix(); - p.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - p.glLoadIdentity(); - p.gluPerspective(angle_rad, ratio, near, far); + final PMVMatrix4f p = getMatrix(); + p.loadPIdentity(); + p.perspectiveP(angle_rad, ratio, near, far); } /** @@ -389,10 +387,9 @@ public final class RegionRenderer { */ public final void reshapeOrtho(final int width, final int height, final float near, final float far) { reshapeNotify(0, 0, width, height); - final PMVMatrix p = getMatrix(); - p.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - p.glLoadIdentity(); - p.glOrthof(0, width, 0, height, near, far); + final PMVMatrix4f p = getMatrix(); + p.loadPIdentity(); + p.orthoP(0, width, 0, height, near, far); } // diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index f2e1c8066..b1bbdde91 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -33,20 +33,20 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLUniformData; -import com.jogamp.opengl.math.Vec4f; import jogamp.common.os.PlatformPropsImpl; import jogamp.graph.curve.opengl.shader.UniformNames; import com.jogamp.graph.curve.Region; +import com.jogamp.math.Vec4f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.util.GLArrayDataWrapper; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderProgram; /** * The RenderState is owned by {@link RegionRenderer}. * - * It holds rendering state data like {@link PMVMatrix}, viewport, + * It holds rendering state data like {@link PMVMatrix4f}, viewport, * but also the current {@link #getColorStatic(float[]) static color}. */ public class RenderState { @@ -91,7 +91,7 @@ public class RenderState { return (RenderState) gl.getContext().getAttachedObject(thisKey); } - private final PMVMatrix pmvMatrix; + private final PMVMatrix4f pmvMatrix; private final float[] weight; private final FloatBuffer weightBuffer; private final float[] colorStatic; @@ -140,7 +140,7 @@ public class RenderState { public final boolean update(final GL2ES2 gl, final RenderState rs, final boolean updateLocation, final int renderModes, final boolean pass1, final boolean throwOnError) { if( rs.id() != rsId ) { // Assignment of Renderstate buffers to uniforms (no copy, direct reference) - gcu_PMVMatrix01.setData(rs.pmvMatrix.getSyncPMvMat()); + gcu_PMVMatrix01.setData(rs.pmvMatrix.getSyncPMv()); gcu_Weight.setData(rs.weightBuffer); gcu_ColorStatic.setData(rs.colorStaticBuffer); rsId = rs.id(); @@ -185,12 +185,12 @@ public class RenderState { /** * Create a RenderState, a composition of RegionRenderer - * @param sharedPMVMatrix optional shared PMVMatrix, if null using a local instance + * @param sharedPMVMatrix optional shared PMVMatrix4f, if null using a local instance */ - /* pp */ RenderState(final PMVMatrix sharedPMVMatrix) { + /* pp */ RenderState(final PMVMatrix4f sharedPMVMatrix) { this.id = getNextID(); this.sp = null; - this.pmvMatrix = null != sharedPMVMatrix ? sharedPMVMatrix : new PMVMatrix(); + this.pmvMatrix = null != sharedPMVMatrix ? sharedPMVMatrix : new PMVMatrix4f(); this.weight = new float[1]; this.weightBuffer = FloatBuffer.wrap(weight); this.colorStatic = new float[] { 1, 1, 1, 1 }; @@ -229,7 +229,8 @@ public class RenderState { return true; } - public final PMVMatrix getMatrix() { return pmvMatrix; } + /** Borrow the current {@link PMVMatrix4f}. */ + public final PMVMatrix4f getMatrix() { return pmvMatrix; } public static boolean isWeightValid(final float v) { return 0.0f <= v && v <= 1.9f ; diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java index 0090480bb..782615c3e 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -33,13 +33,13 @@ import java.util.Iterator; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLException; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; /** * Text Type Rendering Utility Class adding the {@link Font.Glyph}s {@link OutlineShape} to a {@link GLRegion}. diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index c3c997135..997eacbb8 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -28,8 +28,8 @@ package com.jogamp.graph.font; import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; /** * Interface wrapper for font implementation. diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index 654bd2636..272f92f37 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -29,13 +29,13 @@ package com.jogamp.graph.geom; import java.util.ArrayList; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.graph.geom.plane.Winding; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.VectorUtil; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.geom.plane.Winding; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.math.geom.AABBox; diff --git a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java index 6b07501a6..e26d2aaf1 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java @@ -27,8 +27,8 @@ */ package com.jogamp.graph.geom; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.math.VectorUtil; +import com.jogamp.math.geom.plane.AffineTransform; public class Triangle { private final Vertex[] vertices = new Vertex[3]; diff --git a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java index e5fe76c28..8744474d9 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java @@ -27,9 +27,9 @@ */ package com.jogamp.graph.geom; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vert3fImmutable; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vert3fImmutable; /** * A Vertex exposing Vec3f vertex- and texture-coordinates. diff --git a/src/jogl/classes/com/jogamp/opengl/math/Binary16.java b/src/jogl/classes/com/jogamp/math/Binary16.java index 8e4aa9176..725c608c6 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Binary16.java +++ b/src/jogl/classes/com/jogamp/math/Binary16.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * <p> diff --git a/src/jogl/classes/com/jogamp/opengl/math/Binary32.java b/src/jogl/classes/com/jogamp/math/Binary32.java index 599b1ff68..398f97c3a 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Binary32.java +++ b/src/jogl/classes/com/jogamp/math/Binary32.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * Functions for interrogating <code>binary32</code> (float) values. diff --git a/src/jogl/classes/com/jogamp/opengl/math/Binary64.java b/src/jogl/classes/com/jogamp/math/Binary64.java index d4ec636a5..8561cfa8d 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Binary64.java +++ b/src/jogl/classes/com/jogamp/math/Binary64.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * Functions for interrogating <code>binary64</code> (double) values. diff --git a/src/jogl/classes/com/jogamp/math/DoubleUtil.java b/src/jogl/classes/com/jogamp/math/DoubleUtil.java new file mode 100644 index 000000000..e9ccceb10 --- /dev/null +++ b/src/jogl/classes/com/jogamp/math/DoubleUtil.java @@ -0,0 +1,274 @@ +/** + * Copyright 2010-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.math; + +/** + * Basic Double math utility functions. + */ +public final class DoubleUtil { + // + // Scalar Ops + // + + @SuppressWarnings("unused") + private static void calculateMachineEpsilonDouble() { + final long t0; + double machEps = 1.0; + int i=0; + do { + machEps /= 2.0; + i++; + } while (1.0 + (machEps / 2.0) != 1.0); + machEpsilon = machEps; + } + private static volatile boolean machEpsilonAvail = false; + private static double machEpsilon = 0f; + + /** + * Return computed machine Epsilon value. + * <p> + * The machine Epsilon value is computed once. + * </p> + * @see #EPSILON + */ + public static double getMachineEpsilon() { + if( !machEpsilonAvail ) { + synchronized(DoubleUtil.class) { + if( !machEpsilonAvail ) { + machEpsilonAvail = true; + calculateMachineEpsilonDouble(); + } + } + } + return machEpsilon; + } + + public static final double E = 2.7182818284590452354; + + /** The value PI, i.e. 180 degrees in radians. */ + public static final double PI = 3.14159265358979323846; + + /** The value 2PI, i.e. 360 degrees in radians. */ + public static final double TWO_PI = 2.0 * PI; + + /** The value PI/2, i.e. 90 degrees in radians. */ + public static final double HALF_PI = PI / 2.0; + + /** The value PI/4, i.e. 45 degrees in radians. */ + public static final double QUARTER_PI = PI / 4.0; + + /** The value PI^2. */ + public final static double SQUARED_PI = PI * PI; + + /** Converts arc-degree to radians */ + public static double adegToRad(final double arc_degree) { + return arc_degree * PI / 180.0; + } + + /** Converts radians to arc-degree */ + public static double radToADeg(final double rad) { + return rad * 180.0 / PI; + } + + /** + * Epsilon for floating point {@value}, as once computed via {@link #getMachineEpsilon()} on an AMD-64 CPU. + * <p> + * Definition of machine epsilon guarantees that: + * <pre> + * 1.0 + EPSILON != 1.0 + * </pre> + * In other words: <i>machEps</i> is the maximum relative error of the chosen rounding procedure. + * </p> + * <p> + * A number can be considered zero if it is in the range (or in the set): + * <pre> + * <b>MaybeZeroSet</b> e ]-<i>machEps</i> .. <i>machEps</i>[ <i>(exclusive)</i> + * </pre> + * While comparing floating point values, <i>machEps</i> allows to clip the relative error: + * <pre> + * boolean isZero = afloat < EPSILON; + * boolean isNotZero = afloat >= EPSILON; + * + * boolean isEqual = abs(bfloat - afloat) < EPSILON; + * boolean isNotEqual = abs(bfloat - afloat) >= EPSILON; + * </pre> + * </p> + * @see #isEqual(float, float, float) + * @see #isZero(float, float) + */ + public static final double EPSILON = 2.220446049250313E-16; + + /** + * Inversion Epsilon, used with equals method to determine if two inverted matrices are close enough to be considered equal. + * <p> + * Using {@value}, which is ~100 times {@link DoubleUtil#EPSILON}. + * </p> + */ + public static final double INV_DEVIANCE = 1.0E-8f; // EPSILON == 1.1920929E-7f; double ALLOWED_DEVIANCE: 1.0E-8f + + /** + * Return true if both values are equal w/o regarding an epsilon. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * </ul> + * </p> + * @see #isEqual(float, float, float) + */ + public static boolean isEqualRaw(final double a, final double b) { + // Values are equal (Inf, Nan .. ) + return Double.doubleToLongBits(a) == Double.doubleToLongBits(b); + } + + /** + * Return true if both values are equal, i.e. their absolute delta < <code>epsilon</code>. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * </ul> + * </p> + * @see #EPSILON + */ + public static boolean isEqual(final double a, final double b, final double epsilon) { + if ( Math.abs(a - b) < epsilon ) { + return true; + } else { + // Values are equal (Inf, Nan .. ) + return Double.doubleToLongBits(a) == Double.doubleToLongBits(b); + } + } + + /** + * Return true if both values are equal, i.e. their absolute delta < {@link #EPSILON}. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * </ul> + * </p> + * @see #EPSILON + */ + public static boolean isEqual(final double a, final double b) { + if ( Math.abs(a - b) < EPSILON ) { + return true; + } else { + // Values are equal (Inf, Nan .. ) + return Double.doubleToLongBits(a) == Double.doubleToLongBits(b); + } + } + + /** + * Return true if both values are equal, i.e. their absolute delta < {@link #EPSILON}. + * <p> + * Implementation does not consider corner cases like {@link #isEqual(float, float, float)}. + * </p> + * @see #EPSILON + */ + public static boolean isEqual2(final double a, final double b) { + return Math.abs(a - b) < EPSILON; + } + + /** + * Return true if both values are equal w/o regarding an epsilon. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * <li>NaN > 0</li> + * <li>+Inf > -Inf</li> + * </ul> + * </p> + * @see #compare(float, float, float) + */ + public static int compare(final double a, final double b) { + if (a < b) { + return -1; // Neither is NaN, a is smaller + } + if (a > b) { + return 1; // Neither is NaN, a is larger + } + final long aBits = Double.doubleToLongBits(a); + final long bBits = Double.doubleToLongBits(b); + if( aBits == bBits ) { + return 0; // Values are equal (Inf, Nan .. ) + } else if( aBits < bBits ) { + return -1; // (-0.0, 0.0) or (!NaN, NaN) + } else { + return 1; // ( 0.0, -0.0) or ( NaN, !NaN) + } + } + + /** + * Return true if both values are equal, i.e. their absolute delta < <code>epsilon</code>. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * <li>NaN > 0</li> + * <li>+Inf > -Inf</li> + * </ul> + * </p> + * @see #EPSILON + */ + public static int compare(final double a, final double b, final double epsilon) { + if ( Math.abs(a - b) < epsilon ) { + return 0; + } else { + return compare(a, b); + } + } + + /** + * Return true if value is zero, i.e. it's absolute value < <code>epsilon</code>. + * @see #EPSILON + */ + public static boolean isZero(final double a, final double epsilon) { + return Math.abs(a) < epsilon; + } + + /** + * Return true if value is zero, i.e. it's absolute value < {@link #EPSILON}. + * @see #EPSILON + */ + public static boolean isZero(final double a) { + return Math.abs(a) < EPSILON; + } + +}
\ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java b/src/jogl/classes/com/jogamp/math/FixedPoint.java index 31408b079..d40bd6dac 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java +++ b/src/jogl/classes/com/jogamp/math/FixedPoint.java @@ -31,7 +31,7 @@ * */ -package com.jogamp.opengl.math; +package com.jogamp.math; public class FixedPoint { public static final int toFixed(int value) { diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/math/FloatUtil.java index 25b5a8ad7..e75e86b7f 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java +++ b/src/jogl/classes/com/jogamp/math/FloatUtil.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; import java.nio.FloatBuffer; import java.util.Locale; diff --git a/src/jogl/classes/com/jogamp/opengl/math/FovHVHalves.java b/src/jogl/classes/com/jogamp/math/FovHVHalves.java index 5d7907f2f..cc7bcee3d 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FovHVHalves.java +++ b/src/jogl/classes/com/jogamp/math/FovHVHalves.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * Horizontal and vertical field of view (FOV) halves, diff --git a/src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java b/src/jogl/classes/com/jogamp/math/Matrix4f.java index 5d1d8e968..ee505a95d 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Matrix4f.java +++ b/src/jogl/classes/com/jogamp/math/Matrix4f.java @@ -26,13 +26,13 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; import java.nio.FloatBuffer; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.math.geom.Frustum; -import com.jogamp.opengl.math.geom.Frustum.Plane; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.Frustum; +import com.jogamp.math.geom.Frustum.Plane; /** * Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations). @@ -40,8 +40,7 @@ import com.jogamp.opengl.math.geom.Frustum.Plane; * Implementation covers {@link FloatUtil} matrix functionality, exposed in an object oriented manner. * </p> * <p> - * Unlike {@link com.jogamp.opengl.util.PMVMatrix PMVMatrix}, this class only represents one single matrix - * without a complete {@link com.jogamp.opengl.fixedfunc.GLMatrixFunc GLMatrixFunc} implementation. + * Unlike {@link com.jogamp.math.util.PMVMatrix4f PMVMatrix4f}, this class only represents one single matrix. * </p> * <p> * For array operations the layout is expected in column-major order @@ -84,7 +83,7 @@ import com.jogamp.opengl.math.geom.Frustum.Plane; * <li><a href="https://github.com/lessthanoptimal/ejml">EJML Efficient Java Matrix Library</a></li> * </ul> * </p> - * @see com.jogamp.opengl.util.PMVMatrix + * @see com.jogamp.math.util.PMVMatrix4f * @see FloatUtil */ public class Matrix4f { @@ -1319,7 +1318,7 @@ public class Matrix4f { * @return this matrix for chaining * @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear} * @see #setToFrustum(float, float, float, float, float, float) - * @see Frustum#updateByFovDesc(Matrix4f, com.jogamp.opengl.math.geom.Frustum.FovDesc) + * @see Frustum#updateByFovDesc(Matrix4f, com.jogamp.math.geom.Frustum.FovDesc) */ public Matrix4f setToPerspective(final FovHVHalves fovhv, final float zNear, final float zFar) throws IllegalArgumentException { final FovHVHalves fovhvTan = fovhv.toTangents(); // use tangent of half-fov ! diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/math/Quaternion.java index 0d04c69cc..690c1b8dc 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/math/Quaternion.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * Quaternion implementation supporting diff --git a/src/jogl/classes/com/jogamp/opengl/math/Ray.java b/src/jogl/classes/com/jogamp/math/Ray.java index 25a7d9a70..0189b9ce2 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Ray.java +++ b/src/jogl/classes/com/jogamp/math/Ray.java @@ -25,9 +25,9 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; /** * Simple compound denoting a ray. diff --git a/src/jogl/classes/com/jogamp/opengl/math/Recti.java b/src/jogl/classes/com/jogamp/math/Recti.java index 58f5e5e77..68e0cfd0b 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Recti.java +++ b/src/jogl/classes/com/jogamp/math/Recti.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * Rectangle with x, y, width and height integer components. diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java b/src/jogl/classes/com/jogamp/math/Vec2f.java index f504b960b..27371401a 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java +++ b/src/jogl/classes/com/jogamp/math/Vec2f.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * 2D Vector based upon two float components. diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec2i.java b/src/jogl/classes/com/jogamp/math/Vec2i.java index 9e70a502f..73906120d 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec2i.java +++ b/src/jogl/classes/com/jogamp/math/Vec2i.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * 2D Vector based upon two integer components. diff --git a/src/jogl/classes/com/jogamp/math/Vec3d.java b/src/jogl/classes/com/jogamp/math/Vec3d.java new file mode 100644 index 000000000..14408f714 --- /dev/null +++ b/src/jogl/classes/com/jogamp/math/Vec3d.java @@ -0,0 +1,397 @@ +/** + * Copyright 2022-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.math; + + +/** + * 3D Vector based upon three double components. + * + * Implementation borrowed from [gfxbox2](https://jausoft.com/cgit/cs_class/gfxbox2.git/tree/include/pixel/pixel3f.hpp#n29) + * and its data layout from JOAL's Vec3f. + */ +public final class Vec3d { + private double x; + private double y; + private double z; + + public Vec3d() {} + + public Vec3d(final Vec3d o) { + set(o); + } + + /** Creating new Vec3f using Vec4f, dropping w. */ + public Vec3d(final Vec4f o) { + set(o); + } + + /** Creating new Vec3f using { Vec2f, z}. */ + public Vec3d(final Vec2f o, final double z) { + set(o, z); + } + + public Vec3d copy() { + return new Vec3d(this); + } + + public Vec3d(final double[/*3*/] xyz) { + set(xyz); + } + + public Vec3d(final double x, final double y, final double z) { + set(x, y, z); + } + + /** this = o, returns this. */ + public Vec3d set(final Vec3d o) { + this.x = o.x; + this.y = o.y; + this.z = o.z; + return this; + } + + /** this = { o, z }, returns this. */ + public Vec3d set(final Vec2f o, final double z) { + this.x = o.x(); + this.y = o.y(); + this.z = z; + return this; + } + + /** this = o while dropping w, returns this. */ + public Vec3d set(final Vec4f o) { + this.x = o.x(); + this.y = o.y(); + this.z = o.z(); + return this; + } + + /** this = { x, y, z }, returns this. */ + public Vec3d set(final double x, final double y, final double z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + /** this = xyz, returns this. */ + public Vec3d set(final double[/*3*/] xyz) { + this.x = xyz[0]; + this.y = xyz[1]; + this.z = xyz[2]; + return this; + } + + /** Sets the ith component, 0 <= i < 3 */ + public void set(final int i, final double val) { + switch (i) { + case 0: x = val; break; + case 1: y = val; break; + case 2: z = val; break; + default: throw new IndexOutOfBoundsException(); + } + } + + /** xyz = this, returns xyz. */ + public double[] get(final double[/*3*/] xyz) { + xyz[0] = this.x; + xyz[1] = this.y; + xyz[2] = this.z; + return xyz; + } + + /** Gets the ith component, 0 <= i < 3 */ + public double get(final int i) { + switch (i) { + case 0: return x; + case 1: return y; + case 2: return z; + default: throw new IndexOutOfBoundsException(); + } + } + + public double x() { return x; } + public double y() { return y; } + public double z() { return z; } + + public void setX(final double x) { this.x = x; } + public void setY(final double y) { this.y = y; } + public void setZ(final double z) { this.z = z; } + + /** this = max(this, m), returns this. */ + public Vec3d max(final Vec3d m) { + this.x = Math.max(this.x, m.x); + this.y = Math.max(this.y, m.y); + this.z = Math.max(this.z, m.z); + return this; + } + /** this = min(this, m), returns this. */ + public Vec3d min(final Vec3d m) { + this.x = Math.min(this.x, m.x); + this.y = Math.min(this.y, m.y); + this.z = Math.min(this.z, m.z); + return this; + } + + /** Returns this * val; creates new vector */ + public Vec3d mul(final double val) { + return new Vec3d(this).scale(val); + } + + /** this = a * b, returns this. */ + public Vec3d mul(final Vec3d a, final Vec3d b) { + x = a.x * b.x; + y = a.y * b.y; + z = a.z * b.z; + return this; + } + + /** this = this * s, returns this. */ + public Vec3d scale(final double s) { + x *= s; + y *= s; + z *= s; + return this; + } + + /** this = this * { sx, sy, sz }, returns this. */ + public Vec3d scale(final double sx, final double sy, final double sz) { + x *= sx; + y *= sy; + z *= sz; + return this; + } + + /** this = this * { s.x, s.y, s.z }, returns this. */ + public Vec3d scale(final Vec3d s) { return scale(s.x, s.y, s.z); } + + /** Returns this + arg; creates new vector */ + public Vec3d plus(final Vec3d arg) { + return new Vec3d(this).add(arg); + } + + /** this = a + b, returns this. */ + public Vec3d plus(final Vec3d a, final Vec3d b) { + x = a.x + b.x; + y = a.y + b.y; + z = a.z + b.z; + return this; + } + + /** this = this + { dx, dy, dz }, returns this. */ + public Vec3d add(final double dx, final double dy, final double dz) { + x += dx; + y += dy; + z += dz; + return this; + } + + /** this = this + b, returns this. */ + public Vec3d add(final Vec3d b) { + x += b.x; + y += b.y; + z += b.z; + return this; + } + + /** Returns this - arg; creates new vector */ + public Vec3d minus(final Vec3d arg) { + return new Vec3d(this).sub(arg); + } + + /** this = a - b, returns this. */ + public Vec3d minus(final Vec3d a, final Vec3d b) { + x = a.x - b.x; + y = a.y - b.y; + z = a.z - b.z; + return this; + } + + /** this = this - b, returns this. */ + public Vec3d sub(final Vec3d b) { + x -= b.x; + y -= b.y; + z -= b.z; + return this; + } + + /** Return true if all components are zero, i.e. it's absolute value < {@link #EPSILON}. */ + public boolean isZero() { + return DoubleUtil.isZero(x) && DoubleUtil.isZero(y) && DoubleUtil.isZero(z); + } + + /** + * Return the length of this vector, a.k.a the <i>norm</i> or <i>magnitude</i> + */ + public double length() { + return Math.sqrt(lengthSq()); + } + + /** + * Return the squared length of this vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i> + */ + public double lengthSq() { + return x*x + y*y + z*z; + } + + /** + * Normalize this vector in place + */ + public Vec3d normalize() { + final double lengthSq = lengthSq(); + if ( DoubleUtil.isZero( lengthSq ) ) { + x = 0.0f; + y = 0.0f; + z = 0.0f; + } else { + final double invSqr = 1.0f / Math.sqrt(lengthSq); + x *= invSqr; + y *= invSqr; + z *= invSqr; + } + return this; + } + + /** + * Return the squared distance between this vector and the given one. + * <p> + * When comparing the relative distance between two points it is usually sufficient to compare the squared + * distances, thus avoiding an expensive square root operation. + * </p> + */ + public double distSq(final Vec3d o) { + final double dx = x - o.x; + final double dy = y - o.y; + final double dz = z - o.z; + return dx*dx + dy*dy + dz*dz; + } + + /** + * Return the distance between this vector and the given one. + */ + public double dist(final Vec3d o) { + return Math.sqrt(distSq(o)); + } + + + /** + * Return the dot product of this vector and the given one + * @return the dot product as double + */ + public double dot(final Vec3d o) { + return x*o.x + y*o.y + z*o.z; + } + + /** Returns this cross arg; creates new vector */ + public Vec3d cross(final Vec3d arg) { + return new Vec3d().cross(this, arg); + } + + /** this = a cross b. NOTE: "this" must be a different vector than + both a and b. */ + public Vec3d cross(final Vec3d a, final Vec3d b) { + x = a.y * b.z - a.z * b.y; + y = a.z * b.x - a.x * b.z; + z = a.x * b.y - a.y * b.x; + return this; + } + + /** + * Return the cosine of the angle between two vectors using {@link #dot(Vec3d)} + */ + public double cosAngle(final Vec3d o) { + return dot(o) / ( length() * o.length() ) ; + } + + /** + * Return the angle between two vectors in radians using {@link Math#acos(double)} on {@link #cosAngle(Vec3d)}. + */ + public double angle(final Vec3d o) { + return Math.acos( cosAngle(o) ); + } + + /** + * Equals check using a given {@link DoubleUtil#EPSILON} value and {@link DoubleUtil#isEqual(double, double, double)}. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * </ul> + * @param o comparison value + * @param epsilon consider using {@link DoubleUtil#EPSILON} + * @return true if all components differ less than {@code epsilon}, otherwise false. + */ + public boolean isEqual(final Vec3d o, final double epsilon) { + if( this == o ) { + return true; + } else { + return DoubleUtil.isEqual(x, o.x, epsilon) && + DoubleUtil.isEqual(y, o.y, epsilon) && + DoubleUtil.isEqual(z, o.z, epsilon); + } + } + + /** + * Equals check using {@link DoubleUtil#EPSILON} in {@link DoubleUtil#isEqual(double, double)}. + * <p> + * Implementation considers following corner cases: + * <ul> + * <li>NaN == NaN</li> + * <li>+Inf == +Inf</li> + * <li>-Inf == -Inf</li> + * </ul> + * @param o comparison value + * @return true if all components differ less than {@link DoubleUtil#EPSILON}, otherwise false. + */ + public boolean isEqual(final Vec3d o) { + if( this == o ) { + return true; + } else { + return DoubleUtil.isEqual(x, o.x) && + DoubleUtil.isEqual(y, o.y) && + DoubleUtil.isEqual(z, o.z); + } + } + + @Override + public boolean equals(final Object o) { + if( o instanceof Vec3d ) { + return isEqual((Vec3d)o); + } else { + return false; + } + } + + @Override + public String toString() { + return x + " / " + y + " / " + z; + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java b/src/jogl/classes/com/jogamp/math/Vec3f.java index 7012edd74..1ad27463e 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java +++ b/src/jogl/classes/com/jogamp/math/Vec3f.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * 3D Vector based upon three float components. diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java b/src/jogl/classes/com/jogamp/math/Vec4f.java index 914450bf1..45afea7f8 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java +++ b/src/jogl/classes/com/jogamp/math/Vec4f.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; /** * 4D Vector based upon four float components. diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/math/VectorUtil.java index e38501c73..6cea0be0b 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/math/VectorUtil.java @@ -25,11 +25,11 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; import java.util.ArrayList; -import com.jogamp.graph.geom.plane.Winding; +import com.jogamp.math.geom.plane.Winding; public final class VectorUtil { /** diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java b/src/jogl/classes/com/jogamp/math/Vert2fImmutable.java index 66bf078f3..5fc5de7ef 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java +++ b/src/jogl/classes/com/jogamp/math/Vert2fImmutable.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; public interface Vert2fImmutable { float x(); diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vert3fImmutable.java b/src/jogl/classes/com/jogamp/math/Vert3fImmutable.java index 6f63a746c..03e26e840 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vert3fImmutable.java +++ b/src/jogl/classes/com/jogamp/math/Vert3fImmutable.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math; +package com.jogamp.math; public interface Vert3fImmutable extends Vert2fImmutable { float z(); diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/math/geom/AABBox.java index 1720caf0e..926f55aec 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/math/geom/AABBox.java @@ -25,16 +25,15 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math.geom; +package com.jogamp.math.geom; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Ray; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Ray; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.plane.AffineTransform; /** @@ -836,21 +835,6 @@ public class AABBox { } /** - * Transform this box using the {@link PMVMatrix#getMvMat() modelview} of the given {@link PMVMatrix} into {@code out} - * @param pmv transformation {@link PMVMatrix} - * @param out the resulting {@link AABBox} - * @return the resulting {@link AABBox} for chaining - */ - public AABBox transformMv(final PMVMatrix pmv, final AABBox out) { - final Vec3f tmp = new Vec3f(); - out.reset(); - out.resize( pmv.mulMvMatVec3f(low, tmp) ); - out.resize( pmv.mulMvMatVec3f(high, tmp) ); - out.computeCenter(); - return out; - } - - /** * Assume this bounding box as being in object space and * compute the window bounding box. * <p> diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/math/geom/Frustum.java index 73079959b..9e9f65c31 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java +++ b/src/jogl/classes/com/jogamp/math/geom/Frustum.java @@ -25,11 +25,11 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.math.geom; +package com.jogamp.math.geom; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Vec3f; /** * Providing frustum {@link #getPlanes() planes} derived by different inputs diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java b/src/jogl/classes/com/jogamp/math/geom/plane/AffineTransform.java index 66d661990..05d7e201e 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/AffineTransform.java @@ -18,15 +18,15 @@ * @author Denis M. Kishenko * @author Sven Gothel, (c) 2010-2023 */ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; // import jogamp.opengl.util.HashCode; import com.jogamp.graph.geom.Vertex; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; public class AffineTransform implements Cloneable { diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java b/src/jogl/classes/com/jogamp/math/geom/plane/Crossing2F.java index 7eb1d0bf0..09476238f 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/Crossing2F.java @@ -17,9 +17,9 @@ /** * @author Denis M. Kishenko */ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; -import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.math.FloatUtil; /* pp */ class Crossing2F { diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/IllegalPathStateException.java b/src/jogl/classes/com/jogamp/math/geom/plane/IllegalPathStateException.java index be0a14a76..95e47fe5b 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/IllegalPathStateException.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/IllegalPathStateException.java @@ -17,7 +17,7 @@ /** * @author Denis M. Kishenko */ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; public class IllegalPathStateException extends RuntimeException { diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/NoninvertibleTransformException.java b/src/jogl/classes/com/jogamp/math/geom/plane/NoninvertibleTransformException.java index fb90cedfc..f82195944 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/NoninvertibleTransformException.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/NoninvertibleTransformException.java @@ -17,7 +17,7 @@ /** * @author Denis M. Kishenko */ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; public class NoninvertibleTransformException extends java.lang.Exception { diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/Path2F.java b/src/jogl/classes/com/jogamp/math/geom/plane/Path2F.java index 588232d9a..9e0dda286 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/Path2F.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/Path2F.java @@ -18,12 +18,12 @@ * @author Denis M. Kishenko * @author Sven Gothel */ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; import java.io.PrintStream; import java.util.NoSuchElementException; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; /** * Path2F represents and provides construction method for a 2D shape using float[2] points. diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/Winding.java b/src/jogl/classes/com/jogamp/math/geom/plane/Winding.java index bfa214c22..0b3c8dc21 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/Winding.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/Winding.java @@ -1,4 +1,4 @@ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; /** * Winding direction, either clockwise (CW) or counter-clockwise (CCW). diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/WindingRule.java b/src/jogl/classes/com/jogamp/math/geom/plane/WindingRule.java index 46ef167a3..d7881b6db 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/plane/WindingRule.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/WindingRule.java @@ -1,4 +1,4 @@ -package com.jogamp.graph.geom.plane; +package com.jogamp.math.geom.plane; /** * Winding rule, either EVEN_ODD or NON_ZERO (like for TrueType fonts). diff --git a/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java b/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java new file mode 100644 index 000000000..826ca82f6 --- /dev/null +++ b/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java @@ -0,0 +1,1610 @@ +/** + * Copyright 2009-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.math.util; + +import java.nio.Buffer; +import java.nio.FloatBuffer; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Ray; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.Frustum; + +/** + * PMVMatrix4f implements the basic computer graphics {@link Matrix4f} pack using + * projection (P), modelview (Mv) and texture (T) {@link Matrix4f} operations. + * <p> + * Unlike {@link com.jogamp.opengl.util.PMVMatrix PMVMatrix}, this class doesn't implement + * {@link com.jogamp.opengl.fixedfunc.GLMatrixFunc GLMatrixFunc} and is OpenGL agnostic. + * </p> + * <p> + * This is the second implementation of `PMVMatrix4f` using + * direct {@link Matrix4f}, {@link Vec4f} and {@link Vec3f} math operations instead of `float[]` + * via {@link com.jogamp.math.FloatUtil FloatUtil}. + * </p> + * <p> + * PMVMatrix4f provides the {@link #getMvi() inverse modelview matrix (Mvi)} and + * {@link #getMvit() inverse transposed modelview matrix (Mvit)}. + * {@link Frustum} is also provided by {@link #getFrustum()}. + * + * To keep these derived values synchronized after mutable Mv operations like {@link #rotateMv(Quaternion)} + * users have to call {@link #update()} before using Mvi and Mvit. + * </p> + * <p> + * All matrices are provided in column-major order, + * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. + * See {@link Matrix4f}. + * </p> + * <p> + * PMVMatrix4f can supplement {@link com.jogamp.opengl.GL2ES2 GL2ES2} applications w/ the + * lack of the described matrix functionality. + * </p> + * <a name="storageDetails"><h5>Matrix storage details</h5></a> + * <p> + * The {@link SyncBuffer} abstraction is provided, e.g. {@link #getSyncPMvMvi()}, + * to synchronize the respective {@link Matrix4f matrices} with the `float[]` backing store. + * The latter is represents the data to {@link com.jogamp.opengl.GLUniformData} via its {@link FloatBuffer}s, see {@link SyncBuffer#getBuffer()}, + * and is pushed to the GPU eventually. + * </p> + * <p> + * {@link SyncBuffer}'s {@link SyncAction} is called by {@link com.jogamp.opengl.GLUniformData#getBuffer()}, + * i.e. before the data is pushed to the GPU. + * </p> + * <p> + * The provided {@link SyncAction} ensures that the {@link Matrix4f matrices data} + * gets copied into the `float[]` backing store. + * </p> + * <p> + * PMVMatrix4f provides two specializations of {@link SyncBuffer}, {@link SyncMatrix4f} for single {@link Matrix4f} mappings + * and {@link SyncMatrices4f} for multiple {@link Matrix4f} mappings. + * </p> + * <p> + * They can be feed directly to instantiate a {@link com.jogamp.opengl.GLUniformData} object via e.g. {@link com.jogamp.opengl.GLUniformData#GLUniformData(String, int, int, SyncBuffer)}. + * </p> + * <p> + * All {@link Matrix4f matrix} {@link SyncBuffer}'s backing store are backed up by a common primitive float-array for performance considerations + * and are a {@link Buffers#slice2Float(float[], int, int) sliced} representation of it. + * </p> + * <p> + * <b>{@link Matrix4f} {@link SyncBuffer}'s Backing-Store Notes:</b> + * <ul> + * <li>The {@link Matrix4f matrix} {@link SyncBuffer}'s backing store is a {@link Buffers#slice2Float(float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.</li> + * <li>Use {@link FloatBuffer#reset() reset()} to rewind it to it's start position after relative operations, like {@link FloatBuffer#get() get()}.</li> + * <li>If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.</li> + * </ul> + * </p> + */ +public class PMVMatrix4f { + + /** Bit value stating a modified {@link #getP() projection matrix (P)}, since last {@link #update()} call. */ + public static final int MODIFIED_PROJECTION = 1 << 0; + /** Bit value stating a modified {@link #getMv() modelview matrix (Mv)}, since last {@link #update()} call. */ + public static final int MODIFIED_MODELVIEW = 1 << 1; + /** Bit value stating a modified {@link #getT() texture matrix (T)}, since last {@link #update()} call. */ + public static final int MODIFIED_TEXTURE = 1 << 2; + /** Bit value stating all is modified */ + public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE; + /** Bit value for {@link #getMvi() inverse modelview matrix (Mvi)}, updated via {@link #update()}. */ + public static final int INVERSE_MODELVIEW = 1 << 1; + /** Bit value for {@link #getMvit() inverse transposed modelview matrix (Mvit)}, updated via {@link #update()}. */ + public static final int INVERSE_TRANSPOSED_MODELVIEW = 1 << 2; + /** Bit value for {@link #getFrustum() frustum} and updated by {@link #getFrustum()}. */ + public static final int FRUSTUM = 1 << 3; + /** Bit value for {@link #getPMv() pre-multiplied P * Mv}, updated by {@link #getPMv()}. */ + public static final int PREMUL_PMV = 1 << 4; + /** Bit value for {@link #getPMvi() pre-multiplied invert(P * Mv)}, updated by {@link #getPMvi()}. */ + public static final int PREMUL_PMVI = 1 << 5; + /** Manual bits not covered by {@link #update()} but {@link #getFrustum()}, {@link #FRUSTUM}, {@link #getPMv()}, {@link #PREMUL_PMV}, {@link #getPMvi()}, {@link #PREMUL_PMVI}, etc. */ + public static final int MANUAL_BITS = FRUSTUM | PREMUL_PMV | PREMUL_PMVI; + + /** + * Creates an instance of PMVMatrix4f. + * <p> + * This constructor only sets up an instance w/o additional {@link #INVERSE_MODELVIEW} or {@link #INVERSE_TRANSPOSED_MODELVIEW}. + * </p> + * <p> + * Implementation uses non-direct non-NIO Buffers with guaranteed backing array, + * which are synchronized to the actual Matrix4f instances. + * This allows faster access in Java computation. + * </p> + * @see #PMVMatrix4f(int) + */ + public PMVMatrix4f() { + this(0); + } + + /** + * Creates an instance of PMVMatrix4f. + * <p> + * Additional derived matrices can be requested via `derivedMatrices`, i.e. + * - {@link #INVERSE_MODELVIEW} + * - {@link #INVERSE_TRANSPOSED_MODELVIEW} + * </p> + * <p> + * Implementation uses non-direct non-NIO Buffers with guaranteed backing array, + * which are synchronized to the actual Matrix4f instances. + * This allows faster access in Java computation. + * </p> + * @param derivedMatrices additional matrices can be requested by passing bits {@link #INVERSE_MODELVIEW} and {@link #INVERSE_TRANSPOSED_MODELVIEW}. + * @see #getReqBits() + * @see #isReqDirty() + * @see #getDirtyBits() + * @see #update() + */ + public PMVMatrix4f(final int derivedMatrices) { + // I Identity + // T Texture + // P Projection + // Mv ModelView + // Mvi Modelview-Inverse + // Mvit Modelview-Inverse-Transpose + { + int mask = 0; + if( 0 != ( derivedMatrices & ( INVERSE_MODELVIEW | INVERSE_TRANSPOSED_MODELVIEW ) ) ) { + mask |= INVERSE_MODELVIEW; + } + if( 0 != ( derivedMatrices & INVERSE_TRANSPOSED_MODELVIEW ) ) { + mask |= INVERSE_TRANSPOSED_MODELVIEW; + } + requestBits = mask; + } + + // actual underlying Matrix4f count + int mcount = 3; + + // actual underlying Matrix4f data + matP = new Matrix4f(); + matMv = new Matrix4f(); + matTex = new Matrix4f(); + + if( 0 != ( requestBits & INVERSE_MODELVIEW ) ) { + matMvi = new Matrix4f(); + mMvi_offset = 2*16; + ++mcount; + } else { + matMvi = null; + mMvi_offset = -1; + } + if( 0 != ( requestBits & INVERSE_TRANSPOSED_MODELVIEW ) ) { + matMvit = new Matrix4f(); + mMvit_offset = 3*16; + ++mcount; + } else { + matMvit = null; + mMvit_offset = -1; + } + mTex_offset = (mcount-1)*16; // last one + + // float back buffer for GPU, Matrix4f -> matrixStore via SyncedBuffer + matrixStore = new float[mcount*16]; + + // FloatBuffer for single Matrix4f back-buffer + final FloatBuffer bufP = Buffers.slice2Float(matrixStore, mP_offset, 1*16); // P + syncP = new SyncBuffer0(matP, bufP); // mP_offset + + final FloatBuffer bufMv = Buffers.slice2Float(matrixStore, mMv_offset, 1*16); // Mv + syncMv = new SyncBuffer1(matMv, bufMv, mMv_offset); + + final FloatBuffer bufP_Mv = Buffers.slice2Float(matrixStore, mP_offset, 2*16); // P + Mv + syncP_Mv = new SyncBufferN(new Matrix4f[] { matP, matMv }, bufP_Mv, mP_offset); + + final FloatBuffer bufTex = Buffers.slice2Float(matrixStore, mTex_offset, 1*16); // T + syncT = new SyncBuffer1(matTex, bufTex, mTex_offset); + + if( null != matMvi ) { + final FloatBuffer bufMvi = Buffers.slice2Float(matrixStore, mMvi_offset, 1*16); // Mvi + final FloatBuffer bufP_Mv_Mvi = Buffers.slice2Float(matrixStore, mP_offset, 3*16); // P + Mv + Mvi + syncMvi = new SyncBuffer1U(matMvi, bufMvi, mMvi_offset); + syncP_Mv_Mvi = new SyncBufferNU(new Matrix4f[] { matP, matMv, matMvi }, bufP_Mv_Mvi, mP_offset); + } else { + syncMvi = null; + syncP_Mv_Mvi = null; + } + if( null != matMvit ) { + final FloatBuffer bufMvit = Buffers.slice2Float(matrixStore, mMvit_offset, 1*16); // Mvit + final FloatBuffer bufP_Mv_Mvi_Mvit = Buffers.slice2Float(matrixStore, mP_offset, 4*16); // P + Mv + Mvi + Mvit + syncMvit = new SyncBuffer1U(matMvit, bufMvit, mMvit_offset); + syncP_Mv_Mvi_Mvit = new SyncBufferNU(new Matrix4f[] { matP, matMv, matMvi, matMvit }, bufP_Mv_Mvi_Mvit, mP_offset); + } else { + syncMvit = null; + syncP_Mv_Mvi_Mvit = null; + } + + mat4Tmp1 = new Matrix4f(); + + mat4Tmp2 = null; // on demand + matPMv = null; // on demand + matPMvi = null; // on demand + matPMviOK = false; + frustum = null; // on demand + + reset(); + } + + /** + * Issues {@link Matrix4f#loadIdentity()} on all matrices and resets all internal states. + */ + public void reset() { + matP.loadIdentity(); + matMv.loadIdentity(); + matTex.loadIdentity(); + + modifiedBits = MODIFIED_ALL; + dirtyBits = requestBits | MANUAL_BITS; + } + + // + // Temporary storage access for efficiency + // + + + /** + * Return the second temporary Matrix4f exposed to be reused for efficiency. + * <p> + * Temporary storage is only used by this class within single method calls, + * hence has no side-effects. + * </p> + */ + protected final Matrix4f getTmp2Mat() { + if( null == mat4Tmp2 ) { + mat4Tmp2 = new Matrix4f(); + } + return mat4Tmp2; + } + + // + // Regular Matrix4f access as well as their SyncedBuffer counterpart SyncedMatrix and SyncedMatrices + // + + /** + * Returns the {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). + * <p> + * Consider using {@link #setTextureDirty()} if modifying the returned {@link Matrix4f}. + * </p> + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final Matrix4f getT() { + return matTex; + } + + /** + * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final SyncMatrix4f getSyncT() { + return syncT; + } + + /** + * Returns the {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). + * <p> + * Consider using {@link #setProjectionDirty()} if modifying the returned {@link Matrix4f}. + * </p> + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final Matrix4f getP() { + return matP; + } + + /** + * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final SyncMatrix4f getSyncP() { + return syncP; + } + + /** + * Returns the {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). + * <p> + * Consider using {@link #setModelviewDirty()} if modifying the returned {@link Matrix4f}. + * </p> + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final Matrix4f getMv() { + return matMv; + } + + /** + * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final SyncMatrix4f getSyncMv() { + return syncMv; + } + + /** + * Returns {@link SyncMatrices4f} of 2 matrices within one FloatBuffer: {@link #getP() P} and {@link #getMv() Mv}. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + */ + public final SyncMatrices4f getSyncPMv() { + return syncP_Mv; + } + + /** + * Returns the inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi) if requested. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + * @throws IllegalArgumentException if {@link #INVERSE_MODELVIEW} has not been requested in ctor {@link #PMVMatrix4f(int)}. + */ + public final Matrix4f getMvi() { + if( 0 == ( INVERSE_MODELVIEW & requestBits ) ) { + throw new IllegalArgumentException("Not requested in ctor"); + } + updateImpl(false); + return matMvi; + } + + /** + * Returns the {@link SyncMatrix} of inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi) if requested. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + * @throws IllegalArgumentException if {@link #INVERSE_MODELVIEW} has not been requested in ctor {@link #PMVMatrix4f(int)}. + */ + public final SyncMatrix4f getSyncMvi() { + if( 0 == ( INVERSE_MODELVIEW & requestBits ) ) { + throw new IllegalArgumentException("Not requested in ctor"); + } + return syncMvi; + } + + /** + * Returns the inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit) if requested. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + * @throws IllegalArgumentException if {@link #INVERSE_TRANSPOSED_MODELVIEW} has not been requested in ctor {@link #PMVMatrix4f(int)}. + */ + public final Matrix4f getMvit() { + if( 0 == ( INVERSE_TRANSPOSED_MODELVIEW & requestBits ) ) { + throw new IllegalArgumentException("Not requested in ctor"); + } + updateImpl(false); + return matMvit; + } + + /** + * Returns the {@link SyncMatrix} of inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit) if requested. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + * @throws IllegalArgumentException if {@link #INVERSE_TRANSPOSED_MODELVIEW} has not been requested in ctor {@link #PMVMatrix4f(int)}. + */ + public final SyncMatrix4f getSyncMvit() { + if( 0 == ( INVERSE_TRANSPOSED_MODELVIEW & requestBits ) ) { + throw new IllegalArgumentException("Not requested in ctor"); + } + return syncMvit; + } + + /** + * Returns {@link SyncMatrices4f} of 3 matrices within one FloatBuffer: {@link #getP() P}, {@link #getMv() Mv} and {@link #getMvi() Mvi} if requested. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + * @throws IllegalArgumentException if {@link #INVERSE_MODELVIEW} has not been requested in ctor {@link #PMVMatrix4f(int)}. + */ + public final SyncMatrices4f getSyncPMvMvi() { + if( 0 == ( INVERSE_MODELVIEW & requestBits ) ) { + throw new IllegalArgumentException("Not requested in ctor"); + } + return syncP_Mv_Mvi; + } + + /** + * Returns {@link SyncMatrices4f} of 4 matrices within one FloatBuffer: {@link #getP() P}, {@link #getMv() Mv}, {@link #getMvi() Mvi} and {@link #getMvit() Mvit} if requested. + * <p> + * See <a href="#storageDetails"> matrix storage details</a>. + * </p> + * @throws IllegalArgumentException if {@link #INVERSE_TRANSPOSED_MODELVIEW} has not been requested in ctor {@link #PMVMatrix4f(int)}. + */ + public final SyncMatrices4f getSyncPMvMviMvit() { + if( 0 == ( INVERSE_TRANSPOSED_MODELVIEW & requestBits ) ) { + throw new IllegalArgumentException("Not requested in ctor"); + } + return syncP_Mv_Mvi_Mvit; + } + + // + // Basic Matrix4f, Vec3f and Vec4f operations similar to GLMatrixFunc + // + + /** + * Returns multiplication result of {@link #getP() P} and {@link #getMv() Mv} matrix, i.e. + * <pre> + * result = P x Mv + * </pre> + * @param result 4x4 matrix storage for result + * @return given result matrix for chaining + */ + public final Matrix4f getMulPMv(final Matrix4f result) { + return result.mul(matP, matMv); + } + + /** + * Returns multiplication result of {@link #getMv() Mv} and {@link #getP() P} matrix, i.e. + * <pre> + * result = Mv x P + * </pre> + * @param result 4x4 matrix storage for result + * @return given result matrix for chaining + */ + public final Matrix4f getMulMvP(final Matrix4f result) { + return result.mul(matMv, matP); + } + + /** + * v_out = Mv * v_in + * @param v_in input vector, can be v_out for in-place transformation + * @param v_out output vector + * @returns v_out for chaining + */ + public final Vec4f mulWithMv(final Vec4f v_in, final Vec4f v_out) { + return matMv.mulVec4f(v_in, v_out); + } + + /** + * v_inout = Mv * v_inout + * @param v_inout input and output vector, i.e. in-place transformation + * @returns v_inout for chaining + */ + public final Vec4f mulWithMv(final Vec4f v_inout) { + return matMv.mulVec4f(v_inout); + } + + /** + * v_out = Mv * v_in + * + * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. + * + * @param v_in input vector, can be v_out for in-place transformation + * @param v_out output vector + * @returns v_out for chaining + */ + public final Vec3f mulWithMv(final Vec3f v_in, final Vec3f v_out) { + return matMv.mulVec3f(v_in, v_out); + } + + /** + * v_inout = Mv * v_inout + * + * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. + * + * @param v_inout input and output vector, i.e. in-place transformation + * @returns v_inout for chaining + */ + public final Vec3f mulWithMv(final Vec3f v_inout) { + return matMv.mulVec3f(v_inout); + } + + /** + * v_out = P * v_in + * @param v_in input vector, can be v_out for in-place transformation + * @param v_out output vector + * @return given result vector for chaining + * @returns v_out for chaining + */ + public final Vec4f mulWithP(final Vec4f v_in, final Vec4f v_out) { + return matP.mulVec4f(v_in, v_out); + } + + /** + * v_inout = P * v_inout + * @param v_inout input and output vector, i.e. in-place transformation + * @return given result vector for chaining + * @returns v_inout for chaining + */ + public final Vec4f mulWithP(final Vec4f v_inout) { + return matP.mulVec4f(v_inout); + } + + /** + * v_out = P * v_in + * + * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. + * + * @param v_in float[3] input vector, can be v_out for in-place transformation + * @param v_out float[3] output vector + * @returns v_out for chaining + */ + public final Vec3f mulWithP(final Vec3f v_in, final Vec3f v_out) { + return matP.mulVec3f(v_in, v_out); + } + + /** + * v_inout = P * v_inout + * + * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. + * + * @param v_inout input and output vector, i.e. in-place transformation + * @returns v_inout for chaining + */ + public final Vec3f mulWithP(final Vec3f v_inout) { + return matP.mulVec3f(v_inout); + } + + /** + * v_out = P * Mv * v_in + * @param v_in float[4] input vector, can be v_out for in-place transformation + * @param v_out float[4] output vector + * @returns v_out for chaining + */ + public final Vec4f mulWithPMv(final Vec4f v_in, final Vec4f v_out) { + return matP.mulVec4f( matMv.mulVec4f( v_in, v_out ) ); + } + + /** + * v_inout = P * Mv * v_inout + * @param v_inout input and output vector, i.e. in-place transformation + * @returns v_inout for chaining + */ + public final Vec4f mulWithPMv(final Vec4f v_inout) { + return matP.mulVec4f( matMv.mulVec4f( v_inout ) ); + } + + /** + * v_out = P * Mv * v_in + * + * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. + * + * @param v_in float[3] input vector, can be v_out for in-place transformation + * @param v_out float[3] output vector + * @returns v_out for chaining + */ + public final Vec3f mulWithPMv(final Vec3f v_in, final Vec3f v_out) { + return matP.mulVec3f( matMv.mulVec3f( v_in, v_out ) ); + } + + /** + * v_inout = P * Mv * v_inout + * + * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. + * + * @param v_inout float[3] input and output vector, i.e. in-place transformation + * @returns v_inout for chaining + */ + public final Vec3f mulWithPMv(final Vec3f v_inout) { + return matP.mulVec3f( matMv.mulVec3f( v_inout ) ); + } + + // + // GLMatrixFunc alike functionality + // + + /** + * Load the {@link #getMv() modelview matrix} with the provided values. + */ + public final PMVMatrix4f loadMv(final float[] values, final int offset) { + matMv.load(values, offset); + setModelviewDirty(); + return this; + } + /** + * Load the {@link #getMv() modelview matrix} with the provided values. + */ + public final PMVMatrix4f loadMv(final java.nio.FloatBuffer m) { + final int spos = m.position(); + matMv.load(m); + setModelviewDirty(); + m.position(spos); + return this; + } + /** + * Load the {@link #getMv() modelview matrix} with the values of the given {@link Matrix4f}. + */ + public final PMVMatrix4f loadMv(final Matrix4f m) { + matMv.load(m); + setModelviewDirty(); + return this; + } + /** + * Load the {@link #getMv() modelview matrix} with the values of the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}. + */ + public final PMVMatrix4f loadMv(final Quaternion quat) { + matMv.setToRotation(quat); + setModelviewDirty(); + return this; + } + + /** + * Load the {@link #getP() projection matrix} with the provided values. + */ + public final PMVMatrix4f loadP(final float[] values, final int offset) { + matP.load(values, offset); + setProjectionDirty(); + return this; + } + /** + * Load the {@link #getP() projection matrix} with the provided values. + */ + public final PMVMatrix4f loadP(final java.nio.FloatBuffer m) { + final int spos = m.position(); + matP.load(m); + setProjectionDirty(); + m.position(spos); + return this; + } + /** + * Load the {@link #getP() projection matrix} with the values of the given {@link Matrix4f}. + */ + public final PMVMatrix4f loadP(final Matrix4f m) { + matP.load(m); + setProjectionDirty(); + return this; + } + /** + * Load the {@link #getP() projection matrix} with the values of the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}. + */ + public final PMVMatrix4f loadP(final Quaternion quat) { + matP.setToRotation(quat); + setProjectionDirty(); + return this; + } + + /** + * Load the {@link #getT() texture matrix} with the provided values. + */ + public final PMVMatrix4f loadT(final float[] values, final int offset) { + matTex.load(values, offset); + setTextureDirty(); + return this; + } + /** + * Load the {@link #getT() texture matrix} with the provided values. + */ + public final PMVMatrix4f loadT(final java.nio.FloatBuffer m) { + final int spos = m.position(); + matTex.load(m); + setTextureDirty(); + m.position(spos); + return this; + } + /** + * Load the {@link #getT() texture matrix} with the values of the given {@link Matrix4f}. + */ + public final PMVMatrix4f loadT(final Matrix4f m) { + matTex.load(m); + setTextureDirty(); + return this; + } + /** + * Load the {@link #getT() texture matrix} with the values of the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}. + */ + public final PMVMatrix4f loadT(final Quaternion quat) { + matTex.setToRotation(quat); + setTextureDirty(); + return this; + } + + /** + * Load the {@link #getMv() modelview matrix} with the values of the given {@link Matrix4f}. + */ + public final PMVMatrix4f loadMvIdentity() { + matMv.loadIdentity(); + setModelviewDirty(); + return this; + } + + /** + * Load the {@link #getP() projection matrix} with the values of the given {@link Matrix4f}. + */ + public final PMVMatrix4f loadPIdentity() { + matP.loadIdentity(); + setProjectionDirty(); + return this; + } + + /** + * Load the {@link #getT() texture matrix} with the values of the given {@link Matrix4f}. + */ + public final PMVMatrix4f loadTIdentity() { + matTex.loadIdentity(); + setTextureDirty(); + return this; + } + + /** + * Multiply the {@link #getMv() modelview matrix}: [c] = [c] x [m] + * @param m the right hand Matrix4f + * @return this instance of chaining + */ + public final PMVMatrix4f mulMv(final Matrix4f m) { + matMv.mul( m ); + setModelviewDirty(); + return this; + } + + /** + * Multiply the {@link #getP() projection matrix}: [c] = [c] x [m] + * @param m the right hand Matrix4f + * @return this instance of chaining + */ + public final PMVMatrix4f mulP(final Matrix4f m) { + matP.mul( m ); + setProjectionDirty(); + return this; + } + + /** + * Multiply the {@link #getT() texture matrix}: [c] = [c] x [m] + * @param m the right hand Matrix4f + * @return this instance of chaining + */ + public final PMVMatrix4f mulT(final Matrix4f m) { + matTex.mul( m ); + setTextureDirty(); + return this; + } + + /** + * Translate the {@link #getMv() modelview matrix}. + * @param x + * @param y + * @param z + * @return this instance of chaining + */ + public final PMVMatrix4f translateMv(final float x, final float y, final float z) { + return mulMv( mat4Tmp1.setToTranslation(x, y, z) ); + } + /** + * Translate the {@link #getMv() modelview matrix}. + * @param t translation vec3 + * @return this instance of chaining + */ + public final PMVMatrix4f translateMv(final Vec3f t) { + return mulMv( mat4Tmp1.setToTranslation(t) ); + } + + /** + * Translate the {@link #getP() projection matrix}. + * @param x + * @param y + * @param z + * @return this instance of chaining + */ + public final PMVMatrix4f translateP(final float x, final float y, final float z) { + return mulP( mat4Tmp1.setToTranslation(x, y, z) ); + } + /** + * Translate the {@link #getP() projection matrix}. + * @param t translation vec3 + * @return this instance of chaining + */ + public final PMVMatrix4f translateP(final Vec3f t) { + return mulP( mat4Tmp1.setToTranslation(t) ); + } + + /** + * Scale the {@link #getMv() modelview matrix}. + * @param x + * @param y + * @param z + * @return this instance of chaining + */ + public final PMVMatrix4f scaleMv(final float x, final float y, final float z) { + return mulMv( mat4Tmp1.setToScale(x, y, z) ); + } + /** + * Scale the {@link #getMv() modelview matrix}. + * @param s scale vec4f + * @return this instance of chaining + */ + public final PMVMatrix4f scaleMv(final Vec3f s) { + return mulMv( mat4Tmp1.setToScale(s) ); + } + + /** + * Scale the {@link #getP() projection matrix}. + * @param x + * @param y + * @param z + * @return this instance of chaining + */ + public final PMVMatrix4f scaleP(final float x, final float y, final float z) { + return mulP( mat4Tmp1.setToScale(x, y, z) ); + } + /** + * Scale the {@link #getP() projection matrix}. + * @param s scale vec4f + * @return this instance of chaining + */ + public final PMVMatrix4f scaleP(final Vec3f s) { + return mulP( mat4Tmp1.setToScale(s) ); + } + + /** + * Rotate the {@link #getMv() modelview matrix} by the given axis and angle in radians. + * <p> + * Consider using {@link #rotateMv(Quaternion)} + * </p> + * @param ang_rad angle in radians + * @param axis rotation axis + * @return this instance of chaining + * @see #rotateMv(Quaternion) + */ + public final PMVMatrix4f rotateMv(final float ang_rad, final float x, final float y, final float z) { + return mulMv( mat4Tmp1.setToRotationAxis(ang_rad, x, y, z) ); + } + /** + * Rotate the {@link #getMv() modelview matrix} by the given axis and angle in radians. + * <p> + * Consider using {@link #rotateMv(Quaternion)} + * </p> + * @param ang_rad angle in radians + * @param axis rotation axis + * @return this instance of chaining + * @see #rotateMv(Quaternion) + */ + public final PMVMatrix4f rotateMv(final float ang_rad, final Vec3f axis) { + return mulMv( mat4Tmp1.setToRotationAxis(ang_rad, axis) ); + } + /** + * Rotate the {@link #getMv() modelview matrix} with the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}. + * @param quat the {@link Quaternion} + * @return this instance of chaining + */ + public final PMVMatrix4f rotateMv(final Quaternion quat) { + return mulMv( mat4Tmp1.setToRotation(quat) ); + } + + /** + * Rotate the {@link #getP() projection matrix} by the given axis and angle in radians. + * <p> + * Consider using {@link #rotateP(Quaternion)} + * </p> + * @param ang_rad angle in radians + * @param axis rotation axis + * @return this instance of chaining + * @see #rotateP(Quaternion) + */ + public final PMVMatrix4f rotateP(final float ang_rad, final float x, final float y, final float z) { + return mulP( mat4Tmp1.setToRotationAxis(ang_rad, x, y, z) ); + } + /** + * Rotate the {@link #getP() projection matrix} by the given axis and angle in radians. + * <p> + * Consider using {@link #rotateP(Quaternion)} + * </p> + * @param ang_rad angle in radians + * @param axis rotation axis + * @return this instance of chaining + * @see #rotateP(Quaternion) + */ + public final PMVMatrix4f rotateP(final float ang_rad, final Vec3f axis) { + return mulP( mat4Tmp1.setToRotationAxis(ang_rad, axis) ); + } + /** + * Rotate the {@link #getP() projection matrix} with the given {@link Quaternion}'s rotation {@link Matrix4f#setToRotation(Quaternion) matrix representation}. + * @param quat the {@link Quaternion} + * @return this instance of chaining + */ + public final PMVMatrix4f rotateP(final Quaternion quat) { + return mulP( mat4Tmp1.setToRotation(quat) ); + } + + /** Pop the {@link #getMv() modelview matrix} from its stack. */ + public final PMVMatrix4f popMv() { + matMv.pop(); + setModelviewDirty(); + return this; + } + /** Pop the {@link #getP() projection matrix} from its stack. */ + public final PMVMatrix4f popP() { + matP.pop(); + setProjectionDirty(); + return this; + } + /** Pop the {@link #getT() texture matrix} from its stack. */ + public final PMVMatrix4f popT() { + matTex.pop(); + setTextureDirty(); + return this; + } + /** Push the {@link #getMv() modelview matrix} to its stack, while preserving its values. */ + public final PMVMatrix4f pushMv() { + matMv.push(); + return this; + } + /** Push the {@link #getP() projection matrix} to its stack, while preserving its values. */ + public final PMVMatrix4f pushP() { + matP.push(); + return this; + } + /** Push the {@link #getT() texture matrix} to its stack, while preserving its values. */ + public final PMVMatrix4f pushT() { + matTex.push(); + return this; + } + + /** + * {@link #mulP(Matrix4f) Multiply} the {@link #getP() projection matrix} with the orthogonal matrix. + * @param left + * @param right + * @param bottom + * @param top + * @param zNear + * @param zFar + * @see Matrix4f#setToOrtho(float, float, float, float, float, float) + */ + public final void orthoP(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { + mulP( mat4Tmp1.setToOrtho(left, right, bottom, top, zNear, zFar) ); + } + + /** + * {@link #mulP(Matrix4f) Multiply} the {@link #getP() projection matrix} with the frustum matrix. + * + * @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear} + * or {@code left == right}, or {@code bottom == top}. + * @see Matrix4f#setToFrustum(float, float, float, float, float, float) + */ + public final void frustumP(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) throws IllegalArgumentException { + mulP( mat4Tmp1.setToFrustum(left, right, bottom, top, zNear, zFar) ); + } + + // + // Extra functionality + // + + /** + * {@link #mulP(Matrix4f) Multiply} the {@link #getP() projection matrix} with the perspective/frustum matrix. + * + * @param fovy_rad fov angle in radians + * @param aspect aspect ratio width / height + * @param zNear + * @param zFar + * @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear} + * @see Matrix4f#setToPerspective(float, float, float, float) + */ + public final PMVMatrix4f perspectiveP(final float fovy_rad, final float aspect, final float zNear, final float zFar) throws IllegalArgumentException { + mulP( mat4Tmp1.setToPerspective(fovy_rad, aspect, zNear, zFar) ); + return this; + } + + /** + * {@link #mulP(Matrix4f) Multiply} the {@link #getP() projection matrix} + * with the eye, object and orientation, i.e. {@link Matrix4f#setToLookAt(Vec3f, Vec3f, Vec3f, Matrix4f)}. + */ + public final PMVMatrix4f lookAtP(final Vec3f eye, final Vec3f center, final Vec3f up) { + mulP( mat4Tmp1.setToLookAt(eye, center, up, getTmp2Mat()) ); + return this; + } + + /** + * Map object coordinates to window coordinates. + * <p> + * Traditional <code>gluProject</code> implementation. + * </p> + * + * @param objPos 3 component object coordinate + * @param viewport Rect4i viewport + * @param winPos 3 component window coordinate, the result + * @return true if successful, otherwise false (z is 1) + */ + public final boolean mapObjToWin(final Vec3f objPos, final Recti viewport, final Vec3f winPos) { + return Matrix4f.mapObjToWin(objPos, matMv, matP, viewport, winPos); + } + + /** + * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject</code> implementation. + * </p> + * + * @param winx + * @param winy + * @param winz + * @param viewport Rect4i viewport + * @param objPos 3 component object coordinate, the result + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public final boolean mapWinToObj(final float winx, final float winy, final float winz, + final Recti viewport, final Vec3f objPos) { + if( Matrix4f.mapWinToObj(winx, winy, winz, getPMvi(), viewport, objPos) ) { + return true; + } else { + return false; + } + } + + /** + * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject4</code> implementation. + * </p> + * + * @param winx + * @param winy + * @param winz + * @param clipw + * @param viewport Rect4i viewport + * @param near + * @param far + * @param objPos 4 component object coordinate, the result + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public boolean mapWinToObj4(final float winx, final float winy, final float winz, final float clipw, + final Recti viewport, final float near, final float far, final Vec4f objPos) { + if( Matrix4f.mapWinToObj4(winx, winy, winz, clipw, getPMvi(), viewport, near, far, objPos) ) { + return true; + } else { + return false; + } + } + + /** + * Map two window coordinates w/ shared X/Y and distinctive Z + * to a {@link Ray}. The resulting {@link Ray} maybe used for <i>picking</i> + * using a {@link AABBox#getRayIntersection(Vec3f, Ray, float, boolean) bounding box}. + * <p> + * Notes for picking <i>winz0</i> and <i>winz1</i>: + * <ul> + * <li>see {@link FloatUtil#getZBufferEpsilon(int, float, float)}</li> + * <li>see {@link FloatUtil#getZBufferValue(int, float, float, float)}</li> + * <li>see {@link FloatUtil#getOrthoWinZ(float, float, float)}</li> + * </ul> + * </p> + * @param winx + * @param winy + * @param winz0 + * @param winz1 + * @param viewport + * @param ray storage for the resulting {@link Ray} + * @return true if successful, otherwise false (failed to invert matrix, or becomes z is infinity) + */ + public final boolean mapWinToRay(final float winx, final float winy, final float winz0, final float winz1, + final Recti viewport, final Ray ray) { + return Matrix4f.mapWinToRay(winx, winy, winz0, winz1, getPMvi(), viewport, ray); + } + + public StringBuilder toString(StringBuilder sb, final String f) { + if(null == sb) { + sb = new StringBuilder(); + } + final boolean pmvDirty = 0 != (PREMUL_PMV & dirtyBits); + final boolean pmvUsed = null != matPMv; + + final boolean pmviDirty = 0 != (PREMUL_PMVI & dirtyBits); + final boolean pmviUsed = null != matPMvi; + + final boolean frustumDirty = 0 != (FRUSTUM & dirtyBits); + final boolean frustumUsed = null != frustum; + + final boolean mviDirty = 0 != (INVERSE_MODELVIEW & dirtyBits); + final boolean mviReq = 0 != (INVERSE_MODELVIEW & requestBits); + + final boolean mvitDirty = 0 != (INVERSE_TRANSPOSED_MODELVIEW & dirtyBits); + final boolean mvitReq = 0 != (INVERSE_TRANSPOSED_MODELVIEW & requestBits); + + final boolean modP = 0 != ( MODIFIED_PROJECTION & modifiedBits ); + final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); + final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); + int count = 3; // P, Mv, T + + sb.append("PMVMatrix4f[modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); + sb.append("], dirty/used[PMv ").append(pmvDirty).append("/").append(pmvUsed).append(", Pmvi ").append(pmviDirty).append("/").append(pmviUsed).append(", Frustum ").append(frustumDirty).append("/").append(frustumUsed); + sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append("]").append(System.lineSeparator()); + sb.append(", Projection").append(System.lineSeparator()); + matP.toString(sb, null, f); + sb.append(", Modelview").append(System.lineSeparator()); + matMv.toString(sb, null, f); + sb.append(", Texture").append(System.lineSeparator()); + matTex.toString(sb, null, f); + if( null != matPMv ) { + sb.append(", P * Mv").append(System.lineSeparator()); + matPMv.toString(sb, null, f); + ++count; + } + if( null != matPMvi ) { + sb.append(", P * Mv").append(System.lineSeparator()); + matPMvi.toString(sb, null, f); + ++count; + } + if( mviReq ) { + sb.append(", Inverse Modelview").append(System.lineSeparator()); + matMvi.toString(sb, null, f); + ++count; + } + if( mvitReq ) { + sb.append(", Inverse Transposed Modelview").append(System.lineSeparator()); + matMvit.toString(sb, null, f); + ++count; + } + int tmpCount = 1; + if( null != mat4Tmp2 ) { + ++tmpCount; + } + sb.append(", matrices "+count+" + "+tmpCount+" temp = "+(count+tmpCount)+"]"); + return sb; + } + + @Override + public String toString() { + return toString(null, "%10.5f").toString(); + } + + /** + * Returns the modified bits due to mutable operations.. + * <p> + * A modified bit is set, if the corresponding matrix had been modified by a mutable operation + * since last {@link #update()} or {@link #getModifiedBits(boolean) getModifiedBits(true)} call. + * </p> + * @param clear if true, clears the modified bits, otherwise leaves them untouched. + * + * @see #MODIFIED_PROJECTION + * @see #MODIFIED_MODELVIEW + * @see #MODIFIED_TEXTURE + * @see #getDirtyBits() + * @see #isReqDirty() + */ + public final int getModifiedBits(final boolean clear) { + final int r = modifiedBits; + if(clear) { + modifiedBits = 0; + } + return r; + } + + /** + * Returns the dirty bits due to mutable operations, + * i.e. + * - {@link #INVERSE_MODELVIEW} (if requested) + * - {@link #INVERSE_TRANSPOSED_MODELVIEW} (if requested) + * - {@link #FRUSTUM} (always, cleared via {@link #getFrustum()} + * <p> + * A dirty bit is set, if the corresponding matrix had been modified by a mutable operation + * since last {@link #update()} call and requested in the constructor {@link #PMVMatrix4f(int)}. + * </p> + * <p> + * {@link #update()} clears the dirty state for the matrices and {@link #getFrustum()} for {@link #FRUSTUM}. + * </p> + * + * @see #isReqDirty() + * @see #INVERSE_MODELVIEW + * @see #INVERSE_TRANSPOSED_MODELVIEW + * @see #FRUSTUM + * @see #PMVMatrix4f(int) + * @see #getMvi() + * @see #getMvit() + * @see #getSyncPMvMvi() + * @see #getSyncPMvMviMvit() + * @see #getFrustum() + */ + public final int getDirtyBits() { + return dirtyBits; + } + + /** + * Returns true if the one of the {@link #getReqBits() requested bits} are are set dirty due to mutable operations, + * i.e. at least one of + * - {@link #INVERSE_MODELVIEW} + * - {@link #INVERSE_TRANSPOSED_MODELVIEW} + * <p> + * A dirty bit is set, if the corresponding matrix had been modified by a mutable operation + * since last {@link #update()} call and requested in the constructor {@link #PMVMatrix4f(int)}. + * </p> + * <p> + * {@link #update()} clears the dirty state for the matrices and {@link #getFrustum()} for {@link #FRUSTUM}. + * </p> + * + * @see #INVERSE_MODELVIEW + * @see #INVERSE_TRANSPOSED_MODELVIEW + * @see #PMVMatrix4f(int) + * @see #getMvi() + * @see #getMvit() + * @see #getSyncPMvMvi() + * @see #getSyncPMvMviMvit() + */ + public final boolean isReqDirty() { + return 0 != ( requestBits & dirtyBits ); + } + + /** + * Sets the {@link #getMv() Modelview (Mv)} matrix dirty and modified, + * i.e. adds {@link #getReqBits() requested bits} and {@link #MANUAL_BITS} to {@link #getDirtyBits() dirty bits}. + * @see #isReqDirty() + */ + public final void setModelviewDirty() { + dirtyBits |= requestBits | MANUAL_BITS ; + modifiedBits |= MODIFIED_MODELVIEW; + } + + /** + * Sets the {@link #getP() Projection (P)} matrix dirty and modified, + * i.e. adds {@link #MANUAL_BITS} to {@link #getDirtyBits() dirty bits}. + */ + public final void setProjectionDirty() { + dirtyBits |= MANUAL_BITS ; + modifiedBits |= MODIFIED_PROJECTION; + } + + /** + * Sets the {@link #getT() Texture (T)} matrix modified. + */ + public final void setTextureDirty() { + modifiedBits |= MODIFIED_TEXTURE; + } + + /** + * Returns the request bit mask, which uses bit values equal to the dirty mask + * and may contain + * - {@link #INVERSE_MODELVIEW} + * - {@link #INVERSE_TRANSPOSED_MODELVIEW} + * <p> + * The request bit mask is set by in the constructor {@link #PMVMatrix4f(int)}. + * </p> + * + * @see #INVERSE_MODELVIEW + * @see #INVERSE_TRANSPOSED_MODELVIEW + * @see #PMVMatrix4f(int) + * @see #getMvi() + * @see #getMvit() + * @see #getSyncPMvMvi() + * @see #getSyncPMvMviMvit() + * @see #getFrustum() + */ + public final int getReqBits() { + return requestBits; + } + + /** + * Returns the pre-multiplied projection x modelview, P x Mv. + * <p> + * This {@link Matrix4f} instance should be re-fetched via this method and not locally stored + * to have it updated from a potential modification of underlying projection and/or modelview matrix. + * {@link #update()} has no effect on this {@link Matrix4f}. + * </p> + * <p> + * This pre-multipled P x Mv is considered dirty, if its corresponding + * {@link #getP() P matrix} or {@link #getMv() Mv matrix} has been modified since its last update. + * </p> + * @see #update() + */ + public final Matrix4f getPMv() { + if( 0 != ( dirtyBits & PREMUL_PMV ) ) { + if( null == matPMv ) { + matPMv = new Matrix4f(); + } + matPMv.mul(matP, matMv); + dirtyBits &= ~PREMUL_PMV; + } + return matPMv; + } + + /** + * Returns the pre-multiplied inverse projection x modelview, + * if {@link Matrix4f#invert(Matrix4f)} succeeded, otherwise `null`. + * <p> + * This {@link Matrix4f} instance should be re-fetched via this method and not locally stored + * to have it updated from a potential modification of underlying projection and/or modelview matrix. + * {@link #update()} has no effect on this {@link Matrix4f}. + * </p> + * <p> + * This pre-multipled invert(P x Mv) is considered dirty, if its corresponding + * {@link #getP() P matrix} or {@link #getMv() Mv matrix} has been modified since its last update. + * </p> + * @see #update() + */ + public final Matrix4f getPMvi() { + if( 0 != ( dirtyBits & PREMUL_PMVI ) ) { + if( null == matPMvi ) { + matPMvi = new Matrix4f(); + } + final Matrix4f mPMv = getPMv(); + matPMviOK = matPMvi.invert(mPMv); + dirtyBits &= ~PREMUL_PMVI; + } + return matPMviOK ? matPMvi : null; + } + + /** + * Returns the frustum, derived from projection x modelview. + * <p> + * This {@link Frustum} instance should be re-fetched via this method and not locally stored + * to have it updated from a potential modification of underlying projection and/or modelview matrix. + * {@link #update()} has no effect on this {@link Frustum}. + * </p> + * <p> + * The {@link Frustum} is considered dirty, if its corresponding + * {@link #getP() P matrix} or {@link #getMv() Mv matrix} has been modified since its last update. + * </p> + * @see #update() + */ + public final Frustum getFrustum() { + if( 0 != ( dirtyBits & FRUSTUM ) ) { + if( null == frustum ) { + frustum = new Frustum(); + } + final Matrix4f mPMv = getPMv(); + frustum.updateFrustumPlanes(mPMv); + dirtyBits &= ~FRUSTUM; + } + return frustum; + } + + /** + * Update the derived {@link #getMvi() inverse modelview (Mvi)}, + * {@link #getMvit() inverse transposed modelview (Mvit)} matrices + * <b>if</b> they {@link #isReqDirty() are dirty} <b>and</b> + * requested via the constructor {@link #PMVMatrix4f(int)}.<br/> + * Hence updates the following dirty bits. + * - {@link #INVERSE_MODELVIEW} + * - {@link #INVERSE_TRANSPOSED_MODELVIEW} + * <p> + * The {@link Frustum} is updated only via {@link #getFrustum()} separately. + * </p> + * <p> + * The Mvi and Mvit matrices are considered dirty, if their corresponding + * {@link #getMv() Mv matrix} has been modified since their last update. + * </p> + * <p> + * Method is automatically called by {@link SyncMatrix4f} and {@link SyncMatrices4f} + * instances {@link SyncAction} as retrieved by e.g. {@link #getSyncMvit()}. + * This ensures an automatic update cycle if used with {@link com.jogamp.opengl.GLUniformData}. + * </p> + * <p> + * Method may be called manually in case mutable operations has been called + * and caller operates on already fetched references, i.e. not calling + * {@link #getMvi()}, {@link #getMvit()} anymore. + * </p> + * <p> + * Method clears the modified bits like {@link #getModifiedBits(boolean) getModifiedBits(true)}, + * which are set by any mutable operation. The modified bits have no impact + * on this method, but the return value. + * </p> + * + * @return true if any matrix has been modified since last update call or + * if the derived matrices Mvi and Mvit were updated, otherwise false. + * In other words, method returns true if any matrix used by the caller must be updated, + * e.g. uniforms in a shader program. + * + * @see #getModifiedBits(boolean) + * @see #isReqDirty() + * @see #INVERSE_MODELVIEW + * @see #INVERSE_TRANSPOSED_MODELVIEW + * @see #PMVMatrix4f(int) + * @see #getMvi() + * @see #getMvit() + * @see #getSyncPMvMvi() + * @see #getSyncPMvMviMvit() + */ + public final boolean update() { + return updateImpl(true); + } + + // + // private + // + + private final boolean updateImpl(final boolean clearModBits) { + boolean mod = 0 != modifiedBits; + if( clearModBits ) { + modifiedBits = 0; + } + if( 0 != ( requestBits & ( ( dirtyBits & ( INVERSE_MODELVIEW | INVERSE_TRANSPOSED_MODELVIEW ) ) ) ) ) { // only if dirt requested & dirty + if( !matMvi.invert(matMv) ) { + throw new RuntimeException("Invalid source Mv matrix, can't compute inverse"); + } + dirtyBits &= ~INVERSE_MODELVIEW; + mod = true; + } + if( 0 != ( requestBits & ( dirtyBits & INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty + matMvit.transpose(matMvi); + dirtyBits &= ~INVERSE_TRANSPOSED_MODELVIEW; + mod = true; + } + return mod; + } + + protected final Matrix4f matP; + protected final Matrix4f matMv; + protected final Matrix4f matTex; + + private final Matrix4f matMvi; + private final Matrix4f matMvit; + + private static final int mP_offset = 0*16; + private static final int mMv_offset = 1*16; + private final int mMvi_offset; + private final int mMvit_offset; + private final int mTex_offset; + + private final float[] matrixStore; + + private final SyncMatrix4f syncP, syncMv, syncT; + private final SyncMatrix4f syncMvi, syncMvit; + private final SyncMatrices4f syncP_Mv, syncP_Mv_Mvi, syncP_Mv_Mvi_Mvit; + + protected final Matrix4f mat4Tmp1; + private Matrix4f mat4Tmp2; + + private int modifiedBits = MODIFIED_ALL; + private int dirtyBits = 0; // contains the dirty bits, i.e. hinting for update operation + private final int requestBits; // may contain the requested bits: INVERSE_MODELVIEW | INVERSE_TRANSPOSED_MODELVIEW + private Matrix4f matPMv; + private Matrix4f matPMvi; + private boolean matPMviOK; + private Frustum frustum; + + private abstract class PMVSyncBuffer implements SyncMatrix4f { + protected final Matrix4f mat; + private final FloatBuffer fbuf; + + public PMVSyncBuffer(final Matrix4f m, final FloatBuffer fbuf) { + this.mat = m; + this.fbuf = fbuf; + } + + @Override + public final Buffer getBuffer() { return fbuf; } + + @Override + public final SyncBuffer sync() { getAction().sync(); return this; } + + @Override + public final Buffer getSyncBuffer() { getAction().sync(); return fbuf; } + + @Override + public final Matrix4f getMatrix() { return mat; } + + @Override + public final FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; } + } + private final class SyncBuffer0 extends PMVSyncBuffer { + private final SyncAction action = new SyncAction() { + @Override + public void sync() { mat.get(matrixStore); } + }; + + public SyncBuffer0(final Matrix4f m, final FloatBuffer fbuf) { super(m, fbuf); } + + @Override + public SyncAction getAction() { return action; } + + } + private final class SyncBuffer1 extends PMVSyncBuffer { + private final int offset; + private final SyncAction action = new SyncAction() { + @Override + public void sync() { mat.get(matrixStore, offset); } + }; + + public SyncBuffer1(final Matrix4f m, final FloatBuffer fbuf, final int offset) { + super(m, fbuf); + this.offset = offset; + } + + @Override + public SyncAction getAction() { return action; } + } + private final class SyncBuffer1U extends PMVSyncBuffer { + private final int offset; + private final SyncAction action = new SyncAction() { + @Override + public void sync() { + updateImpl(true); + mat.get(matrixStore, offset); + } + }; + + public SyncBuffer1U(final Matrix4f m, final FloatBuffer fbuf, final int offset) { + super(m, fbuf); + this.offset = offset; + } + + @Override + public SyncAction getAction() { return action; } + } + + private abstract class PMVSyncBufferN implements SyncMatrices4f { + protected final Matrix4f[] mats; + private final FloatBuffer fbuf; + + public PMVSyncBufferN(final Matrix4f[] ms, final FloatBuffer fbuf) { + this.mats = ms; + this.fbuf = fbuf; + } + + @Override + public final Buffer getBuffer() { return fbuf; } + + @Override + public final SyncBuffer sync() { getAction().sync(); return this; } + + @Override + public final Buffer getSyncBuffer() { getAction().sync(); return fbuf; } + + @Override + public Matrix4f[] getMatrices() { return mats; } + + @Override + public final FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; } + } + private final class SyncBufferN extends PMVSyncBufferN { + private final int offset; + private final SyncAction action = new SyncAction() { + @Override + public void sync() { + int ioff = offset; + for(int i=0; i<mats.length; ++i, ioff+=16) { + mats[i].get(matrixStore, ioff); + } + } + }; + + public SyncBufferN(final Matrix4f[] ms, final FloatBuffer fbuf, final int offset) { + super(ms, fbuf); + this.offset = offset; + } + + @Override + public SyncAction getAction() { return action; } + } + private final class SyncBufferNU extends PMVSyncBufferN { + private final int offset; + private final SyncAction action = new SyncAction() { + @Override + public void sync() { + updateImpl(true); + int ioff = offset; + for(int i=0; i<mats.length; ++i, ioff+=16) { + mats[i].get(matrixStore, ioff); + } + } + }; + + public SyncBufferNU(final Matrix4f[] ms, final FloatBuffer fbuf, final int offset) { + super(ms, fbuf); + this.offset = offset; + } + + @Override + public SyncAction getAction() { return action; } + } +}
\ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncAction.java b/src/jogl/classes/com/jogamp/math/util/SyncAction.java index fbf55e683..08be2d2ac 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/SyncAction.java +++ b/src/jogl/classes/com/jogamp/math/util/SyncAction.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.util; +package com.jogamp.math.util; /** * Specific data synchronization action implemented by the data provider diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncBuffer.java b/src/jogl/classes/com/jogamp/math/util/SyncBuffer.java index 27bdb5dfb..368a69b14 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/SyncBuffer.java +++ b/src/jogl/classes/com/jogamp/math/util/SyncBuffer.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.util; +package com.jogamp.math.util; import java.nio.Buffer; diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f.java b/src/jogl/classes/com/jogamp/math/util/SyncMatrices4f.java index 055345d65..cc2ae36b6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f.java +++ b/src/jogl/classes/com/jogamp/math/util/SyncMatrices4f.java @@ -25,13 +25,13 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.util; +package com.jogamp.math.util; import java.nio.FloatBuffer; -import com.jogamp.opengl.math.Matrix4f; +import com.jogamp.math.Matrix4f; -/** {@link SyncBuffer} with a multiple underlying {@link Matrix4f}, used in {@link SyncMatrices4f16} and {@link PMVMatrix} */ +/** {@link SyncBuffer} with a multiple underlying {@link Matrix4f}, used in {@link SyncMatrices4f16} and {@link com.jogamp.math.util.PMVMatrix4f PMVMatrix4f} */ public interface SyncMatrices4f extends SyncBuffer { /** Return the underlying multiple {@link Matrix4f}, used to {@link SyncAction#sync() synchronize} to the {@link #getBuffer()}. */ Matrix4f[] getMatrices(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f16.java b/src/jogl/classes/com/jogamp/math/util/SyncMatrices4f16.java index bca827b9f..6faba38ee 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrices4f16.java +++ b/src/jogl/classes/com/jogamp/math/util/SyncMatrices4f16.java @@ -25,12 +25,12 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.util; +package com.jogamp.math.util; import java.nio.Buffer; import java.nio.FloatBuffer; -import com.jogamp.opengl.math.Matrix4f; +import com.jogamp.math.Matrix4f; /** {@link SyncBuffer} {@link SyncMatrices4f16} implementation for multiple underlying {@link Matrix4f} instances using one {@code float[16*n]} backing array. */ public final class SyncMatrices4f16 implements SyncMatrices4f { diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f.java b/src/jogl/classes/com/jogamp/math/util/SyncMatrix4f.java index 6ab473771..9ca6857c5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f.java +++ b/src/jogl/classes/com/jogamp/math/util/SyncMatrix4f.java @@ -25,13 +25,13 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.util; +package com.jogamp.math.util; import java.nio.FloatBuffer; -import com.jogamp.opengl.math.Matrix4f; +import com.jogamp.math.Matrix4f; -/** {@link SyncBuffer} interface with a single underlying {@link Matrix4f}, used in {@link SyncMatrix4f16} and {@link PMVMatrix}. */ +/** {@link SyncBuffer} interface with a single underlying {@link Matrix4f}, used in {@link SyncMatrix4f16} and {@link com.jogamp.math.util.PMVMatrix4f PMVMatrix4f}. */ public interface SyncMatrix4f extends SyncBuffer { /** Return the underlying {@link Matrix4f}, used to {@link SyncAction#sync() synchronize} to the {@link #getBuffer()}. */ Matrix4f getMatrix(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f16.java b/src/jogl/classes/com/jogamp/math/util/SyncMatrix4f16.java index 03a4b64fa..e6b7e8742 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/SyncMatrix4f16.java +++ b/src/jogl/classes/com/jogamp/math/util/SyncMatrix4f16.java @@ -25,12 +25,12 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.util; +package com.jogamp.math.util; import java.nio.Buffer; import java.nio.FloatBuffer; -import com.jogamp.opengl.math.Matrix4f; +import com.jogamp.math.Matrix4f; /** {@link SyncBuffer} {@link SyncMatrix4f} implementation for a single underlying {@link Matrix4f} using one {@code float[16]} backing array. */ public final class SyncMatrix4f16 implements SyncMatrix4f { diff --git a/src/jogl/classes/com/jogamp/opengl/GLUniformData.java b/src/jogl/classes/com/jogamp/opengl/GLUniformData.java index c4cc3fe8f..63eb2658d 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLUniformData.java +++ b/src/jogl/classes/com/jogamp/opengl/GLUniformData.java @@ -32,9 +32,9 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import com.jogamp.common.nio.Buffers; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.util.SyncAction; -import com.jogamp.opengl.util.SyncBuffer; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.util.SyncAction; +import com.jogamp.math.util.SyncBuffer; /** * GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform. diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index ebb164912..3350b30a7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -27,38 +27,27 @@ */ package com.jogamp.opengl.util; -import java.nio.Buffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; import com.jogamp.opengl.GL; import com.jogamp.opengl.GLException; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.GLUniformData; -import com.jogamp.common.nio.Buffers; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Ray; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.math.geom.Frustum; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.Frustum; +import com.jogamp.math.util.PMVMatrix4f; /** - * PMVMatrix implements a subset of the fixed function pipeline - * regarding the projection (P), modelview (Mv) and texture (T) matrix operations, - * which is specified in {@link GLMatrixFunc}. + * PMVMatrix implements a subset of the fixed function pipeline {@link GLMatrixFunc} + * using {@link PMVMatrix4f}. * <p> - * This is the second implementation of `PMVMatrix` using - * direct {@link Matrix4f}, {@link Vec4f} and {@link Vec3f} math operations instead of `float[]` - * via {@link com.jogamp.opengl.math.FloatUtil FloatUtil}. - * </p> - * <p> - * PMVMatrix provides the {@link #getMviMat() inverse modelview matrix (Mvi)} and - * {@link #getMvitMat() inverse transposed modelview matrix (Mvit)}. + * PMVMatrix provides the {@link #getMvi() inverse modelview matrix (Mvi)} and + * {@link #getMvit() inverse transposed modelview matrix (Mvit)}. * {@link Frustum} is also provided by {@link #getFrustum()}. * * To keep these derived values synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)} @@ -66,68 +55,11 @@ import com.jogamp.opengl.math.geom.Frustum; * users have to call {@link #update()} before using Mvi and Mvit. * </p> * <p> - * All matrices are provided in column-major order, - * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. - * See {@link Matrix4f}. - * </p> - * <p> - * PMVMatrix can supplement {@link GL2ES2} applications w/ the + * PMVMatrix can supplement {@link com.jogamp.opengl.GL2ES2 GL2ES2} applications w/ the * lack of the described matrix functionality. * </p> - * <a name="storageDetails"><h5>Matrix storage details</h5></a> - * <p> - * The {@link SyncBuffer} abstraction is provided, e.g. {@link #getSyncPMvMviMat()}, - * to synchronize the respective {@link Matrix4f matrices} with the `float[]` backing store. - * The latter is represents the data to {@link GLUniformData} via its {@link FloatBuffer}s, see {@link SyncBuffer#getBuffer()}, - * and is pushed to the GPU eventually. - * - * {@link SyncBuffer}'s {@link SyncAction} is called by {@link GLUniformData#getBuffer()}, - * i.e. before the data is pushed to the GPU. - * - * The provided {@link SyncAction} ensures that the {@link Matrix4f matrices data} - * gets copied into the `float[]` backing store. - * - * PMVMatrix provides two specializations of {@link SyncBuffer}, {@link SyncMatrix4f} for single {@link Matrix4f} mappings - * and {@link SyncMatrices4f} for multiple {@link Matrix4f} mappings. - * - * They can be feed directly to instantiate a {@link GLUniformData} object via e.g. {@link GLUniformData#GLUniformData(String, int, int, SyncBuffer)}. - * </p> - * <p> - * All matrices are backed up by a common primitive float-array for performance considerations - * and are a {@link Buffers#slice2Float(float[], int, int) sliced} representation of it. - * </p> - * <p> - * <b>Note:</b> - * <ul> - * <li>The matrix is a {@link Buffers#slice2Float(float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.</li> - * <li>Use {@link FloatBuffer#reset() reset()} to rewind it to it's start position after relative operations, like {@link FloatBuffer#get() get()}.</li> - * <li>If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.</li> - * </ul> - * </p> */ -public final class PMVMatrix implements GLMatrixFunc { - - /** Bit value stating a modified {@link #getPMat() projection matrix (P)}, since last {@link #update()} call. */ - public static final int MODIFIED_PROJECTION = 1 << 0; - /** Bit value stating a modified {@link #getMvMat() modelview matrix (Mv)}, since last {@link #update()} call. */ - public static final int MODIFIED_MODELVIEW = 1 << 1; - /** Bit value stating a modified {@link #getTMat() texture matrix (T)}, since last {@link #update()} call. */ - public static final int MODIFIED_TEXTURE = 1 << 2; - /** Bit value stating all is modified */ - public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ; - - /** Bit value for {@link #getMviMat() inverse modelview matrix (Mvi)}, updated via {@link #update()}. */ - public static final int INVERSE_MODELVIEW = 1 << 1; - /** Bit value for {@link #getMvitMat() inverse transposed modelview matrix (Mvit)}, updated via {@link #update()}. */ - public static final int INVERSE_TRANSPOSED_MODELVIEW = 1 << 2; - /** Bit value for {@link #getFrustum() frustum} and updated by {@link #getFrustum()}. */ - public static final int FRUSTUM = 1 << 3; - /** Bit value for {@link #getPMvMat() pre-multiplied P * Mv}, updated by {@link #getPMvMat()}. */ - public static final int PREMUL_PMV = 1 << 4; - /** Bit value for {@link #getPMviMat() pre-multiplied invert(P * Mv)}, updated by {@link #getPMviMat()}. */ - public static final int PREMUL_PMVI = 1 << 5; - /** Manual bits not covered by {@link #update()} but {@link #getFrustum()}, {@link #FRUSTUM}, {@link #getPMvMat()}, {@link #PREMUL_PMV}, {@link #getPMviMat()}, {@link #PREMUL_PMVI}, etc. */ - public static final int MANUAL_BITS = FRUSTUM | PREMUL_PMV | PREMUL_PMVI; +public final class PMVMatrix extends PMVMatrix4f implements GLMatrixFunc { /** * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} @@ -227,297 +159,29 @@ public final class PMVMatrix implements GLMatrixFunc { * @see #update() */ public PMVMatrix(final int derivedMatrices) { - // I Identity - // T Texture - // P Projection - // Mv ModelView - // Mvi Modelview-Inverse - // Mvit Modelview-Inverse-Transpose - { - int mask = 0; - if( 0 != ( derivedMatrices & ( INVERSE_MODELVIEW | INVERSE_TRANSPOSED_MODELVIEW ) ) ) { - mask |= INVERSE_MODELVIEW; - } - if( 0 != ( derivedMatrices & INVERSE_TRANSPOSED_MODELVIEW ) ) { - mask |= INVERSE_TRANSPOSED_MODELVIEW; - } - requestBits = mask; - } - - // actual underlying Matrix4f count - int mcount = 3; - - // actual underlying Matrix4f data - matP = new Matrix4f(); - matMv = new Matrix4f(); - matTex = new Matrix4f(); - - if( 0 != ( requestBits & INVERSE_MODELVIEW ) ) { - matMvi = new Matrix4f(); - mMvi_offset = 2*16; - ++mcount; - } else { - matMvi = null; - mMvi_offset = -1; - } - if( 0 != ( requestBits & INVERSE_TRANSPOSED_MODELVIEW ) ) { - matMvit = new Matrix4f(); - mMvit_offset = 3*16; - ++mcount; - } else { - matMvit = null; - mMvit_offset = -1; - } - mTex_offset = (mcount-1)*16; // last one - - // float back buffer for GPU, Matrix4f -> matrixStore via SyncedBuffer - matrixStore = new float[mcount*16]; - - // FloatBuffer for single Matrix4f back-buffer - bufP = Buffers.slice2Float(matrixStore, mP_offset, 1*16); // P - syncP = new SyncBuffer0(matP, bufP); // mP_offset - - bufMv = Buffers.slice2Float(matrixStore, mMv_offset, 1*16); // Mv - syncMv = new SyncBuffer1(matMv, bufMv, mMv_offset); - - bufP_Mv = Buffers.slice2Float(matrixStore, mP_offset, 2*16); // P + Mv - syncP_Mv = new SyncBufferN(new Matrix4f[] { matP, matMv }, bufP_Mv, mP_offset); - - bufTex = Buffers.slice2Float(matrixStore, mTex_offset, 1*16); // T - syncT = new SyncBuffer1(matTex, bufTex, mTex_offset); - - if( null != matMvi ) { - bufMvi = Buffers.slice2Float(matrixStore, mMvi_offset, 1*16); // Mvi - bufP_Mv_Mvi = Buffers.slice2Float(matrixStore, mP_offset, 3*16); // P + Mv + Mvi - syncMvi = new SyncBuffer1U(matMvi, bufMvi, mMvi_offset); - syncP_Mv_Mvi = new SyncBufferNU(new Matrix4f[] { matP, matMv, matMvi }, bufP_Mv_Mvi, mP_offset); - } else { - bufMvi = null; - bufP_Mv_Mvi = null; - syncMvi = null; - syncP_Mv_Mvi = null; - } - if( null != matMvit ) { - bufMvit = Buffers.slice2Float(matrixStore, mMvit_offset, 1*16); // Mvit - bufP_Mv_Mvi_Mvit = Buffers.slice2Float(matrixStore, mP_offset, 4*16); // P + Mv + Mvi + Mvit - syncMvit = new SyncBuffer1U(matMvit, bufMvit, mMvit_offset); - syncP_Mv_Mvi_Mvit = new SyncBufferNU(new Matrix4f[] { matP, matMv, matMvi, matMvit }, bufP_Mv_Mvi_Mvit, mP_offset); - } else { - bufMvit = null; - bufP_Mv_Mvi_Mvit = null; - syncMvit = null; - syncP_Mv_Mvi_Mvit = null; - } - - mat4Tmp1 = new Matrix4f(); - - mat4Tmp2 = null; // on demand - matPMv = null; // on demand - matPMvi = null; // on demand - matPMviOK = false; - frustum = null; // on demand - - reset(); - } - - /** - * Issues {@link #glLoadIdentity()} on all matrices, - * i.e. {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} - * and resets all internal states. - * - * Leaves {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW} the active matrix mode. - */ - public final void reset() { - matP.loadIdentity(); - matMv.loadIdentity(); - matTex.loadIdentity(); - - modifiedBits = MODIFIED_ALL; - dirtyBits = requestBits | MANUAL_BITS; - matrixMode = GL_MODELVIEW; - } - - /** Returns the current matrix-mode, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. */ - public final int glGetMatrixMode() { - return matrixMode; + super(derivedMatrices); } - // - // Temporary storage access for efficiency - // /** - * Return the second temporary Matrix4f exposed to be reused for efficiency. + * {@inheritDoc} * <p> - * Temporary storage is only used by this class within single method calls, - * hence has no side-effects. + * Leaves {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW} the active matrix mode. * </p> */ - private final Matrix4f getTmp2Mat() { - if( null == mat4Tmp2 ) { - mat4Tmp2 = new Matrix4f(); - } - return mat4Tmp2; + @Override + public void reset() { + super.reset(); + matrixMode = GL_MODELVIEW; } // - // Regular Matrix4f access as well as their SyncedBuffer counterpart SyncedMatrix and SyncedMatrices + // GLMatrixFunc implementation // - /** - * Returns the {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final Matrix4f getTMat() { - return matTex; - } - - /** - * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final SyncMatrix4f getSyncTMat() { - return syncT; - } - - /** - * Returns the {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final Matrix4f getPMat() { - return matP; - } - - /** - * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final SyncMatrix4f getSyncPMat() { - return syncP; - } - - /** - * Returns the {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final Matrix4f getMvMat() { - return matMv; - } - - /** - * Returns the {@link SyncMatrix} of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final SyncMatrix4f getSyncMvMat() { - return syncMv; - } - - /** - * Returns {@link SyncMatrices4f} of 2 matrices within one FloatBuffer: {@link #getPMat() P} and {@link #getMvMat() Mv}. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - */ - public final SyncMatrices4f getSyncPMvMat() { - return syncP_Mv; - } - - /** - * Returns the inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi) if requested. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - * @throws IllegalArgumentException if {@link #INVERSE_MODELVIEW} has not been requested in ctor {@link #PMVMatrix(int)}. - */ - public final Matrix4f getMviMat() { - if( 0 == ( INVERSE_MODELVIEW & requestBits ) ) { - throw new IllegalArgumentException("Not requested in ctor"); - } - updateImpl(false); - return matMvi; - } - - /** - * Returns the {@link SyncMatrix} of inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi) if requested. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - * @throws IllegalArgumentException if {@link #INVERSE_MODELVIEW} has not been requested in ctor {@link #PMVMatrix(int)}. - */ - public final SyncMatrix4f getSyncMviMat() { - if( 0 == ( INVERSE_MODELVIEW & requestBits ) ) { - throw new IllegalArgumentException("Not requested in ctor"); - } - return syncMvi; - } - - /** - * Returns the inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit) if requested. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - * @throws IllegalArgumentException if {@link #INVERSE_TRANSPOSED_MODELVIEW} has not been requested in ctor {@link #PMVMatrix(int)}. - */ - public final Matrix4f getMvitMat() { - if( 0 == ( INVERSE_TRANSPOSED_MODELVIEW & requestBits ) ) { - throw new IllegalArgumentException("Not requested in ctor"); - } - updateImpl(false); - return matMvit; - } - - /** - * Returns the {@link SyncMatrix} of inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit) if requested. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - * @throws IllegalArgumentException if {@link #INVERSE_TRANSPOSED_MODELVIEW} has not been requested in ctor {@link #PMVMatrix(int)}. - */ - public final SyncMatrix4f getSyncMvitMat() { - if( 0 == ( INVERSE_TRANSPOSED_MODELVIEW & requestBits ) ) { - throw new IllegalArgumentException("Not requested in ctor"); - } - return syncMvit; - } - - /** - * Returns {@link SyncMatrices4f} of 3 matrices within one FloatBuffer: {@link #getPMat() P}, {@link #getMvMat() Mv} and {@link #getMviMat() Mvi} if requested. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - * @throws IllegalArgumentException if {@link #INVERSE_MODELVIEW} has not been requested in ctor {@link #PMVMatrix(int)}. - */ - public final SyncMatrices4f getSyncPMvMviMat() { - if( 0 == ( INVERSE_MODELVIEW & requestBits ) ) { - throw new IllegalArgumentException("Not requested in ctor"); - } - return syncP_Mv_Mvi; - } - - /** - * Returns {@link SyncMatrices4f} of 4 matrices within one FloatBuffer: {@link #getPMat() P}, {@link #getMvMat() Mv}, {@link #getMviMat() Mvi} and {@link #getMvitMat() Mvit} if requested. - * <p> - * See <a href="#storageDetails"> matrix storage details</a>. - * </p> - * @throws IllegalArgumentException if {@link #INVERSE_TRANSPOSED_MODELVIEW} has not been requested in ctor {@link #PMVMatrix(int)}. - */ - public final SyncMatrices4f getSyncPMvMviMvitMat() { - if( 0 == ( INVERSE_TRANSPOSED_MODELVIEW & requestBits ) ) { - throw new IllegalArgumentException("Not requested in ctor"); - } - return syncP_Mv_Mvi_Mvit; + /** Returns the current matrix-mode, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. */ + public final int glGetMatrixMode() { + return matrixMode; } /** @@ -550,172 +214,6 @@ public final class PMVMatrix implements GLMatrixFunc { } } - // - // Basic Matrix4f, Vec3f and Vec4f operations similar to GLMatrixFunc - // - - /** - * Multiplies the {@link #getPMat() P} and {@link #getMvMat() Mv} matrix, i.e. - * <pre> - * result = P x Mv - * </pre> - * @param result 4x4 matrix storage for result - * @return given result matrix for chaining - */ - public final Matrix4f mulPMvMat(final Matrix4f result) { - return result.mul(matP, matMv); - } - - /** - * Multiplies the {@link #getMvMat() Mv} and {@link #getPMat() P} matrix, i.e. - * <pre> - * result = Mv x P - * </pre> - * @param result 4x4 matrix storage for result - * @return given result matrix for chaining - */ - public final Matrix4f mulMvPMat(final Matrix4f result) { - return result.mul(matMv, matP); - } - - /** - * v_out = Mv * v_in - * @param v_in input vector, can be v_out for in-place transformation - * @param v_out output vector - * @returns v_out for chaining - */ - public final Vec4f mulMvMatVec4f(final Vec4f v_in, final Vec4f v_out) { - return matMv.mulVec4f(v_in, v_out); - } - - /** - * v_inout = Mv * v_inout - * @param v_inout input and output vector, i.e. in-place transformation - * @returns v_inout for chaining - */ - public final Vec4f mulMvMatVec4f(final Vec4f v_inout) { - return matMv.mulVec4f(v_inout); - } - - /** - * v_out = Mv * v_in - * - * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. - * - * @param v_in input vector, can be v_out for in-place transformation - * @param v_out output vector - * @returns v_out for chaining - */ - public final Vec3f mulMvMatVec3f(final Vec3f v_in, final Vec3f v_out) { - return matMv.mulVec3f(v_in, v_out); - } - - /** - * v_inout = Mv * v_inout - * - * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. - * - * @param v_inout input and output vector, i.e. in-place transformation - * @returns v_inout for chaining - */ - public final Vec3f mulMvMatVec3f(final Vec3f v_inout) { - return matMv.mulVec3f(v_inout); - } - - /** - * v_out = P * v_in - * @param v_in input vector, can be v_out for in-place transformation - * @param v_out output vector - * @return given result vector for chaining - * @returns v_out for chaining - */ - public final Vec4f mulPMatVec4f(final Vec4f v_in, final Vec4f v_out) { - return matP.mulVec4f(v_in, v_out); - } - - /** - * v_inout = P * v_inout - * @param v_inout input and output vector, i.e. in-place transformation - * @return given result vector for chaining - * @returns v_inout for chaining - */ - public final Vec4f mulPMatVec4f(final Vec4f v_inout) { - return matP.mulVec4f(v_inout); - } - - /** - * v_out = P * v_in - * - * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. - * - * @param v_in float[3] input vector, can be v_out for in-place transformation - * @param v_out float[3] output vector - * @returns v_out for chaining - */ - public final Vec3f mulPMatVec3f(final Vec3f v_in, final Vec3f v_out) { - return matP.mulVec3f(v_in, v_out); - } - - /** - * v_inout = P * v_inout - * - * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. - * - * @param v_inout input and output vector, i.e. in-place transformation - * @returns v_inout for chaining - */ - public final Vec3f mulPMatVec3f(final Vec3f v_inout) { - return matP.mulVec3f(v_inout); - } - - /** - * v_out = P * Mv * v_in - * @param v_in float[4] input vector, can be v_out for in-place transformation - * @param v_out float[4] output vector - * @returns v_out for chaining - */ - public final Vec4f mulPMvMatVec4f(final Vec4f v_in, final Vec4f v_out) { - return matP.mulVec4f( matMv.mulVec4f( v_in, v_out ) ); - } - - /** - * v_inout = P * Mv * v_inout - * @param v_inout input and output vector, i.e. in-place transformation - * @returns v_inout for chaining - */ - public final Vec4f mulPMvMatVec4f(final Vec4f v_inout) { - return matP.mulVec4f( matMv.mulVec4f( v_inout ) ); - } - - /** - * v_out = P * Mv * v_in - * - * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. - * - * @param v_in float[3] input vector, can be v_out for in-place transformation - * @param v_out float[3] output vector - * @returns v_out for chaining - */ - public final Vec3f mulPMvMatVec3f(final Vec3f v_in, final Vec3f v_out) { - return matP.mulVec3f( matMv.mulVec3f( v_in, v_out ) ); - } - - /** - * v_inout = P * Mv * v_inout - * - * Affine 3f-vector transformation by 4x4 matrix, see {@link Matrix4f#mulVec3f(Vec3f, Vec3f)}. - * - * @param v_inout float[3] input and output vector, i.e. in-place transformation - * @returns v_inout for chaining - */ - public final Vec3f mulPMvMatVec3f(final Vec3f v_inout) { - return matP.mulVec3f( matMv.mulVec3f( v_inout ) ); - } - - // - // GLMatrixFunc implementation - // - @Override public final void glMatrixMode(final int matrixName) { switch(matrixName) { @@ -772,35 +270,23 @@ public final class PMVMatrix implements GLMatrixFunc { @Override public final void glLoadMatrixf(final float[] values, final int offset) { if(matrixMode==GL_MODELVIEW) { - matMv.load(values, offset); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + loadMv(values, offset); } else if(matrixMode==GL_PROJECTION) { - matP.load(values, offset); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + loadP(values, offset); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.load(values, offset); - modifiedBits |= MODIFIED_TEXTURE; + loadT(values, offset); } } @Override public final void glLoadMatrixf(final java.nio.FloatBuffer m) { - final int spos = m.position(); if(matrixMode==GL_MODELVIEW) { - matMv.load(m); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + loadMv(m); } else if(matrixMode==GL_PROJECTION) { - matP.load(m); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + loadP(m); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.load(m); - modifiedBits |= MODIFIED_TEXTURE; + loadT(m); } - m.position(spos); } /** @@ -811,16 +297,11 @@ public final class PMVMatrix implements GLMatrixFunc { */ public final void glLoadMatrixf(final Matrix4f m) { if(matrixMode==GL_MODELVIEW) { - matMv.load(m); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + loadMv(m); } else if(matrixMode==GL_PROJECTION) { - matP.load(m); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + loadP(m); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.load(m); - modifiedBits |= MODIFIED_TEXTURE; + loadT(m); } } @@ -832,59 +313,22 @@ public final class PMVMatrix implements GLMatrixFunc { */ public final void glLoadMatrix(final Quaternion quat) { if(matrixMode==GL_MODELVIEW) { - matMv.setToRotation(quat); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + loadMv(quat); } else if(matrixMode==GL_PROJECTION) { - matP.setToRotation(quat); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + loadP(quat); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.setToRotation(quat); - modifiedBits |= MODIFIED_TEXTURE; - } - } - - @Override - public final void glPopMatrix() { - if(matrixMode==GL_MODELVIEW) { - matMv.pop(); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; - } else if(matrixMode==GL_PROJECTION) { - matP.pop(); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; - } else if(matrixMode==GL.GL_TEXTURE) { - matTex.pop(); - modifiedBits |= MODIFIED_TEXTURE; - } - } - - @Override - public final void glPushMatrix() { - if(matrixMode==GL_MODELVIEW) { - matMv.push(); - } else if(matrixMode==GL_PROJECTION) { - matP.push(); - } else if(matrixMode==GL.GL_TEXTURE) { - matTex.push(); + loadT(quat); } } @Override public final void glLoadIdentity() { if(matrixMode==GL_MODELVIEW) { - matMv.loadIdentity(); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + loadMvIdentity(); } else if(matrixMode==GL_PROJECTION) { - matP.loadIdentity(); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + loadPIdentity(); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.loadIdentity(); - modifiedBits |= MODIFIED_TEXTURE; + loadTIdentity(); } } @@ -892,16 +336,11 @@ public final class PMVMatrix implements GLMatrixFunc { public final void glMultMatrixf(final FloatBuffer m) { final int spos = m.position(); if(matrixMode==GL_MODELVIEW) { - matMv.mul( mat4Tmp1.load( m ) ); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + mulMv( mat4Tmp1.load( m ) ); } else if(matrixMode==GL_PROJECTION) { - matP.mul( mat4Tmp1.load( m ) ); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + mulP( mat4Tmp1.load( m ) ); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.mul( mat4Tmp1.load( m ) ); - modifiedBits |= MODIFIED_TEXTURE; + mulT( mat4Tmp1.load( m ) ); } m.position(spos); } @@ -909,16 +348,11 @@ public final class PMVMatrix implements GLMatrixFunc { @Override public final void glMultMatrixf(final float[] m, final int m_offset) { if(matrixMode==GL_MODELVIEW) { - matMv.mul( mat4Tmp1.load( m, m_offset ) ); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + mulMv( mat4Tmp1.load( m, m_offset ) ); } else if(matrixMode==GL_PROJECTION) { - matP.mul( mat4Tmp1.load( m, m_offset ) ); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + mulP( mat4Tmp1.load( m, m_offset ) ); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.mul( mat4Tmp1.load( m, m_offset ) ); - modifiedBits |= MODIFIED_TEXTURE; + mulT( mat4Tmp1.load( m, m_offset ) ); } } @@ -932,16 +366,11 @@ public final class PMVMatrix implements GLMatrixFunc { */ public final PMVMatrix glMultMatrixf(final Matrix4f m) { if(matrixMode==GL_MODELVIEW) { - matMv.mul( m ); - dirtyBits |= requestBits | MANUAL_BITS ; - modifiedBits |= MODIFIED_MODELVIEW; + mulMv(m); } else if(matrixMode==GL_PROJECTION) { - matP.mul( m ); - dirtyBits |= MANUAL_BITS ; - modifiedBits |= MODIFIED_PROJECTION; + mulP(m); } else if(matrixMode==GL.GL_TEXTURE) { - matTex.mul( m ); - modifiedBits |= MODIFIED_TEXTURE; + mulT(m); } return this; } @@ -1015,6 +444,28 @@ public final class PMVMatrix implements GLMatrixFunc { } @Override + public final void glPopMatrix() { + if(matrixMode==GL_MODELVIEW) { + popMv(); + } else if(matrixMode==GL_PROJECTION) { + popP(); + } else if(matrixMode==GL.GL_TEXTURE) { + popT(); + } + } + + @Override + public final void glPushMatrix() { + if(matrixMode==GL_MODELVIEW) { + pushMv(); + } else if(matrixMode==GL_PROJECTION) { + pushP(); + } else if(matrixMode==GL.GL_TEXTURE) { + pushT(); + } + } + + @Override public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { glMultMatrixf( mat4Tmp1.setToOrtho(left, right, bottom, top, zNear, zFar) ); } @@ -1022,12 +473,12 @@ public final class PMVMatrix implements GLMatrixFunc { /** * {@inheritDoc} * - * @throws GLException if {@code zNear <= 0} or {@code zFar <= zNear} - * or {@code left == right}, or {@code bottom == top}. + * @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear} + * or {@code left == right}, or {@code bottom == top}. * @see Matrix4f#setToFrustum(float, float, float, float, float, float) */ @Override - public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) throws GLException { + public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) throws IllegalArgumentException { glMultMatrixf( mat4Tmp1.setToFrustum(left, right, bottom, top, zNear, zFar) ); } @@ -1042,111 +493,22 @@ public final class PMVMatrix implements GLMatrixFunc { * @param aspect aspect ratio width / height * @param zNear * @param zFar - * @throws GLException if {@code zNear <= 0} or {@code zFar <= zNear} + * @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear} * @see Matrix4f#setToPerspective(float, float, float, float) */ - public final void gluPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar) throws GLException { + public final void gluPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar) throws IllegalArgumentException { glMultMatrixf( mat4Tmp1.setToPerspective(fovy_rad, aspect, zNear, zFar) ); } /** - * {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix} - * with the eye, object and orientation. + * {@link #glMultMatrixf(FloatBuffer) Multiply} the {@link #glGetMatrixMode() current matrix} + * with the eye, object and orientation, i.e. {@link Matrix4f#setToLookAt(Vec3f, Vec3f, Vec3f, Matrix4f)}. */ public final void gluLookAt(final Vec3f eye, final Vec3f center, final Vec3f up) { glMultMatrixf( mat4Tmp1.setToLookAt(eye, center, up, getTmp2Mat()) ); } /** - * Map object coordinates to window coordinates. - * <p> - * Traditional <code>gluProject</code> implementation. - * </p> - * - * @param objPos 3 component object coordinate - * @param viewport Rect4i viewport - * @param winPos 3 component window coordinate, the result - * @return true if successful, otherwise false (z is 1) - */ - public final boolean gluProject(final Vec3f objPos, final Recti viewport, final Vec3f winPos ) { - return Matrix4f.mapObjToWin(objPos, matMv, matP, viewport, winPos); - } - - /** - * Map window coordinates to object coordinates. - * <p> - * Traditional <code>gluUnProject</code> implementation. - * </p> - * - * @param winx - * @param winy - * @param winz - * @param viewport Rect4i viewport - * @param objPos 3 component object coordinate, the result - * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) - */ - public final boolean gluUnProject(final float winx, final float winy, final float winz, - final Recti viewport, final Vec3f objPos) { - if( Matrix4f.mapWinToObj(winx, winy, winz, getPMviMat(), viewport, objPos) ) { - return true; - } else { - return false; - } - } - - /** - * Map window coordinates to object coordinates. - * <p> - * Traditional <code>gluUnProject4</code> implementation. - * </p> - * - * @param winx - * @param winy - * @param winz - * @param clipw - * @param viewport Rect4i viewport - * @param near - * @param far - * @param objPos 4 component object coordinate, the result - * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) - */ - public boolean gluUnProject4(final float winx, final float winy, final float winz, final float clipw, - final Recti viewport, - final float near, final float far, - final Vec4f objPos) { - if( Matrix4f.mapWinToObj4(winx, winy, winz, clipw, getPMviMat(), viewport, near, far, objPos) ) { - return true; - } else { - return false; - } - } - - /** - * Map two window coordinates w/ shared X/Y and distinctive Z - * to a {@link Ray}. The resulting {@link Ray} maybe used for <i>picking</i> - * using a {@link AABBox#getRayIntersection(Vec3f, Ray, float, boolean) bounding box}. - * <p> - * Notes for picking <i>winz0</i> and <i>winz1</i>: - * <ul> - * <li>see {@link FloatUtil#getZBufferEpsilon(int, float, float)}</li> - * <li>see {@link FloatUtil#getZBufferValue(int, float, float, float)}</li> - * <li>see {@link FloatUtil#getOrthoWinZ(float, float, float)}</li> - * </ul> - * </p> - * @param winx - * @param winy - * @param winz0 - * @param winz1 - * @param viewport - * @param ray storage for the resulting {@link Ray} - * @return true if successful, otherwise false (failed to invert matrix, or becomes z is infinity) - */ - public final boolean gluUnProjectRay(final float winx, final float winy, final float winz0, final float winz1, - final Recti viewport, final Ray ray) { - return Matrix4f.mapWinToRay(winx, winy, winz0, winz1, getPMviMat(), viewport, ray); - } - - /** * Make given matrix the <i>pick</i> matrix based on given parameters. * <p> * Traditional <code>gluPickMatrix</code> implementation. @@ -1160,495 +522,15 @@ public final class PMVMatrix implements GLMatrixFunc { * @param deltaY the height of the picking region in window coordinates. * @param viewport Rect4i viewport vector */ - public final void gluPickMatrix(final float x, final float y, - final float deltaX, final float deltaY, final Recti viewport) { + public final void gluPickMatrix(final float x, final float y, final float deltaX, final float deltaY, final Recti viewport) { if( null != mat4Tmp1.setToPick(x, y, deltaX, deltaY, viewport, getTmp2Mat()) ) { glMultMatrixf( mat4Tmp1 ); } } - public StringBuilder toString(StringBuilder sb, final String f) { - if(null == sb) { - sb = new StringBuilder(); - } - final boolean pmvDirty = 0 != (PREMUL_PMV & dirtyBits); - final boolean pmvUsed = null != matPMv; - - final boolean pmviDirty = 0 != (PREMUL_PMVI & dirtyBits); - final boolean pmviUsed = null != matPMvi; - - final boolean frustumDirty = 0 != (FRUSTUM & dirtyBits); - final boolean frustumUsed = null != frustum; - - final boolean mviDirty = 0 != (INVERSE_MODELVIEW & dirtyBits); - final boolean mviReq = 0 != (INVERSE_MODELVIEW & requestBits); - - final boolean mvitDirty = 0 != (INVERSE_TRANSPOSED_MODELVIEW & dirtyBits); - final boolean mvitReq = 0 != (INVERSE_TRANSPOSED_MODELVIEW & requestBits); - - final boolean modP = 0 != ( MODIFIED_PROJECTION & modifiedBits ); - final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); - final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); - int count = 3; // P, Mv, T - - sb.append("PMVMatrix[modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); - sb.append("], dirty/used[PMv ").append(pmvDirty).append("/").append(pmvUsed).append(", Pmvi ").append(pmviDirty).append("/").append(pmviUsed).append(", Frustum ").append(frustumDirty).append("/").append(frustumUsed); - sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append("]").append(System.lineSeparator()); - sb.append(", Projection").append(System.lineSeparator()); - matP.toString(sb, null, f); - sb.append(", Modelview").append(System.lineSeparator()); - matMv.toString(sb, null, f); - sb.append(", Texture").append(System.lineSeparator()); - matTex.toString(sb, null, f); - if( null != matPMv ) { - sb.append(", P * Mv").append(System.lineSeparator()); - matPMv.toString(sb, null, f); - ++count; - } - if( null != matPMvi ) { - sb.append(", P * Mv").append(System.lineSeparator()); - matPMvi.toString(sb, null, f); - ++count; - } - if( mviReq ) { - sb.append(", Inverse Modelview").append(System.lineSeparator()); - matMvi.toString(sb, null, f); - ++count; - } - if( mvitReq ) { - sb.append(", Inverse Transposed Modelview").append(System.lineSeparator()); - matMvit.toString(sb, null, f); - ++count; - } - int tmpCount = 1; - if( null != mat4Tmp2 ) { - ++tmpCount; - } - sb.append(", matrices "+count+" + "+tmpCount+" temp = "+(count+tmpCount)+"]"); - return sb; - } - - @Override - public String toString() { - return toString(null, "%10.5f").toString(); - } - - /** - * Returns the modified bits due to mutable operations.. - * <p> - * A modified bit is set, if the corresponding matrix had been modified by a mutable operation - * since last {@link #update()} or {@link #getModifiedBits(boolean) getModifiedBits(true)} call. - * </p> - * @param clear if true, clears the modified bits, otherwise leaves them untouched. - * - * @see #MODIFIED_PROJECTION - * @see #MODIFIED_MODELVIEW - * @see #MODIFIED_TEXTURE - * @see #getDirtyBits() - * @see #isReqDirty() - */ - public final int getModifiedBits(final boolean clear) { - final int r = modifiedBits; - if(clear) { - modifiedBits = 0; - } - return r; - } - - /** - * Returns the dirty bits due to mutable operations, - * i.e. - * - {@link #INVERSE_MODELVIEW} (if requested) - * - {@link #INVERSE_TRANSPOSED_MODELVIEW} (if requested) - * - {@link #FRUSTUM} (always, cleared via {@link #getFrustum()} - * <p> - * A dirty bit is set, if the corresponding matrix had been modified by a mutable operation - * since last {@link #update()} call and requested in the constructor {@link #PMVMatrix(int)}. - * </p> - * <p> - * {@link #update()} clears the dirty state for the matrices and {@link #getFrustum()} for {@link #FRUSTUM}. - * </p> - * - * @see #isReqDirty() - * @see #INVERSE_MODELVIEW - * @see #INVERSE_TRANSPOSED_MODELVIEW - * @see #FRUSTUM - * @see #PMVMatrix(int) - * @see #getMviMat() - * @see #getMvitMat() - * @see #getSyncPMvMviMat() - * @see #getSyncPMvMviMvitMat() - * @see #getFrustum() - */ - public final int getDirtyBits() { - return dirtyBits; - } - - /** - * Returns true if the one of the {@link #getReqBits() requested bits} are are set dirty due to mutable operations, - * i.e. at least one of - * - {@link #INVERSE_MODELVIEW} - * - {@link #INVERSE_TRANSPOSED_MODELVIEW} - * <p> - * A dirty bit is set, if the corresponding matrix had been modified by a mutable operation - * since last {@link #update()} call and requested in the constructor {@link #PMVMatrix(int)}. - * </p> - * <p> - * {@link #update()} clears the dirty state for the matrices and {@link #getFrustum()} for {@link #FRUSTUM}. - * </p> - * - * @see #INVERSE_MODELVIEW - * @see #INVERSE_TRANSPOSED_MODELVIEW - * @see #PMVMatrix(int) - * @see #getMviMat() - * @see #getMvitMat() - * @see #getSyncPMvMviMat() - * @see #getSyncPMvMviMvitMat() - */ - public final boolean isReqDirty() { - return 0 != ( requestBits & dirtyBits ); - } - - /** - * Returns the request bit mask, which uses bit values equal to the dirty mask - * and may contain - * - {@link #INVERSE_MODELVIEW} - * - {@link #INVERSE_TRANSPOSED_MODELVIEW} - * <p> - * The request bit mask is set by in the constructor {@link #PMVMatrix(int)}. - * </p> - * - * @see #INVERSE_MODELVIEW - * @see #INVERSE_TRANSPOSED_MODELVIEW - * @see #PMVMatrix(int) - * @see #getMviMat() - * @see #getMvitMat() - * @see #getSyncPMvMviMat() - * @see #getSyncPMvMviMvitMat() - * @see #getFrustum() - */ - public final int getReqBits() { - return requestBits; - } - - /** - * Returns the pre-multiplied projection x modelview, P x Mv. - * <p> - * This {@link Matrix4f} instance should be re-fetched via this method and not locally stored - * to have it updated from a potential modification of underlying projection and/or modelview matrix. - * {@link #update()} has no effect on this {@link Matrix4f}. - * </p> - * <p> - * This pre-multipled P x Mv is considered dirty, if its corresponding - * {@link #getPMat() P matrix} or {@link #getMvMat() Mv matrix} has been modified since its last update. - * </p> - * @see #update() - */ - public final Matrix4f getPMvMat() { - if( 0 != ( dirtyBits & PREMUL_PMV ) ) { - if( null == matPMv ) { - matPMv = new Matrix4f(); - } - matPMv.mul(matP, matMv); - dirtyBits &= ~PREMUL_PMV; - } - return matPMv; - } - - /** - * Returns the pre-multiplied inverse projection x modelview, - * if {@link Matrix4f#invert(Matrix4f)} succeeded, otherwise `null`. - * <p> - * This {@link Matrix4f} instance should be re-fetched via this method and not locally stored - * to have it updated from a potential modification of underlying projection and/or modelview matrix. - * {@link #update()} has no effect on this {@link Matrix4f}. - * </p> - * <p> - * This pre-multipled invert(P x Mv) is considered dirty, if its corresponding - * {@link #getPMat() P matrix} or {@link #getMvMat() Mv matrix} has been modified since its last update. - * </p> - * @see #update() - */ - public final Matrix4f getPMviMat() { - if( 0 != ( dirtyBits & PREMUL_PMVI ) ) { - if( null == matPMvi ) { - matPMvi = new Matrix4f(); - } - final Matrix4f mPMv = getPMvMat(); - matPMviOK = matPMvi.invert(mPMv); - dirtyBits &= ~PREMUL_PMVI; - } - return matPMviOK ? matPMvi : null; - } - - /** - * Returns the frustum, derived from projection x modelview. - * <p> - * This {@link Frustum} instance should be re-fetched via this method and not locally stored - * to have it updated from a potential modification of underlying projection and/or modelview matrix. - * {@link #update()} has no effect on this {@link Frustum}. - * </p> - * <p> - * The {@link Frustum} is considered dirty, if its corresponding - * {@link #getPMat() P matrix} or {@link #getMvMat() Mv matrix} has been modified since its last update. - * </p> - * @see #update() - */ - public final Frustum getFrustum() { - if( 0 != ( dirtyBits & FRUSTUM ) ) { - if( null == frustum ) { - frustum = new Frustum(); - } - final Matrix4f mPMv = getPMvMat(); - frustum.updateFrustumPlanes(mPMv); - dirtyBits &= ~FRUSTUM; - } - return frustum; - } - - /** - * Update the derived {@link #getMviMat() inverse modelview (Mvi)}, - * {@link #getMvitMat() inverse transposed modelview (Mvit)} matrices - * <b>if</b> they {@link #isReqDirty() are dirty} <b>and</b> - * requested via the constructor {@link #PMVMatrix(int)}.<br/> - * Hence updates the following dirty bits. - * - {@link #INVERSE_MODELVIEW} - * - {@link #INVERSE_TRANSPOSED_MODELVIEW} - * <p> - * The {@link Frustum} is updated only via {@link #getFrustum()} separately. - * </p> - * <p> - * The Mvi and Mvit matrices are considered dirty, if their corresponding - * {@link #getMvMat() Mv matrix} has been modified since their last update. - * </p> - * <p> - * Method is automatically called by {@link SyncMatrix4f} and {@link SyncMatrices4f} - * instances {@link SyncAction} as retrieved by e.g. {@link #getSyncMvitMat()}. - * This ensures an automatic update cycle if used with {@link GLUniformData}. - * </p> - * <p> - * Method may be called manually in case mutable operations has been called - * and caller operates on already fetched references, i.e. not calling - * {@link #getMviMat()}, {@link #getMvitMat()} anymore. - * </p> - * <p> - * Method clears the modified bits like {@link #getModifiedBits(boolean) getModifiedBits(true)}, - * which are set by any mutable operation. The modified bits have no impact - * on this method, but the return value. - * </p> - * - * @return true if any matrix has been modified since last update call or - * if the derived matrices Mvi and Mvit were updated, otherwise false. - * In other words, method returns true if any matrix used by the caller must be updated, - * e.g. uniforms in a shader program. - * - * @see #getModifiedBits(boolean) - * @see #isReqDirty() - * @see #INVERSE_MODELVIEW - * @see #INVERSE_TRANSPOSED_MODELVIEW - * @see #PMVMatrix(int) - * @see #getMviMat() - * @see #getMvitMat() - * @see #getSyncPMvMviMat() - * @see #getSyncPMvMviMvitMat() - */ - public final boolean update() { - return updateImpl(true); - } - // // private // - private final boolean updateImpl(final boolean clearModBits) { - boolean mod = 0 != modifiedBits; - if( clearModBits ) { - modifiedBits = 0; - } - if( 0 != ( requestBits & ( ( dirtyBits & ( INVERSE_MODELVIEW | INVERSE_TRANSPOSED_MODELVIEW ) ) ) ) ) { // only if dirt requested & dirty - if( !matMvi.invert(matMv) ) { - throw new GLException(msgCantComputeInverse); - } - dirtyBits &= ~INVERSE_MODELVIEW; - mod = true; - } - if( 0 != ( requestBits & ( dirtyBits & INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - matMvit.transpose(matMvi); - dirtyBits &= ~INVERSE_TRANSPOSED_MODELVIEW; - mod = true; - } - return mod; - } - private static final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse"; - - private final Matrix4f matP; - private final Matrix4f matMv; - private final Matrix4f matTex; - - private final Matrix4f matMvi; - private final Matrix4f matMvit; - - private static final int mP_offset = 0*16; - private static final int mMv_offset = 1*16; - private final int mMvi_offset; - private final int mMvit_offset; - private final int mTex_offset; - - private final float[] matrixStore; - - private final FloatBuffer bufP, bufMv, bufTex; - private final FloatBuffer bufMvi, bufMvit; - private final FloatBuffer bufP_Mv, bufP_Mv_Mvi, bufP_Mv_Mvi_Mvit; - - private final SyncMatrix4f syncP, syncMv, syncT; - private final SyncMatrix4f syncMvi, syncMvit; - private final SyncMatrices4f syncP_Mv, syncP_Mv_Mvi, syncP_Mv_Mvi_Mvit; - - private final Matrix4f mat4Tmp1; - private int matrixMode = GL_MODELVIEW; - private int modifiedBits = MODIFIED_ALL; - private int dirtyBits = 0; // contains the dirty bits, i.e. hinting for update operation - private final int requestBits; // may contain the requested bits: INVERSE_MODELVIEW | INVERSE_TRANSPOSED_MODELVIEW - private Matrix4f mat4Tmp2; - private Matrix4f matPMv; - private Matrix4f matPMvi; - private boolean matPMviOK; - private Frustum frustum; - - private abstract class PMVSyncBuffer implements SyncMatrix4f { - protected final Matrix4f mat; - private final FloatBuffer fbuf; - - public PMVSyncBuffer(final Matrix4f m, final FloatBuffer fbuf) { - this.mat = m; - this.fbuf = fbuf; - } - - @Override - public final Buffer getBuffer() { return fbuf; } - - @Override - public final SyncBuffer sync() { getAction().sync(); return this; } - - @Override - public final Buffer getSyncBuffer() { getAction().sync(); return fbuf; } - - @Override - public final Matrix4f getMatrix() { return mat; } - - @Override - public final FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; } - } - private final class SyncBuffer0 extends PMVSyncBuffer { - private final SyncAction action = new SyncAction() { - @Override - public void sync() { mat.get(matrixStore); } - }; - - public SyncBuffer0(final Matrix4f m, final FloatBuffer fbuf) { super(m, fbuf); } - - @Override - public SyncAction getAction() { return action; } - - } - private final class SyncBuffer1 extends PMVSyncBuffer { - private final int offset; - private final SyncAction action = new SyncAction() { - @Override - public void sync() { mat.get(matrixStore, offset); } - }; - - public SyncBuffer1(final Matrix4f m, final FloatBuffer fbuf, final int offset) { - super(m, fbuf); - this.offset = offset; - } - - @Override - public SyncAction getAction() { return action; } - } - private final class SyncBuffer1U extends PMVSyncBuffer { - private final int offset; - private final SyncAction action = new SyncAction() { - @Override - public void sync() { - updateImpl(true); - mat.get(matrixStore, offset); - } - }; - - public SyncBuffer1U(final Matrix4f m, final FloatBuffer fbuf, final int offset) { - super(m, fbuf); - this.offset = offset; - } - - @Override - public SyncAction getAction() { return action; } - } - - private abstract class PMVSyncBufferN implements SyncMatrices4f { - protected final Matrix4f[] mats; - private final FloatBuffer fbuf; - - public PMVSyncBufferN(final Matrix4f[] ms, final FloatBuffer fbuf) { - this.mats = ms; - this.fbuf = fbuf; - } - - @Override - public final Buffer getBuffer() { return fbuf; } - - @Override - public final SyncBuffer sync() { getAction().sync(); return this; } - - @Override - public final Buffer getSyncBuffer() { getAction().sync(); return fbuf; } - - @Override - public Matrix4f[] getMatrices() { return mats; } - - @Override - public final FloatBuffer getSyncFloats() { getAction().sync(); return fbuf; } - } - private final class SyncBufferN extends PMVSyncBufferN { - private final int offset; - private final SyncAction action = new SyncAction() { - @Override - public void sync() { - int ioff = offset; - for(int i=0; i<mats.length; ++i, ioff+=16) { - mats[i].get(matrixStore, ioff); - } - } - }; - - public SyncBufferN(final Matrix4f[] ms, final FloatBuffer fbuf, final int offset) { - super(ms, fbuf); - this.offset = offset; - } - - @Override - public SyncAction getAction() { return action; } - } - private final class SyncBufferNU extends PMVSyncBufferN { - private final int offset; - private final SyncAction action = new SyncAction() { - @Override - public void sync() { - updateImpl(true); - int ioff = offset; - for(int i=0; i<mats.length; ++i, ioff+=16) { - mats[i].get(matrixStore, ioff); - } - } - }; - - public SyncBufferNU(final Matrix4f[] ms, final FloatBuffer fbuf, final int offset) { - super(ms, fbuf); - this.offset = offset; - } - - @Override - public SyncAction getAction() { return action; } - } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java index 37bca895a..e6549baba 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java @@ -4,6 +4,7 @@ package com.jogamp.opengl.util.glsl.fixedfunc; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES1; import com.jogamp.opengl.GL2ES2; @@ -66,7 +67,7 @@ public class FixedFuncUtil { * @see ShaderSelectionMode#COLOR_TEXTURE * @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX */ - public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) { + public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix) { return wrapFixedFuncEmul(gl, mode, null, false, false); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java index e0f465da7..c6c968415 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java @@ -27,8 +27,8 @@ */ package com.jogamp.opengl.util.stereo; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; /** * Constant single eye parameter of the viewer, relative to its {@link ViewerPose}. diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/LocationSensorParameter.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/LocationSensorParameter.java index 6294adee1..2634535aa 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/LocationSensorParameter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/LocationSensorParameter.java @@ -27,8 +27,8 @@ */ package com.jogamp.opengl.util.stereo; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.geom.Frustum; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.geom.Frustum; /** * Constant parameter of the positioning sensor to locate the {@link ViewerPose}. diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java index 85e752302..538152f7a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java @@ -27,14 +27,13 @@ */ package com.jogamp.opengl.util.stereo; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.PointImmutable; import jogamp.opengl.Debug; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; - /** * Interface describing a native stereoscopic device */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java index 0d6539634..624a1984c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java @@ -27,12 +27,11 @@ */ package com.jogamp.opengl.util.stereo; +import com.jogamp.math.FovHVHalves; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.RectangleImmutable; import com.jogamp.opengl.GL; -import com.jogamp.opengl.math.FovHVHalves; - /** * Stereoscopic device rendering interface. * <p> @@ -175,7 +174,7 @@ public interface StereoDeviceRenderer { * <p> * In case the renderer does not support multiple textures for post-processing, * or no post-processing at all, method returns zero despite the request - * from {@link StereoDevice#createRenderer(int, int, float[], com.jogamp.opengl.math.FovHVHalves[], float)}. + * from {@link StereoDevice#createRenderer(int, int, float[], com.jogamp.math.FovHVHalves[], float)}. * </p> */ public int getTextureCount(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java index 59f38f2af..9108a0723 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java @@ -27,10 +27,9 @@ */ package com.jogamp.opengl.util.stereo; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; - -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.util.CustomGLEventListener; /** @@ -65,7 +64,7 @@ public interface StereoGLEventListener extends CustomGLEventListener { * @param height viewport height in pixel units * @param eyeParam constant eye parameter, i.e. FOV and IPD * @param viewerPose current viewer position and orientation - * @see FloatUtil#makePerspective(float[], int, boolean, com.jogamp.opengl.math.FloatUtil.FovHVHalves, float, float) + * @see FloatUtil#makePerspective(float[], int, boolean, com.jogamp.math.FloatUtil.FovHVHalves, float, float) */ public void reshapeForEye(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height, final EyeParameter eyeParam, final ViewerPose viewerPose); diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java index 63cb3e1e7..404c80d23 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java @@ -27,9 +27,9 @@ */ package com.jogamp.opengl.util.stereo; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.stereo.StereoDeviceRenderer.Eye; diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java index 5d2cf925c..7c116a019 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java @@ -27,8 +27,8 @@ */ package com.jogamp.opengl.util.stereo; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; /** * {@link #position} and {@link #orientation} of viewer. diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java index 0cdef8770..a25e923dc 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java @@ -31,11 +31,11 @@ import jogamp.opengl.util.stereo.DistortionMesh; import jogamp.opengl.util.stereo.GenericStereoDevice; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.stereo.EyeParameter; import com.jogamp.opengl.util.stereo.StereoDevice; import com.jogamp.opengl.util.stereo.StereoDeviceConfig; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index 52c674342..73af4603d 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -41,13 +41,13 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.SyncMatrices4f16; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLArrayDataServer; -import com.jogamp.opengl.util.SyncMatrices4f16; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; @@ -288,7 +288,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { drawView.setWidth(vpWidth); drawView.setHeight(vpHeight); - box.mapToWindow(drawWinBox, renderer.getMatrix().getPMvMat(), drawView, true /* useCenterZ */); + box.mapToWindow(drawWinBox, renderer.getMatrix().getPMv(), drawView, true /* useCenterZ */); winWidth = drawWinBox.getWidth(); winHeight = drawWinBox.getHeight(); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index d8e8166b3..9fad72881 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -43,14 +43,14 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.SyncMatrices4f16; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.FBObject.TextureAttachment; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLArrayDataServer; -import com.jogamp.opengl.util.SyncMatrices4f16; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; @@ -322,7 +322,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { drawView.setWidth(vpWidth); drawView.setHeight(vpHeight); - box.mapToWindow(drawWinBox, renderer.getMatrix().getPMvMat(), drawView, true /* useCenterZ */); + box.mapToWindow(drawWinBox, renderer.getMatrix().getPMv(), drawView, true /* useCenterZ */); winWidth = drawWinBox.getWidth(); winHeight = drawWinBox.getHeight(); diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index e187b1590..b7fee25e5 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -35,9 +35,9 @@ import com.jogamp.graph.curve.tess.Triangulator; import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.plane.Winding; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.math.Vec2f; +import com.jogamp.math.VectorUtil; +import com.jogamp.math.geom.plane.Winding; import jogamp.opengl.Debug; diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java index 86edf7d61..32f526f3b 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java @@ -30,9 +30,9 @@ package jogamp.graph.curve.tess; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; +import com.jogamp.math.VectorUtil; /** * Experimental Add-On .. diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java index 275abda23..396c541ab 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java @@ -30,7 +30,7 @@ package jogamp.graph.curve.tess; import java.util.ArrayList; import com.jogamp.graph.geom.Vertex; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.Vec3f; public class GraphVertex { private Vertex point; diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java index 6020e7c66..a27540878 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java @@ -31,11 +31,11 @@ import java.util.ArrayList; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.plane.Winding; +import com.jogamp.math.Vec3f; +import com.jogamp.math.VectorUtil; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.Winding; import com.jogamp.graph.geom.Triangle; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.math.geom.AABBox; public class Loop { private HEdge root = null; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index b153b813e..a8651389c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -31,8 +31,8 @@ import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; import jogamp.graph.font.typecast.ot.OTFontCollection; import jogamp.graph.font.typecast.ot.TTFont; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java index 3ace5c480..fa8271088 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java @@ -29,7 +29,7 @@ package jogamp.graph.font.typecast; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.font.Font; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; import jogamp.graph.font.typecast.ot.table.KernSubtable; import jogamp.graph.font.typecast.ot.table.KerningPair; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java index 11f1ce7c7..900747f01 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java @@ -31,7 +31,7 @@ import jogamp.graph.font.typecast.ot.table.HeadTable; import jogamp.graph.font.typecast.ot.table.HheaTable; import com.jogamp.graph.font.Font.Metrics; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; final class TypecastHMetrics implements Metrics { private final TypecastFont fontImpl; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index 816be92b2..248e023ed 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -34,7 +34,7 @@ import jogamp.opengl.Debug; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.geom.Vertex; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; /** * Factory to build an {@link OutlineShape} from diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/Glyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/Glyph.java index 5bb610a1c..2c4394317 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/Glyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/Glyph.java @@ -18,7 +18,7 @@ package jogamp.graph.font.typecast.ot; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; /** * An individual glyph within a font. diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/T2Glyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/T2Glyph.java index 9df937121..b8c0c4900 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/T2Glyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/T2Glyph.java @@ -17,7 +17,7 @@ */ package jogamp.graph.font.typecast.ot; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; import jogamp.graph.font.typecast.cff.CharstringType2; import jogamp.graph.font.typecast.cff.T2Interpreter; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/TTGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/TTGlyph.java index 5e0f83a33..d5f9eedc5 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/TTGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/TTGlyph.java @@ -17,7 +17,7 @@ */ package jogamp.graph.font.typecast.ot; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; import jogamp.graph.font.typecast.ot.table.GlyfDescript; import jogamp.graph.font.typecast.ot.table.GlyphDescription; diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index cc4640534..991a57a4d 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -118,11 +118,10 @@ package jogamp.opengl; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.GLException; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; - /** * ProjectFloat.java * <p> diff --git a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java index afd6ba204..4415f2c9e 100644 --- a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java +++ b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java @@ -115,11 +115,10 @@ package jogamp.opengl.glu; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.GL; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.glu.GLUquadric; - -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.util.ImmModeSink; import com.jogamp.opengl.util.glsl.ShaderState; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 2fb690747..a308c0597 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -58,7 +58,6 @@ import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.Debug; @@ -76,8 +75,8 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GLRendererQuirks; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; @@ -199,12 +198,10 @@ public class MacOSXCGLContext extends GLContextImpl sp.useProgram(gl, true); // setup mgl_PMVMatrix - final PMVMatrix pmvMatrix = new PMVMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmvMatrix.glLoadIdentity(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + final PMVMatrix4f pmvMatrix = new PMVMatrix4f(); + pmvMatrix.loadPIdentity(); + pmvMatrix.loadMvIdentity(); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv pmvMatrixUniform.setLocation(gl, sp.program()); gl.glUniform(pmvMatrixUniform); diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 94b666b7b..7d517c2d6 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -1459,6 +1459,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { isBlocked = false; } catch (final Throwable t) { streamErr = new StreamException(t.getClass().getSimpleName()+" while decoding: "+GLMediaPlayerImpl.this.toString(), t); + isBlocked = false; } finally { if( null != nextFrame ) { // put back videoFramesFree.put(nextFrame); diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java index 72c7c257f..e39def369 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java @@ -31,23 +31,21 @@ package jogamp.opengl.util.glsl; import java.nio.FloatBuffer; import com.jogamp.opengl.util.GLArrayDataServer; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; - +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLArrayData; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLUniformData; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; public class GLSLTextureRaster { private final boolean textureVertFlipped; private final int textureUnit; private ShaderProgram sp; - private PMVMatrix pmvMatrix; + private PMVMatrix4f pmvMatrix; private GLUniformData pmvMatrixUniform; private GLUniformData activeTexUniform; private GLArrayDataServer interleavedVBO; @@ -82,12 +80,10 @@ public class GLSLTextureRaster { sp.useProgram(gl, true); // setup mgl_PMVMatrix - pmvMatrix = new PMVMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmvMatrix.glLoadIdentity(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrix = new PMVMatrix4f(); + pmvMatrix.loadPIdentity(); + pmvMatrix.loadMvIdentity(); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv if( pmvMatrixUniform.setLocation(gl, sp.program()) < 0 ) { throw new GLException("Couldn't locate "+pmvMatrixUniform+" in shader: "+sp); } @@ -130,12 +126,10 @@ public class GLSLTextureRaster { public void reshape(final GL2ES2 gl, final int x, final int y, final int width, final int height) { if(null != sp) { - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmvMatrix.glLoadIdentity(); - pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + pmvMatrix.loadPIdentity(); + pmvMatrix.orthoP(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); + pmvMatrix.loadMvIdentity(); sp.useProgram(gl, true); gl.glUniform(pmvMatrixUniform); diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java index 998406856..fb2bf1bdc 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java @@ -43,6 +43,7 @@ import com.jogamp.opengl.fixedfunc.GLPointerFunc; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.ValueConv; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.util.GLArrayDataWrapper; import com.jogamp.opengl.util.GLBuffers; import com.jogamp.opengl.util.PMVMatrix; @@ -70,7 +71,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun this.pmvMatrix = pmvMatrix; } else { this.ownsPMVMatrix = true; - this.pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + this.pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); } fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix); } @@ -91,7 +92,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun this.pmvMatrix = pmvMatrix; } else { this.ownsPMVMatrix = true; - this.pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + this.pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); } fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot, @@ -109,7 +110,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun gl=null; } - public PMVMatrix getMatrix() { return pmvMatrix; } + public PMVMatrix4f getMatrix() { return pmvMatrix; } // // FixedFuncHookIf - hooks diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index c9e2664ba..a4b5e9afd 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -54,9 +54,9 @@ import jogamp.opengl.Debug; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IntIntHashMap; import com.jogamp.common.util.PropertyAccess; -import com.jogamp.opengl.util.PMVMatrix; -import com.jogamp.opengl.util.SyncBuffer; -import com.jogamp.opengl.util.SyncMatrices4f; +import com.jogamp.math.util.PMVMatrix4f; +import com.jogamp.math.util.SyncBuffer; +import com.jogamp.math.util.SyncMatrices4f; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; @@ -82,7 +82,7 @@ public class FixedFuncPipeline { public static final int MAX_TEXTURE_UNITS = 8; public static final int MAX_LIGHTS = 8; - public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) { + public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix) { shaderRootClass = FixedFuncPipeline.class; shaderSrcRoot = shaderSrcRootDef; shaderBinRoot = shaderBinRootDef; @@ -92,7 +92,7 @@ public class FixedFuncPipeline { fragmentColorTextureFile = fragmentColorTextureFileDef; init(gl, mode, pmvMatrix); } - public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix, + public FixedFuncPipeline(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix, final Class<?> shaderRootClass, final String shaderSrcRoot, final String shaderBinRoot, final String vertexColorFile, final String vertexColorLightFile, @@ -820,9 +820,9 @@ public class FixedFuncPipeline { final SyncMatrices4f m; if(ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX == currentShaderSelectionMode || ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) { - m = pmvMatrix.getSyncPMvMviMvitMat(); + m = pmvMatrix.getSyncPMvMviMvit(); } else { - m = pmvMatrix.getSyncPMvMat(); + m = pmvMatrix.getSyncPMv(); } if(m != ud.getBuffer()) { ud.setData(m); @@ -1102,7 +1102,7 @@ public class FixedFuncPipeline { return sp; } - private void init(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) { + private void init(final GL2ES2 gl, final ShaderSelectionMode mode, final PMVMatrix4f pmvMatrix) { if(null==pmvMatrix) { throw new GLException("PMVMatrix is null"); } @@ -1114,7 +1114,7 @@ public class FixedFuncPipeline { shaderState.attachShaderProgram(gl, selectShaderProgram(gl, requestedShaderSelectionMode), true); // mandatory .. - if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.getSyncPMvMviMvitMat()))) { + if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.getSyncPMvMviMvit()))) { throw new GLException("Error setting PMVMatrix in shader: "+this); } @@ -1202,7 +1202,7 @@ public class FixedFuncPipeline { /** ( pointSize, pointSmooth, attn. pointMinSize, attn. pointMaxSize ) , ( attenuation coefficients 1f 0f 0f, attenuation fade theshold 1f ) */ private final FloatBuffer pointParams = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f }); - private PMVMatrix pmvMatrix; + private PMVMatrix4f pmvMatrix; private ShaderState shaderState; private ShaderProgram shaderProgramColor; private ShaderProgram shaderProgramColorTexture2, shaderProgramColorTexture4, shaderProgramColorTexture8; diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java index 60adc7d74..89765e4f6 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java @@ -27,14 +27,14 @@ */ package jogamp.opengl.util.stereo; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.Point; import com.jogamp.nativewindow.util.PointImmutable; import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.nativewindow.util.RectangleImmutable; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.stereo.StereoDeviceConfig; import com.jogamp.opengl.util.stereo.EyeParameter; import com.jogamp.opengl.util.stereo.LocationSensorParameter; diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java index 3c6f5e37e..3a3ead790 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java @@ -44,8 +44,8 @@ import jogamp.common.os.PlatformPropsImpl; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java b/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java index 1fed69363..f7a5a5e9b 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/ScaleAndOffset2D.java @@ -27,12 +27,11 @@ */ package jogamp.opengl.util.stereo; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.VectorUtil; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.RectangleImmutable; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.VectorUtil; - /** * 2D scale and offset NDC class, * providing conversion from {@link FovHVHalves} in tangent to NDC space. diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java index d5567b1d8..06158a033 100644 --- a/src/newt/classes/jogamp/newt/MonitorModeProps.java +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -29,6 +29,7 @@ package jogamp.newt; import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; import com.jogamp.newt.Screen; @@ -41,7 +42,6 @@ import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.nativewindow.util.SurfaceSize; -import com.jogamp.opengl.math.FloatUtil; import jogamp.newt.MonitorDeviceImpl; import jogamp.newt.ScreenImpl; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index a19218ead..75c1e9474 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -74,6 +74,7 @@ import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.Display; import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.MonitorDevice; @@ -90,7 +91,6 @@ import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseEvent.PointerType; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.NEWTEventConsumer; diff --git a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java index 234ee187c..f617ffc04 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java @@ -36,10 +36,10 @@ import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.Display; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; -import com.jogamp.opengl.math.FloatUtil; public class ScreenDriver extends ScreenImpl { diff --git a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java index 280adf71a..454b2200f 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java @@ -29,6 +29,7 @@ package jogamp.newt.driver.ios; import com.jogamp.common.util.InterruptSource; +import com.jogamp.math.FloatUtil; import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.GraphicsConfigurationFactory; import com.jogamp.nativewindow.NativeWindow; @@ -51,7 +52,6 @@ import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MouseEvent; -import com.jogamp.opengl.math.FloatUtil; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index 8cb900abd..ec661e5f6 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -42,10 +42,10 @@ import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.Display; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; -import com.jogamp.opengl.math.FloatUtil; public class ScreenDriver extends ScreenImpl { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 9aab8d285..79951e5a6 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -35,6 +35,7 @@ package jogamp.newt.driver.macosx; import com.jogamp.common.util.InterruptSource; +import com.jogamp.math.FloatUtil; import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.GraphicsConfigurationFactory; import com.jogamp.nativewindow.NativeWindow; @@ -58,7 +59,6 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MonitorEvent; -import com.jogamp.opengl.math.FloatUtil; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java index 335123bb9..a59b8248f 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java @@ -27,6 +27,9 @@ */ package jogamp.opengl.oculusvr; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.Frustum; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.PointImmutable; @@ -39,9 +42,6 @@ import com.jogamp.oculusvr.ovrFovPort; import com.jogamp.oculusvr.ovrHmdDesc; import com.jogamp.oculusvr.ovrSizei; import com.jogamp.oculusvr.ovrTrackingState; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.Frustum; import com.jogamp.opengl.util.stereo.LocationSensorParameter; import com.jogamp.opengl.util.stereo.StereoDevice; import com.jogamp.opengl.util.stereo.StereoDeviceFactory; diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java index 1430a9c45..a6671f6b6 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java @@ -42,6 +42,8 @@ import com.jogamp.opengl.GLUniformData; import jogamp.common.os.PlatformPropsImpl; import com.jogamp.common.nio.Buffers; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Vec3f; import com.jogamp.oculusvr.OVR; import com.jogamp.oculusvr.OVRException; import com.jogamp.oculusvr.ovrDistortionMesh; @@ -58,8 +60,6 @@ import com.jogamp.oculusvr.ovrTrackingState; import com.jogamp.oculusvr.ovrVector2f; import com.jogamp.oculusvr.ovrVector3f; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRUtil.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRUtil.java index e54bd61e8..9a439a386 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRUtil.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRUtil.java @@ -27,6 +27,8 @@ */ package jogamp.opengl.oculusvr; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Quaternion; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.Point; @@ -42,8 +44,6 @@ import com.jogamp.oculusvr.ovrSizei; import com.jogamp.oculusvr.ovrVector2f; import com.jogamp.oculusvr.ovrVector2i; import com.jogamp.oculusvr.ovrVector3f; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Quaternion; import com.jogamp.opengl.util.stereo.StereoDevice; import com.jogamp.opengl.util.stereo.StereoDeviceRenderer; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java index 684e0c78a..dcbb0b123 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java @@ -37,12 +37,12 @@ import com.jogamp.graph.ui.layout.Gap; import com.jogamp.graph.ui.layout.GridLayout; import com.jogamp.graph.ui.shapes.GlyphShape; import com.jogamp.graph.ui.shapes.Rectangle; +import com.jogamp.math.geom.AABBox; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.math.geom.AABBox; /** * Glyph Grid using GraphUI diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java index 42ee9d2c0..1146d7a5f 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener01.java @@ -31,15 +31,14 @@ package com.jogamp.opengl.test.junit.graph; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.Vec4f; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.geom.plane.Path2F; -import com.jogamp.graph.geom.plane.WindingRule; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.plane.Path2F; +import com.jogamp.math.geom.plane.WindingRule; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.opengl.util.PMVMatrix; /** Demonstrate the rendering of multiple outlines into one region/OutlineShape * These Outlines are not necessary connected or contained. @@ -282,11 +281,10 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java index 716c9f2e7..78d17624c 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPURegionGLListener10.java @@ -35,14 +35,13 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.opengl.util.PMVMatrix; /** Demonstrate the rendering of multiple OutlineShapes * into one region @@ -123,11 +122,10 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { final RegionRenderer regionRenderer = getRenderer(); - final PMVMatrix pmv = regionRenderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + final PMVMatrix4f pmv = regionRenderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); if( weight != regionRenderer.getWeight() ) { regionRenderer.setWeight(weight); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java index 7d14dcf17..2eac05555 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPURendererListenerBase01.java @@ -39,23 +39,22 @@ import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.font.FontScale; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** * @@ -110,7 +109,8 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { public final float getZTran() { return zTran; } public final float getXTran() { return xTran; } public final float getYTran() { return yTran; } - public final float getAngle() { return ang; } + public final float getAngleDeg() { return ang; } + public final float getAngleRad() { return FloatUtil.adegToRad(ang); } public final int[] getSampleCount() { return sampleCount; } public final float[] getPosition() { return position; } @@ -149,20 +149,19 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { getRenderer().init(gl); } - public static void mapWin2ObjectCoords(final PMVMatrix pmv, final Recti view, + public static void mapWin2ObjectCoords(final PMVMatrix4f pmv, final Recti view, final float zNear, final float zFar, final float orthoX, final float orthoY, final float orthoDist, final float[] winZ, final Vec3f objPos) { winZ[0] = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar); - pmv.gluUnProject(orthoX, orthoY, winZ[0], view, objPos); + pmv.mapWinToObj(orthoX, orthoY, winZ[0], view, objPos); } @Override public void reshape(final GLAutoDrawable drawable, final int xstart, final int ystart, final int width, final int height) { - final PMVMatrix pmv = renderer.getMatrix(); + final PMVMatrix4f pmv = renderer.getMatrix(); renderer.reshapePerspective(FloatUtil.QUARTER_PI, width, height, zNear, zFar); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + pmv.loadMvIdentity(); System.err.printf("Reshape: zNear %f, zFar %f%n", zNear, zFar); System.err.printf("Reshape: Frustum: %s%n", pmv.getFrustum()); { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java index b6391b1cf..32db14340 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/GPUTextRendererListenerBase01.java @@ -35,7 +35,6 @@ import com.jogamp.opengl.GLAnimatorControl; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; @@ -46,13 +45,13 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; /** * @@ -301,9 +300,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB // final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; final RegionRenderer renderer = getRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); renderer.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); final float pixelSizeFName = FontScale.toPixels(fontSizeFName, dpiV); final float pixelSizeHead = FontScale.toPixels(fontSizeHead, dpiV); @@ -314,7 +312,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB renderer.enable(gl, true); if( drawFPS ) { - pmv.glPushMatrix(); + pmv.pushMv(); final float pixelSizeFPS = FontScale.toPixels(fontSizeFPS, dpiV); final float lfps, tfps; final GLAnimatorControl animator = drawable.getAnimator(); @@ -335,58 +333,58 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB drawable.getChosenGLCapabilities().getAlphaBits()); // bottom, half line up - pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); + pmv.translateMv(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeFPS; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // No cache, keep region alive! TextRegionUtil.drawString3D(gl, regionFPS.clear(gl), renderer, font, text, null, sampleCountFPS, tempT1, tempT2); - pmv.glPopMatrix(); + pmv.popMv(); } // float dx = width - ( fontNameBox.getWidth() + font.getAdvanceWidth( Glyph.ID_SPACE ) ) * pixelSizeFName; float dx = width - ( fontNameBox.getWidth() + 2 * font.getAdvanceWidth( font.getGlyphID('X') ) ) * pixelSizeFName; float dy = height - fontNameBox.getHeight() * pixelSizeFName; { - pmv.glPushMatrix(); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.pushMv(); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeFName; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // System.err.printf("FontN: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); textRegionUtil.drawString3D(gl, renderer, font, fontName, null, getSampleCount()); - pmv.glPopMatrix(); + pmv.popMv(); } dx = 10f; dy += -fontNameBox.getHeight() * pixelSizeFName - 10f; if(null != headtext) { - pmv.glPushMatrix(); + pmv.pushMv(); // System.err.printf("Head: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); { final float sxy = nearPlaneS * pixelSizeHead; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } // pmv.glTranslatef(x0, y1, z0); textRegionUtil.drawString3D(gl, renderer, font, headtext, null, getSampleCount()); - pmv.glPopMatrix(); + pmv.popMv(); } dy += ( -headbox.getHeight() - font.getLineHeight() ) * pixelSizeCenter; { - pmv.glPushMatrix(); - pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); + pmv.pushMv(); + pmv.translateMv(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0); // System.err.printf("Bottom: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy)); - pmv.glTranslatef(getXTran(), getYTran(), getZTran()); - pmv.glRotatef(getAngle(), 0, 1, 0); + pmv.translateMv(getXTran(), getYTran(), getZTran()); + pmv.rotateMv(getAngleRad(), 0, 1, 0); { final float sxy = nearPlaneS * pixelSizeCenter; - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } renderer.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f); @@ -406,7 +404,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRegionUtil.drawString3D(gl, renderer, font, userString.toString(), null, getSampleCount()); } } - pmv.glPopMatrix(); + pmv.popMv(); } renderer.enable(gl, false); } @@ -487,7 +485,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB public boolean isUserInputMode() { return userInput; } void dumpMatrix(final boolean bbox) { - System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngle() +" fontSize "+fontSizeCenter); + System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngleDeg() +" fontSize "+fontSizeCenter); if(bbox) { System.err.println("bbox em: "+font.getMetricBounds(text2)); System.err.println("bbox px: "+font.getMetricBounds(text2).scale(nearPlaneS * FontScale.toPixels(fontSizeCenter, dpiV))); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java index 9b487a2f0..b5fe23920 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java @@ -42,7 +42,6 @@ import com.jogamp.opengl.GLDrawable; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.os.Clock; import com.jogamp.common.util.IOUtil; @@ -54,13 +53,13 @@ import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** @@ -305,11 +304,10 @@ public class PerfTextRendererNEWT00 { final float dx = 0; final float dy = drawable.getSurfaceHeight() - 2 * fontScale * font.getLineHeight(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(dx, dy, z0); - pmv.glScalef(fontScale, fontScale, 1f); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(dx, dy, z0); + pmv.scaleMv(fontScale, fontScale, 1f); region.draw(gl, renderer, sampleCountIO); final long t5 = Clock.currentNanos(); // text added to region if( null != perf ) { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestFontScale01NOUI.java b/src/test/com/jogamp/opengl/test/junit/graph/TestFontScale01NOUI.java index ad6355d8a..4500aae36 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestFontScale01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestFontScale01NOUI.java @@ -29,8 +29,7 @@ package com.jogamp.opengl.test.junit.graph; import com.jogamp.graph.font.FontScale; import com.jogamp.junit.util.JunitTracer; - -import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.math.FloatUtil; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java index afdecfaca..6516b2b1b 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java @@ -36,8 +36,8 @@ import org.junit.runners.MethodSorters; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontScale; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.geom.AABBox; import com.jogamp.opengl.test.junit.util.UITestCase; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java index 80bb95d05..bf99aedee 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java @@ -37,7 +37,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLDrawable; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import org.junit.Assert; import org.junit.BeforeClass; @@ -54,12 +53,12 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; /** @@ -253,11 +252,10 @@ public class TestTextRendererNEWT01 extends UITestCase { dx += fontSize * font.getAdvanceWidth('X') * column; dy -= fontSize * textBox.getHeight() * ( row + 1 ); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(dx, dy, z0); - pmv.glScalef(fontSize, fontSize, 1.0f); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(dx, dy, z0); + pmv.scaleMv(fontSize, fontSize, 1.0f); textRenderUtil.drawString3D(gl, renderer, font, text, null, sampleCount); lastRow = row; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java index 41b556186..ae17e7821 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java @@ -37,7 +37,6 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLDrawable; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import org.junit.Assert; import org.junit.Test; @@ -49,11 +48,11 @@ import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; -import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -195,13 +194,12 @@ public class TestTextRendererNEWTBugXXXX extends UITestCase { dx += fontSize * font.getAdvanceWidth('X') * column; dy -= fontSize * textBox.getHeight() * ( row + 1 ); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(dx, dy, z0); + final PMVMatrix4f pmv = renderer.getMatrix(); + pmv.loadMvIdentity(); + pmv.translateMv(dx, dy, z0); { final float sxy = fontSize / font.getMetrics().getUnitsPerEM(); - pmv.glScalef(sxy, sxy, 1.0f); + pmv.scaleMv(sxy, sxy, 1.0f); } textRenderUtil.drawString3D(gl, renderer, font, text, null, sampleCount); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java index 8e90d88eb..b09a5c2ab 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java @@ -32,7 +32,6 @@ import java.io.IOException; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; @@ -42,9 +41,9 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontScale; import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.math.geom.plane.AffineTransform; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; -import com.jogamp.opengl.util.PMVMatrix; public abstract class TextRendererGLELBase implements GLEventListener { public final int renderModes; @@ -53,7 +52,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { protected final float[] staticRGBAColor = new float[] { 1f, 1f, 1f, 1f }; private boolean exclusivePMVMatrix = true; - private PMVMatrix sharedPMVMatrix = null; + private PMVMatrix4f sharedPMVMatrix = null; private RegionRenderer.GLCallback enableCallback=null, disableCallback=null; protected RegionRenderer renderer = null; protected TextRegionUtil textRenderUtil = null; @@ -105,7 +104,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { * Must be called before {@link #init(GLAutoDrawable)}. * </p> */ - public void setSharedPMVMatrix(final PMVMatrix pmv) { + public void setSharedPMVMatrix(final PMVMatrix4f pmv) { this.sharedPMVMatrix = pmv; } @@ -245,18 +244,17 @@ public abstract class TextRendererGLELBase implements GLEventListener { dx += sxy * font.getAdvanceWidth('X') * column; dy -= sxy * lineHeight * ( row + 1 ); - final PMVMatrix pmvMatrix = renderer.getMatrix(); - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + final PMVMatrix4f pmvMatrix = renderer.getMatrix(); if( !exclusivePMVMatrix ) { - pmvMatrix.glPushMatrix(); + pmvMatrix.pushMv(); } else { - pmvMatrix.glLoadIdentity(); + pmvMatrix.loadMvIdentity(); } - pmvMatrix.glTranslatef(dx, dy, tz); + pmvMatrix.translateMv(dx, dy, tz); if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { - pmvMatrix.glScalef(sxy, -1f*sxy, 1.0f); + pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f); } else { - pmvMatrix.glScalef(sxy, sxy, 1.0f); + pmvMatrix.scaleMv(sxy, sxy, 1.0f); } renderer.enable(gl, true); if( cacheRegion ) { @@ -269,7 +267,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { renderer.enable(gl, false); if( !exclusivePMVMatrix ) { - pmvMatrix.glPopMatrix(); + pmvMatrix.popMv(); } lastRow = row + newLineCount; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java index e35f084db..9f6a49ded 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -119,7 +119,7 @@ public class TestFBOMRTNEWT01 extends UITestCase { st.attachShaderProgram(gl, sp1, true); final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java index efe903971..eebffdd8b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java @@ -259,7 +259,7 @@ public class ElektronenMultiplizierer implements GLEventListener { st.uniform(gl, mScreenDimensionUniform); pmvMatrix = new PMVMatrix(); - pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java index 57634b581..c2f95222e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java @@ -116,7 +116,7 @@ public class FBOMix2DemosES2 implements GLEventListener { sp0.add(gl, fp0, System.err); st.attachShaderProgram(gl, sp0, true); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index b0f89eb1a..1ffa30560 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -21,6 +21,10 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2; import com.jogamp.common.nio.Buffers; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Vec3f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.newt.Window; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.KeyAdapter; @@ -32,9 +36,6 @@ import com.jogamp.newt.event.PinchToZoomGesture; import com.jogamp.newt.event.GestureHandler.GestureEvent; import com.jogamp.opengl.GLRendererQuirks; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.PMVMatrix; @@ -172,7 +173,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen public void setUseMappedBuffers(final boolean v) { useMappedBuffers = v; } public void setValidateBuffers(final boolean v) { validateBuffers = v; } - public PMVMatrix getPMVMatrix() { + public PMVMatrix4f getPMVMatrix() { return pmvMatrix; } @@ -231,9 +232,9 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - pmvMatrix = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + pmvMatrix = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); st.attachObject("pmvMatrix", pmvMatrix); - pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvitMat()); // P, Mv, Mvi and Mvit + pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.getSyncPMvMviMvit()); // P, Mv, Mvi and Mvit st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java index d083b149c..3d375bcfd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java @@ -77,7 +77,7 @@ public class LineSquareXDemoES2 implements GLEventListener { sp0.add(gl, fp0, System.err); st.attachShaderProgram(gl, sp0, true); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java index 954aeaf8e..4bcc7e3bc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java @@ -100,7 +100,7 @@ public class Mix2TexturesES2 implements GLEventListener { sp0.add(gl, fp0, System.err); st.attachShaderProgram(gl, sp0, true); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java index aa89bcdc9..a6076a3d2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java @@ -96,7 +96,7 @@ public class MultisampleDemoES2 implements GLEventListener { sp0.add(gl, fp0, System.err); st.attachShaderProgram(gl, sp0, true); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java index eebce5a5d..6d8d413a7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2; import java.nio.FloatBuffer; import com.jogamp.common.nio.Buffers; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; @@ -44,7 +45,6 @@ import com.jogamp.opengl.GL2GL3; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; public class PointsDemoES2 extends PointsDemo { ShaderState st; @@ -112,7 +112,7 @@ public class PointsDemoES2 extends PointsDemo { pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 0dc9eb633..f6d0b6876 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -126,7 +126,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java index 32f917f9f..d56575ecf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareMappedES2.java @@ -123,7 +123,7 @@ public class RedSquareMappedES2 implements GLEventListener, TileRendererBase.Til pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java index 017b3e5fe..f6d9a1c97 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -138,7 +138,7 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); if(!st.uniform(gl, pmvMatrixUniform)) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java index 02782644a..c7c852eb4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java @@ -108,7 +108,7 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener { sp0.add(gl, fp0, System.err); st.attachShaderProgram(gl, sp0, true); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 3f4be9833..124eab460 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -38,8 +38,8 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.common.os.Platform; +import com.jogamp.math.FloatUtil; import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -227,7 +227,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { pmvMatrix = new PMVMatrix(); reshapePMV(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java index f0a92891a..8aa2d49f3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java @@ -135,7 +135,7 @@ public class GeomShader01TextureGL3 implements GLEventListener { pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); // P, Mv + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java index da799906a..7acbb034a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java @@ -7,6 +7,9 @@ import java.io.PrintStream; import java.nio.FloatBuffer; import java.util.Random; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.DebugGL4; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; @@ -17,9 +20,6 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.TraceGL4; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.GLArrayDataClient; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; @@ -104,7 +104,7 @@ public class TriangleInstancedRendererWithShaderState implements GLEventListener initShader(gl); projectionMatrix = new PMVMatrix(); - projectionMatrixUniform = new GLUniformData("mgl_PMatrix", 4, 4, projectionMatrix.getSyncPMat()); + projectionMatrixUniform = new GLUniformData("mgl_PMatrix", 4, 4, projectionMatrix.getSyncP()); st.ownUniform(projectionMatrixUniform); if(!st.uniform(gl, projectionMatrixUniform)) { throw new GLException("Error setting mgl_PMatrix in shader: " + st); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java index 986f60550..7ee7c0e7c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java @@ -16,9 +16,9 @@ import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.TraceGL4; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.nio.Buffers; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.util.PMVMatrix; public class TrianglesInstancedRendererHardcoded implements GLEventListener { @@ -100,7 +100,7 @@ public class TrianglesInstancedRendererHardcoded implements GLEventListener { winScale = view.getScale(); } projectionMatrix.glScalef(winScale, winScale, winScale); - gl.glUniformMatrix4fv(projectionMatrixLocation, 1, false, projectionMatrix.getSyncPMat().getSyncFloats()); + gl.glUniformMatrix4fv(projectionMatrixLocation, 1, false, projectionMatrix.getSyncP().getSyncFloats()); projectionMatrix.glPopMatrix(); generateTriangleTransform(); gl.glUniformMatrix4fv(transformMatrixLocation, NO_OF_INSTANCE, false, triangleTransform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java index cd68eb0ce..194ea338f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java @@ -39,6 +39,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import java.io.IOException; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLCapabilities; @@ -46,7 +47,6 @@ import com.jogamp.opengl.GLDrawable; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import org.junit.Assert; import org.junit.Test; @@ -126,7 +126,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); pmvMatrixUniform.setLocation(gl, sp.program()); gl.glUniform(pmvMatrixUniform); @@ -245,7 +245,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); st.ownUniform(pmvMatrixUniform); @@ -337,7 +337,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); @@ -426,7 +426,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java index 73c166abb..7db859f41 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java @@ -39,6 +39,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import java.io.IOException; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLCapabilities; @@ -47,7 +48,6 @@ import com.jogamp.opengl.GLDrawable; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; import org.junit.Assert; import org.junit.Test; @@ -117,7 +117,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); @@ -320,7 +320,7 @@ com.jogamp.opengl.GLException: Thread[main,5,main] glGetError() returned the fol // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); st.ownUniform(pmvMatrixUniform); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java index 5d571bc09..438138533 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java @@ -83,7 +83,7 @@ public class TestRulerNEWT01 extends UITestCase { glWindow.addGLEventListener(new GLEventListener() { final ShaderState st = new ShaderState(); final PMVMatrix pmvMatrix = new PMVMatrix(); - final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat()); + final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); final GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("gca_Vertices", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java index b82d70923..6355ad095 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java @@ -30,13 +30,13 @@ package com.jogamp.opengl.test.junit.jogl.offscreen; import java.nio.*; +import com.jogamp.math.FloatUtil; import com.jogamp.opengl.*; import com.jogamp.opengl.fixedfunc.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.fixedfunc.GLPointerFunc; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.GLArrayDataClient; import com.jogamp.opengl.util.GLArrayDataServer; @@ -108,7 +108,7 @@ public class ReadBuffer2Screen extends ReadBufferBase { pmvMatrix.glTranslatef(0, 0, -2.5f); if(null!=glM) { glM.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - glM.glLoadMatrixf(pmvMatrix.getSyncMvMat().getSyncFloats()); + glM.glLoadMatrixf(pmvMatrix.getSyncMv().getSyncFloats()); } // Set location in front of camera @@ -117,7 +117,7 @@ public class ReadBuffer2Screen extends ReadBufferBase { pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float)width / (float)height, 1.0f, 100.0f); if(null!=glM) { glM.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - glM.glLoadMatrixf(pmvMatrix.getSyncPMat().getSyncFloats()); + glM.glLoadMatrixf(pmvMatrix.getSyncP().getSyncFloats()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java index 46c9fc2c2..02fabce6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES2ImmModeSink.java @@ -89,7 +89,7 @@ public class DemoGL2ES2ImmModeSink implements GLEventListener { sp.useProgram(gl, true); } - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMvMat().getSyncFloats()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv().getSyncFloats()); if(null != st) { st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java b/src/test/com/jogamp/opengl/test/junit/math/Matrix4fb.java index feb9b6f46..a151eec96 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/Matrix4fb.java +++ b/src/test/com/jogamp/opengl/test/junit/math/Matrix4fb.java @@ -26,20 +26,20 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import java.nio.FloatBuffer; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.FovHVHalves; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.Ray; -import com.jogamp.opengl.math.Vec3f; -import com.jogamp.opengl.math.Vec4f; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.math.geom.Frustum; -import com.jogamp.opengl.math.geom.Frustum.Plane; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.FovHVHalves; +import com.jogamp.math.Quaternion; +import com.jogamp.math.Ray; +import com.jogamp.math.Vec3f; +import com.jogamp.math.Vec4f; +import com.jogamp.math.VectorUtil; +import com.jogamp.math.geom.AABBox; +import com.jogamp.math.geom.Frustum; +import com.jogamp.math.geom.Frustum.Plane; /** * Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations). diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary16NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestBinary16NOUI.java index 5e4166a49..6fecb1f23 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary16NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestBinary16NOUI.java @@ -26,14 +26,14 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import org.junit.Assert; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; -import com.jogamp.opengl.math.Binary16; +import com.jogamp.math.Binary16; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestBinary32NOUI.java index ba59eddec..9eda98cc9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestBinary32NOUI.java @@ -26,13 +26,13 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import org.junit.Assert; import org.junit.Test; import com.jogamp.junit.util.JunitTracer; -import com.jogamp.opengl.math.Binary32; +import com.jogamp.math.Binary32; public class TestBinary32NOUI extends JunitTracer { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestBinary64NOUI.java index 8e635f128..e65776635 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestBinary64NOUI.java @@ -26,13 +26,13 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import org.junit.Assert; import org.junit.Test; import com.jogamp.junit.util.JunitTracer; -import com.jogamp.opengl.math.Binary64; +import com.jogamp.math.Binary64; public class TestBinary64NOUI extends JunitTracer { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestFloatUtil01NOUI.java index 1c2b32fcb..aae2b02e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestFloatUtil01NOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.math;
+package com.jogamp.opengl.test.junit.math;
@@ -37,7 +37,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.math.FloatUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestFloatUtil01NOUI extends JunitTracer {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestGluUnprojectDoubleNOUI.java index 7d7ec47d6..5cd11d30e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestGluUnprojectDoubleNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import com.jogamp.junit.util.JunitTracer; import com.jogamp.opengl.glu.GLU; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestGluUnprojectFloatNOUI.java index 55df4bcd4..cd119d5a3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestGluUnprojectFloatNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import com.jogamp.junit.util.JunitTracer; import com.jogamp.opengl.glu.GLU; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4f01NOUI.java index 2657bce03..5c4a0f4ca 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4f01NOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import org.junit.Assert; import org.junit.Test; @@ -34,9 +34,9 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; import com.jogamp.junit.util.JunitTracer; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Vec3f; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMatrix4f01NOUI extends JunitTracer { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4f02MulNOUI.java index b040caed9..a2cc5a3f3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f02MulNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4f02MulNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.math;
+package com.jogamp.opengl.test.junit.math;
import org.junit.Assert;
import org.junit.Test; @@ -35,8 +35,8 @@ import org.junit.runners.MethodSorters; import com.jogamp.common.os.Platform;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.math.FloatUtil;
+import com.jogamp.math.Matrix4f;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMatrix4f02MulNOUI extends JunitTracer {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4f03InversionNOUI.java index 268d4271d..ae0d8d739 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4f03InversionNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4f03InversionNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.math;
+package com.jogamp.opengl.test.junit.math;
import org.junit.Assert;
import org.junit.Test; @@ -35,8 +35,8 @@ import org.junit.runners.MethodSorters; import com.jogamp.common.os.Platform;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Matrix4f;
+import com.jogamp.math.FloatUtil;
+import com.jogamp.math.Matrix4f;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMatrix4f03InversionNOUI extends JunitTracer {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fMatrixMulNOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4fMatrixMulNOUI.java index 67099cfab..1352d36c5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fMatrixMulNOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4fMatrixMulNOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import org.junit.Assert; import org.junit.Test; @@ -34,7 +34,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; import com.jogamp.junit.util.JunitTracer; -import com.jogamp.opengl.math.Matrix4f; +import com.jogamp.math.Matrix4f; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMatrix4fMatrixMulNOUI extends JunitTracer { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4fProject01NOUI.java index b22bf9ad7..69b103541 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4fProject01NOUI.java @@ -25,21 +25,21 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import java.util.Arrays; import com.jogamp.common.nio.Buffers; import com.jogamp.junit.util.JunitTracer; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.opengl.glu.GLU; import jogamp.opengl.gl2.ProjectDouble; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.PMVMatrix; import org.junit.Assert; @@ -74,15 +74,15 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { final PMVMatrix m = new PMVMatrix(); final Matrix4f mat4PMv = new Matrix4f(); - m.mulPMvMat(mat4PMv); + m.getMulPMv(mat4PMv); System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f")); - m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA00); // separate P + Mv + m.mapObjToWin(new Vec3f(1f, 0f, 0f), viewport, winA00); // separate P + Mv System.err.println("A.0.0 - Project 1,0 -->" + winA00); Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB00); // single PMv System.err.println("B.0.0 - Project 1,0 -->" + winB00); - m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA01); + m.mapObjToWin(new Vec3f(0f, 0f, 0f), viewport, winA01); System.err.println("A.0.1 - Project 0,0 -->" + winA01); Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB01); System.err.println("B.0.1 - Project 0,0 -->" + winB01); @@ -91,15 +91,15 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { m.glOrthof(0, 10, 0, 10, 1, -1); System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale"); System.err.println(m); - m.mulPMvMat(mat4PMv); + m.getMulPMv(mat4PMv); System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f")); - m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA10); + m.mapObjToWin(new Vec3f(1f, 0f, 0f), viewport, winA10); System.err.println("A.1.0 - Project 1,0 -->" +winA10); Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB10); System.err.println("B.1.0 - Project 1,0 -->" +winB10); - m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA11); + m.mapObjToWin(new Vec3f(0f, 0f, 0f), viewport, winA11); System.err.println("A.1.1 - Project 0,0 -->" +winA11); Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB11); System.err.println("B.1.1 - Project 0,0 -->" +winB11); @@ -140,15 +140,15 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { mat4P.load( m.getMat(GLMatrixFunc.GL_PROJECTION_MATRIX) ); Assert.assertEquals(new Matrix4f(mat4Mv_f16), mat4Mv); Assert.assertEquals(new Matrix4f(mat4P_f16), mat4P); - Assert.assertEquals(mat4Mv, m.getMvMat()); - Assert.assertEquals(mat4P, m.getPMat()); + Assert.assertEquals(mat4Mv, m.getMv()); + Assert.assertEquals(mat4P, m.getP()); - m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA00); + m.mapObjToWin(new Vec3f(1f, 0f, 0f), viewport, winA00); System.err.println("A.0.0 - Project 1,0 -->" + winA00); Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB00); System.err.println("B.0.0 - Project 1,0 -->" + winB00); - m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA01); + m.mapObjToWin(new Vec3f(0f, 0f, 0f), viewport, winA01); System.err.println("A.0.1 - Project 0,0 -->" + winA01); Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB01); System.err.println("B.0.1 - Project 0,0 -->" + winB01); @@ -165,15 +165,15 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { mat4P.load( m.getMat(GLMatrixFunc.GL_PROJECTION_MATRIX) ); Assert.assertEquals(new Matrix4f(mat4Mv_f16), mat4Mv); Assert.assertEquals(new Matrix4f(mat4P_f16), mat4P); - Assert.assertEquals(mat4Mv, m.getMvMat()); - Assert.assertEquals(mat4P, m.getPMat()); + Assert.assertEquals(mat4Mv, m.getMv()); + Assert.assertEquals(mat4P, m.getP()); - m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA10); + m.mapObjToWin(new Vec3f(1f, 0f, 0f), viewport, winA10); System.err.println("A.1.0 - Project 1,0 -->" +winA10); Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4Mv, mat4P, viewport, winB10); System.err.println("B.1.0 - Project 1,0 -->" +winB10); - m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA11); + m.mapObjToWin(new Vec3f(0f, 0f, 0f), viewport, winA11); System.err.println("A.1.1 - Project 0,0 -->" +winA11); Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4Mv, mat4P, viewport, winB11); System.err.println("B.1.1 - Project 0,0 -->" +winB11); @@ -209,8 +209,8 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0); System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */)); System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */)); - mat4Mv.load( m.getMvMat() ); - mat4P.load( m.getPMat() ); + mat4Mv.load( m.getMv() ); + mat4P.load( m.getP() ); glu.gluProject(1f, 0f, 0f, mat4Mv_f16, 0, mat4P_f16, 0, viewport_i4, 0, winA00, 0); System.err.println("A.0.0 - Project 1,0 -->" + winA00); @@ -230,8 +230,8 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0); System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */)); System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */)); - mat4Mv.load( m.getMvMat() ); - mat4P.load( m.getPMat() ); + mat4Mv.load( m.getMv() ); + mat4P.load( m.getP() ); glu.gluProject(1f, 0f, 0f, mat4Mv_f16, 0, mat4P_f16, 0, viewport_i4, 0, winA10, 0); System.err.println("A.1.0 - Project 1,0 -->" +winA10); @@ -274,8 +274,8 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0); System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */)); System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */)); - mat4Mv.load( m.getMvMat() ); - mat4P.load( m.getPMat() ); + mat4Mv.load( m.getMv() ); + mat4P.load( m.getP() ); double[] mat4Mv_d16 = Buffers.getDoubleArray(mat4Mv_f16, 0, null, 0, -1); double[] mat4P_d16 = Buffers.getDoubleArray(mat4P_f16, 0, null, 0, -1); @@ -297,8 +297,8 @@ public class TestMatrix4fProject01NOUI extends JunitTracer { m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P_f16, 0); System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv_f16, 0, 4, 4, false /* rowMajorOrder */)); System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P_f16, 0, 4, 4, false /* rowMajorOrder */)); - mat4Mv.load( m.getMvMat() ); - mat4P.load( m.getPMat() ); + mat4Mv.load( m.getMv() ); + mat4P.load( m.getP() ); mat4Mv_d16 = Buffers.getDoubleArray(mat4Mv_f16, 0, null, 0, -1); mat4P_d16 = Buffers.getDoubleArray(mat4P_f16, 0, null, 0, -1); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject02NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4fProject02NOUI.java index 329c122ac..f2f3ebb0d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestMatrix4fProject02NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestMatrix4fProject02NOUI.java @@ -25,17 +25,16 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import java.util.Arrays; import com.jogamp.junit.util.JunitTracer; - -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec2f; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec2f; +import com.jogamp.math.Vec3f; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/math/TestPMVMatrix01NEWT.java index 7119a7c48..055cddb36 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestPMVMatrix01NEWT.java @@ -26,10 +26,13 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import java.nio.FloatBuffer; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GL2ES1; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLContext; @@ -47,8 +50,6 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.PMVMatrix; @@ -147,7 +148,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { Assert.assertEquals(0, pmv.getReqBits()); Assert.assertEquals(false, pmv.isReqDirty()); Assert.assertTrue(0 != pmv.getDirtyBits()); - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); // // Action #0 @@ -156,7 +157,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { { pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmv.glLoadIdentity(); - ident = pmv.getPMat(); + ident = pmv.getP(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); @@ -165,7 +166,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { Assert.assertTrue(0 == pmv.getModifiedBits(false)); // clear & test Assert.assertTrue(0 != pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); // // Action #1 @@ -177,30 +178,30 @@ public class TestPMVMatrix01NEWT extends UITestCase { Assert.assertEquals(false, pmv.isReqDirty()); Assert.assertTrue(0 != pmv.getDirtyBits()); - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals("Update has been perfomed, but non requested", false, pmv.update()); // nothing has been requested // System.err.println("P2: "+pmv.toString()); // // Get // - p = pmv.getPMat(); + p = pmv.getP(); MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon); - mv = pmv.getMvMat(); + mv = pmv.getMv(); MiscUtils.assertMatrix4fEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon); { IllegalArgumentException e = null; try { - pmv.getMviMat(); + pmv.getMvi(); } catch(final IllegalArgumentException iae) { e = iae; } Assert.assertNotNull(e); } - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertNotNull(pmv.getFrustum()); // FIXME: Test Frustum value! - Assert.assertNotNull(pmv.getPMvMat()); // FIXME: Test value! - Assert.assertNotNull(pmv.getPMviMat()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMv()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMvi()); // FIXME: Test value! Assert.assertEquals(0, pmv.getDirtyBits()); // System.err.println("P3: "+pmv.toString()); @@ -209,7 +210,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { // pmv.glLoadIdentity(); // all dirty Assert.assertTrue(0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); System.err.println("test01a.PX: "+pmv.toString()); } @@ -222,16 +223,16 @@ public class TestPMVMatrix01NEWT extends UITestCase { @Test public void test01bTraditionalAccess() { Matrix4f p, mv, mvi, mvit; - final PMVMatrix pmv = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + final PMVMatrix pmv = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); System.err.println("test01b.P0: "+pmv.toString()); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW, pmv.getReqBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW, pmv.getReqBits()); Assert.assertTrue(0 != pmv.getDirtyBits()); Assert.assertEquals(true, pmv.isReqDirty()); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); // // Action #0 @@ -240,14 +241,14 @@ public class TestPMVMatrix01NEWT extends UITestCase { { pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmv.glLoadIdentity(); - ident = pmv.getPMat(); + ident = pmv.getP(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); } Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.INVERSE_MODELVIEW|PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix4f.INVERSE_MODELVIEW|PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); // // Action #1 @@ -255,17 +256,17 @@ public class TestPMVMatrix01NEWT extends UITestCase { pmv.glTranslatef(1f, 2f, 3f); // all dirty ! Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.INVERSE_MODELVIEW|PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix4f.INVERSE_MODELVIEW|PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); System.err.println("test01b.P1: "+pmv.toString()); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals(true, pmv.isReqDirty()); Assert.assertEquals(true, pmv.update()); - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); Assert.assertNotNull(pmv.getFrustum()); // FIXME: Test Frustum value! - Assert.assertNotNull(pmv.getPMvMat()); // FIXME: Test value! - Assert.assertNotNull(pmv.getPMviMat()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMv()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMvi()); // FIXME: Test value! Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); // System.err.println("P2: "+pmv.toString()); @@ -273,23 +274,23 @@ public class TestPMVMatrix01NEWT extends UITestCase { // // Get // - p = pmv.getPMat(); + p = pmv.getP(); MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon); - mv = pmv.getMvMat(); + mv = pmv.getMv(); MiscUtils.assertMatrix4fEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon); - mvi = pmv.getMviMat(); + mvi = pmv.getMvi(); MiscUtils.assertMatrix4fEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon); Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); Assert.assertNotNull(pmv.getFrustum()); // FIXME: Test Frustum value! - Assert.assertNotNull(pmv.getPMvMat()); // FIXME: Test value! - Assert.assertNotNull(pmv.getPMviMat()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMv()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMvi()); // FIXME: Test value! Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); // System.err.println("P3: "+pmv.toString()); - mvit = pmv.getMvitMat(); + mvit = pmv.getMvit(); MiscUtils.assertMatrix4fEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); @@ -302,7 +303,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue(0 != pmv.getDirtyBits()); Assert.assertEquals(true, pmv.isReqDirty()); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); System.err.println("test01b.P2: "+pmv.toString()); MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon); MiscUtils.assertMatrix4fEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); @@ -314,14 +315,14 @@ public class TestPMVMatrix01NEWT extends UITestCase { Assert.assertEquals(true, pmv.update()); Assert.assertTrue(0 != pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); MiscUtils.assertMatrix4fEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon); MiscUtils.assertMatrix4fEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon); Assert.assertNotNull(pmv.getFrustum()); // FIXME: Test Frustum value! - Assert.assertNotNull(pmv.getPMvMat()); // FIXME: Test value! - Assert.assertNotNull(pmv.getPMviMat()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMv()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMvi()); // FIXME: Test value! Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); System.err.println("test01b.PX: "+pmv.toString()); @@ -336,13 +337,13 @@ public class TestPMVMatrix01NEWT extends UITestCase { @Test public void test02MviUpdateShaderAccess() { final Matrix4f p, mv, mvi, mvit; - final PMVMatrix pmv = new PMVMatrix(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW); + final PMVMatrix pmv = new PMVMatrix(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW); // System.err.println("P0: "+pmv.toString()); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW, pmv.getReqBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW, pmv.getReqBits()); Assert.assertTrue(0 != pmv.getDirtyBits()); Assert.assertEquals(true, pmv.isReqDirty()); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); // // Action #0 @@ -351,7 +352,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { { pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmv.glLoadIdentity(); - ident = pmv.getPMat(); + ident = pmv.getP(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); @@ -359,14 +360,14 @@ public class TestPMVMatrix01NEWT extends UITestCase { // System.err.println("P0: "+pmv.toString()); Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals(true, pmv.isReqDirty()); Assert.assertEquals(true, pmv.update()); - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); Assert.assertNotNull(pmv.getFrustum()); // FIXME: Test Frustum value! - Assert.assertNotNull(pmv.getPMvMat()); // FIXME: Test value! - Assert.assertNotNull(pmv.getPMviMat()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMv()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMvi()); // FIXME: Test value! Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); // System.err.println("P1: "+pmv.toString()); @@ -374,19 +375,19 @@ public class TestPMVMatrix01NEWT extends UITestCase { // // Get // - p = pmv.getPMat(); + p = pmv.getP(); MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString(), ident, p, epsilon); - mv = pmv.getMvMat(); + mv = pmv.getMv(); MiscUtils.assertMatrix4fEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); - mvi = pmv.getMviMat(); + mvi = pmv.getMvi(); MiscUtils.assertMatrix4fEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon); Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); - mvit = pmv.getMvitMat(); + mvit = pmv.getMvit(); MiscUtils.assertMatrix4fEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon); Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); @@ -397,7 +398,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { pmv.glTranslatef(1f, 2f, 3f); // all dirty ! Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.INVERSE_MODELVIEW|PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix4f.INVERSE_MODELVIEW|PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); MiscUtils.assertMatrix4fEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon); MiscUtils.assertMatrix4fEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123C, mv, epsilon); MiscUtils.assertMatrix4fNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); @@ -405,14 +406,14 @@ public class TestPMVMatrix01NEWT extends UITestCase { MiscUtils.assertMatrix4fEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon); MiscUtils.assertMatrix4fEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon); - Assert.assertEquals(PMVMatrix.INVERSE_MODELVIEW | PMVMatrix.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.INVERSE_MODELVIEW | PMVMatrix4f.INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals(true, pmv.isReqDirty()); Assert.assertEquals(true, pmv.update()); // will clean dirty bits, since all requests has been made -> true - Assert.assertEquals(PMVMatrix.MANUAL_BITS, pmv.getDirtyBits()); + Assert.assertEquals(PMVMatrix4f.MANUAL_BITS, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); Assert.assertNotNull(pmv.getFrustum()); // FIXME: Test Frustum value! - Assert.assertNotNull(pmv.getPMvMat()); // FIXME: Test value! - Assert.assertNotNull(pmv.getPMviMat()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMv()); // FIXME: Test value! + Assert.assertNotNull(pmv.getPMvi()); // FIXME: Test value! Assert.assertEquals(0, pmv.getDirtyBits()); Assert.assertEquals(false, pmv.isReqDirty()); MiscUtils.assertMatrix4fEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); @@ -432,7 +433,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { pmv.glLoadIdentity(); pmv.glTranslatef(5f, 6f, 7f); - pmvMv.load(pmv.getMvMat()); + pmvMv.load(pmv.getMv()); // pmvMvi = pmv.glGetMviMatrixf(); // pmvMvit = pmv.glGetMvitMatrixf(); } @@ -473,7 +474,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { pmv.glTranslatef(5f, 6f, 7f); pmv.glRotatef(90f, 1f, 0f, 0f); - pmvMv.load(pmv.getMvMat()); + pmvMv.load(pmv.getMv()); // pmvMvi = pmv.glGetMviMatrixf(); // pmvMvit = pmv.glGetMvitMatrixf(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestPMVMatrix02NOUI.java index 391973215..b03feed56 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestPMVMatrix02NOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.math;
+package com.jogamp.opengl.test.junit.math;
import org.junit.Before;
import org.junit.Test; @@ -35,9 +35,9 @@ import org.junit.runners.MethodSorters; import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.junit.util.JunitTracer;
+import com.jogamp.math.Matrix4f;
+import com.jogamp.math.Vec3f;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
-import com.jogamp.opengl.math.Matrix4f;
-import com.jogamp.opengl.math.Vec3f;
import static org.junit.Assert.assertEquals;
@@ -63,7 +63,7 @@ public class TestPMVMatrix02NOUI extends JunitTracer { new Vec3f(0, 0, -1),
new Vec3f(0, 1, 0)
);
- final Matrix4f mvMatrix = fMat.getMvMat();
+ final Matrix4f mvMatrix = fMat.getMv();
assertEquals(
/**
* The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward.
@@ -86,7 +86,7 @@ public class TestPMVMatrix02NOUI extends JunitTracer { new Vec3f(0, 1, 0),
new Vec3f(0, 0, 1)
);
- final Matrix4f mvMatrix = fMat.getMvMat();
+ final Matrix4f mvMatrix = fMat.getMv();
assertEquals(
/**
* The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward.
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestPMVMatrix03NOUI.java index e6697d356..78f017f60 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestPMVMatrix03NOUI.java @@ -1,16 +1,16 @@ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import java.util.Arrays; import com.jogamp.junit.util.JunitTracer; +import com.jogamp.math.FloatUtil; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Recti; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import jogamp.opengl.ProjectFloat; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Recti; -import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.util.PMVMatrix; import org.junit.Assert; @@ -40,15 +40,15 @@ public class TestPMVMatrix03NOUI extends JunitTracer { final PMVMatrix m = new PMVMatrix(); final Matrix4f mat4PMv = new Matrix4f(); - m.mulPMvMat(mat4PMv); + m.getMulPMv(mat4PMv); System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f")); - m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA00); + m.mapObjToWin(new Vec3f(1f, 0f, 0f), viewport, winA00); System.err.println("A.0.0 - Project 1,0 -->" + winA00); Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB00); // single PMv System.err.println("B.0.0 - Project 1,0 -->" + winB00); - m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA01); + m.mapObjToWin(new Vec3f(0f, 0f, 0f), viewport, winA01); System.err.println("A.0.1 - Project 0,0 -->" + winA01); Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB01); // single PMv System.err.println("B.0.1 - Project 0,0 -->" + winB01); @@ -57,15 +57,15 @@ public class TestPMVMatrix03NOUI extends JunitTracer { m.glOrthof(0, 10, 0, 10, 1, -1); System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale"); System.err.println(m); - m.mulPMvMat(mat4PMv); + m.getMulPMv(mat4PMv); System.err.println(mat4PMv.toString(null, "mat4PMv", "%10.5f")); - m.gluProject(new Vec3f(1f, 0f, 0f), viewport, winA10); + m.mapObjToWin(new Vec3f(1f, 0f, 0f), viewport, winA10); System.err.println("A.1.0 - Project 1,0 -->" +winA10); Matrix4f.mapObjToWin(new Vec3f(1f, 0f, 0f), mat4PMv, viewport, winB10); // single PMv System.err.println("B.1.0 - Project 1,0 -->" +winB10); - m.gluProject(new Vec3f(0f, 0f, 0f), viewport, winA11); + m.mapObjToWin(new Vec3f(0f, 0f, 0f), viewport, winA11); System.err.println("A.1.1 - Project 0,0 -->" +winA11); Matrix4f.mapObjToWin(new Vec3f(0f, 0f, 0f), mat4PMv, viewport, winB11); // single PMv System.err.println("B.1.1 - Project 0,0 -->" +winB11); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestPMVTransform01NOUI.java index d2f0fc794..f92394fa8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestPMVTransform01NOUI.java @@ -25,12 +25,11 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.math; +package com.jogamp.opengl.test.junit.math; import com.jogamp.junit.util.JunitTracer; - -import com.jogamp.opengl.math.Matrix4f; -import com.jogamp.opengl.math.Vec3f; +import com.jogamp.math.Matrix4f; +import com.jogamp.math.Vec3f; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.util.PMVMatrix; @@ -64,7 +63,7 @@ public class TestPMVTransform01NOUI extends JunitTracer { 1.00000f, 2.00000f, 3.00000f, 1.00000f, }); final Matrix4f has = new Matrix4f(); - pmv.mulPMvMat(has); + pmv.getMulPMv(has); MiscUtils.assertMatrix4fEquals(exp, has, epsilon); Assert.assertEquals(exp, has); } @@ -89,7 +88,7 @@ public class TestPMVTransform01NOUI extends JunitTracer { 2.00000f, 4.00000f, 6.00000f, 1.00000f, }); final Matrix4f has = new Matrix4f(); - pmv.mulPMvMat(has); + pmv.getMulPMv(has); MiscUtils.assertMatrix4fEquals(exp, has, epsilon); Assert.assertEquals(exp, has); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestQuaternion01NOUI.java index 8c6191c75..8e4957d97 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestQuaternion01NOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.math;
+package com.jogamp.opengl.test.junit.math;
import org.junit.Assert;
import org.junit.Test; @@ -34,12 +34,12 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Matrix4f;
-import com.jogamp.opengl.math.Quaternion;
-import com.jogamp.opengl.math.Vec3f;
-import com.jogamp.opengl.math.Vec4f;
-import com.jogamp.opengl.math.VectorUtil;
+import com.jogamp.math.FloatUtil;
+import com.jogamp.math.Matrix4f;
+import com.jogamp.math.Quaternion;
+import com.jogamp.math.Vec3f;
+import com.jogamp.math.Vec4f;
+import com.jogamp.math.VectorUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestQuaternion01NOUI extends JunitTracer {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestVec3f01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestVec3f01NOUI.java index fe762926f..b8e9356fb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestVec3f01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestVec3f01NOUI.java @@ -26,7 +26,7 @@ * or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.math;
+package com.jogamp.opengl.test.junit.math;
import org.junit.Assert;
import org.junit.Test; @@ -34,9 +34,9 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters;
import com.jogamp.junit.util.JunitTracer;
-import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.Quaternion;
-import com.jogamp.opengl.math.Vec3f;
+import com.jogamp.math.FloatUtil;
+import com.jogamp.math.Quaternion;
+import com.jogamp.math.Vec3f;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestVec3f01NOUI extends JunitTracer {
diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java index d4c60144a..b8c7a84e6 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java +++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java @@ -40,9 +40,9 @@ import java.util.Iterator; import java.util.List; import com.jogamp.opengl.GLContext; -import com.jogamp.opengl.math.Matrix4f; import com.jogamp.common.os.Platform; import com.jogamp.common.util.InterruptSource; +import com.jogamp.math.Matrix4f; public class MiscUtils { public static boolean atob(final String str, final boolean def) { |