summaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/com/jogamp')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java17
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java9
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java238
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java41
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java27
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java22
9 files changed, 301 insertions, 59 deletions
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 e60bc95f3..fde29d9ea 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
@@ -150,7 +150,7 @@ public class UISceneDemo00 {
final long t0_us = Clock.currentNanos() / 1000; // [us]
long t1_us = t0_us;
shape.moveTo(min_obj, 0f, 0f); // move shape to min start position
- while( shape.getPosition()[0] < max_obj && window.isNativeValid() ) {
+ while( shape.getPosition().x() < max_obj && window.isNativeValid() ) {
final long t2_us = Clock.currentNanos() / 1000;
final float dt_s = ( t2_us - t1_us ) / 1e6f;
t1_us = t2_us;
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 3358804b7..3bf506e8f 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -159,7 +159,7 @@ public class UISceneDemo01 {
final long t0_us = Clock.currentNanos() / 1000; // [us]
long t1_us = t0_us;
shape.moveTo(min_obj, 0f, 0f); // move shape to min start position
- while( shape.getPosition()[0] < max_obj && window.isNativeValid() ) {
+ while( shape.getPosition().x() < max_obj && window.isNativeValid() ) {
final long t2_us = Clock.currentNanos() / 1000;
final float dt_s = ( t2_us - t1_us ) / 1e6f;
t1_us = t2_us;
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 e6e210f69..77827656f 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
@@ -248,7 +248,7 @@ public class UISceneDemo02 {
final long t1_us = Clock.currentNanos() / 1000; // [us]
final long[] t2_us = { t1_us };
- while( movingGlyph.getPosition()[0] > end_pos && window.isNativeValid() ) {
+ while( movingGlyph.getPosition().x() > end_pos && window.isNativeValid() ) {
// Move on GL thread to have vsync for free
// Otherwise we would need to employ a sleep(..) w/ manual vsync
final long[] t3_us = { 0 };
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 ee48a684e..7df78ca99 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -57,7 +57,6 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
import com.jogamp.opengl.math.Vec3f;
-import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.PMVMatrix;
@@ -82,7 +81,7 @@ public class UISceneDemo03 {
" JogAmp, Java™ libraries for 3D & Media "
};
- static GraphUIDemoArgs options = new GraphUIDemoArgs(1280, 720, 0);
+ static GraphUIDemoArgs options = new GraphUIDemoArgs(1280, 720, Region.VBAA_RENDERING_BIT);
static float velocity = 30 / 1e3f; // [m]/[s]
static float rot_step = velocity * 1;
@@ -306,7 +305,7 @@ public class UISceneDemo03 {
addedGlyphShapes.addAll(glyphShapes);
final float pos_eps = FloatUtil.EPSILON * 5000; // ~= 0.0005960
- final float rot_eps = FloatUtil.adegToRad(1f); // 1 adeg ~= 0.01745 rad
+ final float rot_eps = FloatUtil.adegToRad(0.5f); // 1 adeg ~= 0.01745 rad
final long t0_us = Clock.currentNanos() / 1000; // [us]
final long[] t2_us = { t0_us };
@@ -327,13 +326,19 @@ public class UISceneDemo03 {
final Vec3f p_t = target.minus(pos);
final float p_t_diff = p_t.length();
final Quaternion q = glyph.getRotation();
- final float radY = q.toAngleAxis(VectorUtil.VEC3_UNIT_Y);
- final float radYdiff = Math.min(radY, FloatUtil.TWO_PI - radY);
+ final Vec3f euler = q.toEuler(new Vec3f());
+ final float radY = euler.y();
+ final float radYdiff = Math.min(Math.abs(radY), FloatUtil.TWO_PI - Math.abs(radY));
final boolean pos_ok = p_t_diff <= pos_eps;
final boolean pos_near = p_t_diff <= glyph.getBounds().getSize() * fontScale * 2f;
final boolean rot_ok = pos_near && ( radYdiff <= rot_eps || radYdiff <= rot_step * 2f );
if ( pos_ok && rot_ok ) {
// arrived
+ if( DEBUG ) {
+ if( 0 == idx ) {
+ System.err.println("F: rot: "+radY+" ("+FloatUtil.radToADeg(radY)+"), diff "+radYdiff+" ("+FloatUtil.radToADeg(radYdiff)+"), step "+rot_step+" ("+FloatUtil.radToADeg(rot_step)+")");
+ }
+ }
glyph.moveTo(target.x(), target.y(), target.z());
q.setIdentity();
glyphShapes.remove(idx);
@@ -362,7 +367,7 @@ public class UISceneDemo03 {
} else {
if( DEBUG ) {
if( 0 == idx ) {
- System.err.println("rot: "+radY+" ("+FloatUtil.radToADeg(radY)+"), diff "+radYdiff+" ("+FloatUtil.radToADeg(radYdiff)+"), step "+rot_step+" ("+FloatUtil.radToADeg(rot_step)+")");
+ System.err.println("P: rot: "+radY+" ("+FloatUtil.radToADeg(radY)+"), diff "+radYdiff+" ("+FloatUtil.radToADeg(radYdiff)+"), step "+rot_step+" ("+FloatUtil.radToADeg(rot_step)+")");
}
}
if( radYdiff <= rot_step * 3f || radYdiff <= rot_eps ) {
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 52fe33e51..0874df04e 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
@@ -56,6 +56,7 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.es2.GearsES2;
import com.jogamp.opengl.demos.util.MiscUtils;
+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;
@@ -149,8 +150,8 @@ public class UISceneDemo10 {
shape.onMove(new Shape.Listener() {
@Override
public void run(final Shape shape) {
- final float[] p = shape.getPosition();
- System.err.println("Shape moved: "+p[0]+", "+p[1]+", "+p[2]);
+ final Vec3f p = shape.getPosition();
+ System.err.println("Shape moved: "+p);
}
});
shape.addMouseListener(new Shape.MouseGestureAdapter() {
@@ -226,8 +227,8 @@ public class UISceneDemo10 {
static void testProject(final Scene scene, final Shape shape, final int glWinX, final int glWinY) {
final PMVMatrix pmv = new PMVMatrix();
- final float[] objPos = shape.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, new float[3]);
- System.err.printf("MM1: winToObjCoord: obj [%25.20ff, %25.20ff, %25.20ff]%n", objPos[0], objPos[1], objPos[2]);
+ 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]);
final int windx = glWinPos[0]-glWinX;
final int windy = glWinPos[1]-glWinY;
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
new file mode 100644
index 000000000..43cd9fc07
--- /dev/null
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
@@ -0,0 +1,238 @@
+/**
+ * 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.opengl.demos.graph.ui;
+
+import java.io.IOException;
+
+import com.jogamp.common.os.Clock;
+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.ui.Group;
+import com.jogamp.graph.ui.Scene;
+import com.jogamp.graph.ui.Shape;
+import com.jogamp.graph.ui.layout.GridLayout;
+import com.jogamp.graph.ui.shapes.Button;
+import com.jogamp.graph.ui.shapes.GLButton;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GLCapabilities;
+import com.jogamp.opengl.GLProfile;
+import com.jogamp.opengl.demos.es2.GearsES2;
+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.
+ * <p>
+ * Pass '-keep' to main-function to keep running after animation,
+ * then user can test Shape drag-move and drag-resize w/ 1-pointer.
+ * </p>
+ */
+public class UISceneDemo11 {
+ public static void main(final String[] args) throws IOException {
+ final int surface_width = 1280, surface_height = 720;
+ final int renderModes = Region.VBAA_RENDERING_BIT;
+ final GLProfile glp = GLProfile.getGL2ES2();
+
+ boolean keepRunning = false;
+ if( 0 != args.length ) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-keep")) {
+ keepRunning = true;
+ }
+ }
+ }
+
+ //
+ // Resolution independent, no screen size
+ //
+ final Font font = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_LIGHT, FontSet.STYLE_SERIF);
+ System.err.println("Font: "+font.getFullFamilyName());
+
+ final float shapeWidth = 1/8f;
+ final float shapeHeight = shapeWidth/2.5f;
+ final Group groupA0 = new Group(new GridLayout(2, shapeWidth*1.1f, shapeHeight*1.1f));
+ {
+ groupA0.addShape( new Button(renderModes, font, "1", shapeWidth, shapeHeight) );
+ groupA0.addShape( new Button(renderModes, font, "2", shapeWidth, shapeHeight) );
+ groupA0.addShape( new Button(renderModes, font, "3", shapeWidth, shapeHeight) );
+ groupA0.addShape( new Button(renderModes, font, "4", shapeWidth, shapeHeight) );
+ }
+ groupA0.validate(glp);
+ System.err.println("Group-A0 "+groupA0);
+ groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; });
+
+ final Scene scene = new Scene();
+ scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ scene.addShape(groupA0);
+ scene.setFrustumCullingEnabled(true);
+
+ final Animator animator = new Animator();
+
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ System.out.println("Requested: " + caps);
+
+ final GLWindow window = GLWindow.create(caps);
+ window.setSize(surface_width, surface_height);
+ window.setTitle(UISceneDemo11.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
+ window.setVisible(true);
+ window.addGLEventListener(scene);
+ window.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowResized(final WindowEvent e) {
+ window.setTitle(UISceneDemo11.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
+ }
+ @Override
+ public void windowDestroyNotify(final WindowEvent e) {
+ animator.stop();
+ }
+ });
+
+ scene.attachInputListenerTo(window);
+
+ animator.setUpdateFPSFrames(1*60, null); // System.err);
+ animator.add(window);
+ animator.start();
+
+ //
+ // After initial display we can use screen resolution post initial Scene.reshape(..)
+ // However, in this example we merely use the resolution to
+ // - Compute the animation values with DPI
+ scene.waitUntilDisplayed();
+
+ final AABBox sceneBox = scene.getBounds();
+ System.err.println("SceneBox "+sceneBox);
+ System.err.println("Group-A0 "+groupA0);
+ groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; });
+ try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
+
+ final Shape mobileShape = groupA0;
+
+ if( true ) {
+ //
+ // Compute the metric animation values -> shape obj-velocity
+ //
+ 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 float[] pixPerShapeUnit = mobileShape.getPixelPerShapeUnit(shapeSizePx, new float[2]); // [px]/[shapeUnit]
+
+ final float pixPerMM = window.getPixelsPerMM(new float[2])[0]; // [px]/[mm]
+ final float dist_px = scene.getWidth() - shapeSizePx[0]; // [px]
+ final float dist_m = dist_px/pixPerMM/1e3f; // [m]
+ final float velocity = 50/1e3f; // [m]/[s]
+ final float velocity_px = velocity * 1e3f * pixPerMM; // [px]/[s]
+ final float velovity_obj = velocity_px / pixPerShapeUnit[0]; // [shapeUnit]/[s]
+ final float exp_dur_s = dist_m / velocity; // [s]
+
+ System.err.println();
+ System.err.printf("Shape: %d x %d [pixel], %.4f px/shape_unit%n", shapeSizePx[0], shapeSizePx[1], pixPerShapeUnit[0]);
+ System.err.printf("Shape: %s%n", mobileShape);
+ System.err.println();
+ System.err.printf("Distance: %.0f pixel @ %.3f px/mm, %.3f mm%n", dist_px, pixPerMM, dist_m*1e3f);
+ System.err.printf("Velocity: %.3f mm/s, %.3f px/s, %.6f obj/s, expected travel-duration %.3f s%n",
+ velocity*1e3f, velocity_px, velovity_obj, exp_dur_s);
+
+ final long t0_us = Clock.currentNanos() / 1000; // [us]
+ long t1_us = t0_us;
+ mobileShape.moveTo(min_obj, 0f, 0f); // move shape to min start position
+ while( mobileShape.getPosition().x() < max_obj && window.isNativeValid() ) {
+ final long t2_us = Clock.currentNanos() / 1000;
+ final float dt_s = ( t2_us - t1_us ) / 1e6f;
+ t1_us = t2_us;
+
+ final float dx = velovity_obj * dt_s; // [shapeUnit]
+ // System.err.println("move ")
+
+ // Move on GL thread to have vsync for free
+ // Otherwise we would need to employ a sleep(..) w/ manual vsync
+ window.invoke(true, (drawable) -> {
+ mobileShape.move(dx, 0f, 0f);
+ return true;
+ });
+ }
+ final float has_dur_s = ( ( Clock.currentNanos() / 1000 ) - t0_us ) / 1e6f; // [us]
+ System.err.printf("Actual travel-duration %.3f s, delay %.3f s%n", has_dur_s, has_dur_s-exp_dur_s);
+ System.err.println("Group-A0 bounds "+groupA0);
+ groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; });
+ try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
+ }
+ if( !keepRunning ) {
+ window.destroy();
+ }
+ }
+
+ static Shape makeGLButton(final float sw, final float sh, final Font font, final int renderModes) {
+ final GearsES2 gears = new GearsES2(0);
+ gears.setVerbose(false);
+ gears.setClearColor(new float[] { 0.9f, 0.9f, 0.9f, 1f } );
+ final boolean[] animate = { true };
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ System.err.println("Gears Anim: Waiting");
+ try {
+ gears.waitForInit(true);
+ } catch (final InterruptedException e) { }
+ System.err.println("Gears Anim: Started");
+ while( gears.isInit() ) {
+ if( animate[0] ) {
+ final float ry = ( gears.getRotY() + 1 ) % 360;
+ gears.setRotY(ry);
+ }
+ try {
+ Thread.sleep(15);
+ } catch (final InterruptedException e) { }
+ }
+ System.err.println("Gears Anim: End");
+ }
+ }).start();
+ final int texUnit = 1;
+ final GLButton b = new GLButton(renderModes, sw,
+ sh, texUnit, gears, false /* useAlpha */);
+ b.setToggleable(true);
+ b.setToggle(true); // toggle == true -> animation
+ b.setAnimate(true);
+ b.addMouseListener(new Shape.MouseGestureAdapter() {
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ b.setAnimate( b.isToggleOn() );
+ animate[0] = b.getAnimate();
+ } } );
+ return b;
+ }
+
+}
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 e4a50b2da..5e94758dc 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -80,7 +80,7 @@ import com.jogamp.opengl.demos.graph.MSAATool;
import com.jogamp.opengl.demos.util.MiscUtils;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.math.FloatUtil;
-import com.jogamp.opengl.math.VectorUtil;
+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;
@@ -306,8 +306,8 @@ public class UISceneDemo20 implements GLEventListener {
scene.setDebugBox(options.debugBoxThickness);
}
- private void rotateButtons(float[] angdeg) {
- angdeg = VectorUtil.scaleVec3(angdeg, angdeg, FloatUtil.PI / 180.0f);
+ private void rotateButtons(final Vec3f angdeg) {
+ angdeg.scale(FloatUtil.PI / 180.0f); // -> radians
for(int i=0; i<buttons.size(); i++) {
buttons.get(i).getRotation().rotateByEuler( angdeg );
}
@@ -434,15 +434,15 @@ public class UISceneDemo20 implements GLEventListener {
@Override
public void mouseClicked(final MouseEvent e) {
final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
- if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) {
- rotateButtons(new float[] { 0f, -5f, 0f}); // left-half pressed
+ if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
+ rotateButtons(new Vec3f( 0f, -5f, 0f ) ); // left-half pressed
} else {
- rotateButtons(new float[] { 0f, 5f, 0f}); // right-half pressed
+ rotateButtons(new Vec3f( 0f, 5f, 0f ) ); // right-half pressed
}
}
@Override
public void mouseWheelMoved(final MouseEvent e) {
- rotateButtons(new float[] { 0f, e.getRotation()[1], 0f});
+ rotateButtons(new Vec3f( 0f, e.getRotation()[1], 0f ) );
} } );
buttons.add(button);
@@ -454,7 +454,7 @@ public class UISceneDemo20 implements GLEventListener {
public void mouseClicked(final MouseEvent e) {
final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
int sampleCount = scene.getSampleCount();
- if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) {
+ if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
// left-half pressed
sampleCount--;
} else {
@@ -475,7 +475,7 @@ public class UISceneDemo20 implements GLEventListener {
if( shapeEvent.shape instanceof GraphShape ) {
int quality = ((GraphShape)shapeEvent.shape).getQuality();
- if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) {
+ if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
// left-half pressed
if( quality > 0 ) {
quality--;
@@ -526,7 +526,7 @@ public class UISceneDemo20 implements GLEventListener {
button.addMouseListener(new Shape.MouseGestureAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
- rotateButtons(new float[] { 0f, 180f, 0f});
+ rotateButtons(new Vec3f ( 0f, 180f, 0f ));
} } );
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
@@ -537,7 +537,7 @@ public class UISceneDemo20 implements GLEventListener {
button.addMouseListener(new Shape.MouseGestureAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
- rotateButtons(new float[] { 180f, 0f, 0f});
+ rotateButtons(new Vec3f ( 180f, 0f, 0f ));
} } );
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
@@ -550,7 +550,7 @@ public class UISceneDemo20 implements GLEventListener {
public void mouseClicked(final MouseEvent e) {
final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
final float dx, dy;
- if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) {
+ if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
dx=-0.01f; dy=-0.005f;
} else {
dx=0.01f; dy=0.005f;
@@ -571,7 +571,7 @@ public class UISceneDemo20 implements GLEventListener {
public void mouseClicked(final MouseEvent e) {
final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
final float dc;
- if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) {
+ if( shapeEvent.objPos.x() < shapeEvent.shape.getBounds().getCenter().x() ) {
dc=-0.1f;
} else {
dc=0.1f;
@@ -901,7 +901,7 @@ public class UISceneDemo20 implements GLEventListener {
- 1.5f * truePtSizeLabel.getScaledLineHeight()
- labels[currentText].getScaledHeight(), 0f);
System.err.println("Label["+currentText+"] MOVE: "+labels[currentText]);
- System.err.println("Label["+currentText+"] MOVE: "+Arrays.toString(labels[currentText].getPosition()));
+ System.err.println("Label["+currentText+"] MOVE: "+labels[currentText].getPosition());
}
}
@@ -936,7 +936,7 @@ public class UISceneDemo20 implements GLEventListener {
labels[currentText].addMouseListener(dragZoomRotateListener);
scene.addShape(labels[currentText]);
System.err.println("Label["+currentText+"] CTOR: "+labels[currentText]);
- System.err.println("Label["+currentText+"] CTOR: "+Arrays.toString(labels[currentText].getPosition()));
+ System.err.println("Label["+currentText+"] CTOR: "+labels[currentText].getPosition());
}
if( fpsLabel.isEnabled() ) {
final String text;
@@ -968,19 +968,18 @@ public class UISceneDemo20 implements GLEventListener {
public void mouseDragged(final MouseEvent e) {
final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
if( e.getPointerCount() == 1 ) {
- final float[] tx = shapeEvent.shape.getPosition();
- actionText = String.format((Locale)null, "Pos %6.2f / %6.2f / %6.2f", tx[0], tx[1], tx[2]);
+ final Vec3f tx = shapeEvent.shape.getPosition();
+ actionText = String.format((Locale)null, "Pos %s", tx);
}
}
@Override
public void mouseWheelMoved(final MouseEvent e) {
final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
- final float[] rot = VectorUtil.scaleVec3(e.getRotation(), e.getRotation(), FloatUtil.PI / 180.0f);
+ final Vec3f rot = new Vec3f(e.getRotation()).scale( FloatUtil.PI / 180.0f );
// swap axis for onscreen rotation matching natural feel
- final float tmp = rot[0]; rot[0] = rot[1]; rot[1] = tmp;
- VectorUtil.scaleVec3(rot, rot, 2f);
- shapeEvent.shape.getRotation().rotateByEuler( rot );
+ final float tmp = rot.x(); rot.setX( rot.y() ); rot.setY( tmp );
+ shapeEvent.shape.getRotation().rotateByEuler( rot.scale( 2f ) );
}
};
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 05b3aa955..fc4b275de 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java
@@ -44,6 +44,7 @@ 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.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.graph.curve.Region;
@@ -400,9 +401,9 @@ public class UIShapeDemo01 implements GLEventListener {
button.setTransform(pmv);
System.err.println("\n\nButton: "+button);
- final float[] objPos = button.winToShapeCoord(pmv, viewport, glWinX, glWinY, new float[3]);
+ final Vec3f objPos = button.winToShapeCoord(pmv, viewport, glWinX, glWinY, new Vec3f());
if( null != objPos ) {
- System.err.println("Button: Click: Win "+glWinX+"/"+glWinY+" -> Obj "+objPos[0]+"/"+objPos[1]+"/"+objPos[1]);
+ System.err.println("Button: Click: Win "+glWinX+"/"+glWinY+" -> Obj "+objPos);
}
final int[] surfaceSize = button.getSurfaceSize(pmv, viewport, new int[2]);
@@ -416,26 +417,24 @@ public class UIShapeDemo01 implements GLEventListener {
pmv.glPushMatrix();
crossHair.setTransform(pmv);
- final float[] objPosC = crossHair.getBounds().getCenter();
+ final Vec3f objPosC = crossHair.getBounds().getCenter();
System.err.println("\n\nCrossHair: "+crossHair);
final int[] objWinPos = crossHair.shapeToWinCoord(pmv, viewport, objPosC, new int[2]);
- System.err.println("CrossHair: Obj: Obj "+objPosC[0]+"/"+objPosC[1]+"/"+objPosC[1]+" -> Win "+objWinPos[0]+"/"+objWinPos[1]);
+ System.err.println("CrossHair: Obj: Obj "+objPosC+" -> Win "+objWinPos[0]+"/"+objWinPos[1]);
- final float[] objPos2 = crossHair.winToShapeCoord(pmv, viewport, objWinPos[0], objWinPos[1], new float[3]);
- System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2[0]+"/"+objPos2[1]+"/"+objPos2[1]);
+ final Vec3f objPos2 = crossHair.winToShapeCoord(pmv, viewport, objWinPos[0], objWinPos[1], new Vec3f());
+ System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2);
- final float[] winObjPos = crossHair.winToShapeCoord(pmv, viewport, glWinX, glWinY, new float[3]);
+ final Vec3f winObjPos = crossHair.winToShapeCoord(pmv, viewport, glWinX, glWinY, new Vec3f());
if( null != winObjPos ) {
// final float[] translate = crossHair.getTranslate();
// final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] };
- final float dx = winObjPos[0] - objPosC[0];
- final float dy = winObjPos[1] - objPosC[1];
- // final float dz = winObjPos[2] - objPosT[2];
- if( !FloatUtil.isZero(dx, FloatUtil.EPSILON) || !FloatUtil.isZero(dy, FloatUtil.EPSILON) ) {
- System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy);
- crossHair.move(dx, dy, 0f);
+ final Vec3f diff = winObjPos.minus(objPosC);
+ if( !FloatUtil.isZero(diff.x(), FloatUtil.EPSILON) || !FloatUtil.isZero(diff.y(), FloatUtil.EPSILON) ) {
+ System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos+" -> diff "+diff);
+ crossHair.move(diff.x(), diff.y(), 0f);
} else {
- System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy);
+ System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos+" -> diff "+diff);
}
}
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 2097b6cfe..d4e7bfc0f 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java
@@ -68,6 +68,7 @@ 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.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLReadBufferUtil;
@@ -469,26 +470,25 @@ public class UITypeDemo01 implements GLEventListener {
pmv.glPushMatrix();
crossHair.setTransform(pmv);
- final float[] objPosC = crossHair.getBounds().getCenter();
+ final Vec3f objPosC = crossHair.getBounds().getCenter();
System.err.println("\n\nCrossHair: "+crossHair);
final int[] objWinPos = crossHair.shapeToWinCoord(pmv, viewport, objPosC, new int[2]);
- System.err.println("CrossHair: Obj: Obj "+objPosC[0]+"/"+objPosC[1]+"/"+objPosC[1]+" -> Win "+objWinPos[0]+"/"+objWinPos[1]);
+ System.err.println("CrossHair: Obj: Obj "+objPosC+" -> Win "+objWinPos[0]+"/"+objWinPos[1]);
- final float[] objPos2 = crossHair.winToShapeCoord(pmv, viewport, objWinPos[0], objWinPos[1], new float[3]);
- System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2[0]+"/"+objPos2[1]+"/"+objPos2[1]);
+ final Vec3f objPos2 = crossHair.winToShapeCoord(pmv, viewport, objWinPos[0], objWinPos[1], new Vec3f());
+ System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2);
- final float[] winObjPos = crossHair.winToShapeCoord(pmv, viewport, glWinX, glWinY, new float[3]);
+ final Vec3f winObjPos = crossHair.winToShapeCoord(pmv, viewport, glWinX, glWinY, new Vec3f());
if( null != winObjPos ) {
// final float[] translate = crossHair.getTranslate();
// final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] };
- final float dx = winObjPos[0] - objPosC[0];
- final float dy = winObjPos[1] - objPosC[1];
+ final Vec3f diff = winObjPos.minus(objPosC);
// final float dz = winObjPos[2] - objPosT[2];
- if( !FloatUtil.isZero(dx, FloatUtil.EPSILON) || !FloatUtil.isZero(dy, FloatUtil.EPSILON) ) {
- System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy);
- crossHair.move(dx, dy, 0f);
+ if( !FloatUtil.isZero(diff.x(), FloatUtil.EPSILON) || !FloatUtil.isZero(diff.y(), FloatUtil.EPSILON) ) {
+ System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos+" -> diff "+diff);
+ crossHair.move(diff.x(), diff.y(), 0f);
} else {
- System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy);
+ System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos+" -> diff "+diff);
}
}