From 3a0aadb747fe3a62799278fc97cf777662851a94 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 10 Apr 2023 06:12:37 +0200 Subject: GraphUI UISceneDemo03: Use Group as a Container to hold all Glyphs and have them no more interacting when arrived. Play: Drag 'em ;-) --- .../jogamp/opengl/demos/graph/ui/UISceneDemo03.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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 d196b58c0..35f925f82 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java @@ -37,6 +37,7 @@ import com.jogamp.common.util.IOUtil; import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.ui.Group; import com.jogamp.graph.ui.Scene; import com.jogamp.graph.ui.Scene.PMVMatrixSetup; import com.jogamp.graph.ui.shapes.GlyphShape; @@ -128,6 +129,12 @@ public class UISceneDemo03 { scene.setPMVMatrixSetup(new MyPMVMatrixSetup()); scene.setDebugBox(options.debugBoxThickness); + final Group glyphGroup = new Group(); + scene.addShape(glyphGroup); + + // scene.setFrustumCullingEnabled(true); + glyphGroup.setFrustumCullingEnabled(true); + final Animator animator = new Animator(); animator.setUpdateFPSFrames(1 * 60, null); // System.err); @@ -201,6 +208,7 @@ public class UISceneDemo03 { final AABBox sceneBox = scene.getBounds(); System.err.println("SceneBox " + sceneBox); System.err.println("Frustum " + scene.getMatrix().getFrustum()); + System.err.println("GlyphGroup.0: "+glyphGroup); final Label statusLabel; { @@ -246,7 +254,6 @@ public class UISceneDemo03 { // final List glyphShapes = new ArrayList(); - final List addedGlyphShapes = new ArrayList(); final float pixPerMM, dpiV; { @@ -268,8 +275,7 @@ public class UISceneDemo03 { } z_only = !z_only; window.invoke(true, (drawable) -> { - scene.removeShapes(drawable.getGL().getGL2ES2(), addedGlyphShapes); - addedGlyphShapes.clear(); + glyphGroup.removeAllShapes(drawable.getGL().getGL2ES2(), scene.getRenderer()); return true; }); @@ -300,10 +306,9 @@ public class UISceneDemo03 { } // just add destText to scene to be cleaned up, invisible testGlyph.setEnabled(false); - scene.addShape(testGlyph); + glyphGroup.addShape(testGlyph); } - scene.addShapes(glyphShapes); - addedGlyphShapes.addAll(glyphShapes); + glyphGroup.addShapes(glyphShapes); final float pos_eps = FloatUtil.EPSILON * 5000; // ~= 0.0005960 final float rot_eps = FloatUtil.adegToRad(0.5f); // 1 adeg ~= 0.01745 rad @@ -341,6 +346,7 @@ public class UISceneDemo03 { } } glyph.moveTo(target.x(), target.y(), target.z()); + glyph.setInteractive(false); q.setIdentity(); glyphShapes.remove(idx); continue; -- cgit v1.2.3