From 4f2e451d9f6d8edadc1dc392d3831d3b25675693 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 30 Mar 2023 20:55:53 +0200 Subject: GraphUI: Fix debug-box and allow API access in Shape (off, thickness fractional to box size) and Scene for all Shapes. --- .../classes/com/jogamp/graph/ui/gl/GraphShape.java | 60 +++++++++++++--------- 1 file changed, 37 insertions(+), 23 deletions(-) (limited to 'src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java') diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java index 8153d2b23..f2c60a12c 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java @@ -147,40 +147,54 @@ public abstract class GraphShape extends Shape { region.clear(gl); } addShapeToRegion(); + if( hasDebugBox() ) { + addDebugOutline(); + } region.setQuality(regionQuality); } else if( isStateDirty() ) { region.markStateDirty(); } } - protected OutlineShape createDebugOutline(final OutlineShape shape, final AABBox box) { - final float d = 0.025f; - final float tw = box.getWidth() + d*2f; - final float th = box.getHeight() + d*2f; - - final float minX = box.getMinX() - d; - final float minY = box.getMinY() - d; - final float z = 0; // box.getMinZ() + 0.025f; - - // CCW! - shape.moveTo(minX, minY, z); - shape.lineTo(minX+tw, minY, z); - shape.lineTo(minX+tw, minY + th, z); - shape.lineTo(minX, minY + th, z); - shape.closePath(); - - // shape.addVertex(minX, minY, z, true); - // shape.addVertex(minX+tw, minY, z, true); - // shape.addVertex(minX+tw, minY + th, z, true); - // shape.addVertex(minX, minY + th, z, true); - // shape.closeLastOutline(true); - - return shape; + private final float[] dbgColor = {0.3f, 0.3f, 0.3f, 0.5f}; + + protected void addDebugOutline() { + final OutlineShape shape = new OutlineShape(vertexFactory); + final float x1 = box.getMinX(); + final float x2 = box.getMaxX(); + final float y1 = box.getMinY(); + final float y2 = box.getMaxY(); + final float z = box.getCenter()[2]; // 0; // box.getMinZ() + 0.025f; + { + // Outer OutlineShape as Winding.CCW. + shape.moveTo(x1, y1, z); + shape.lineTo(x2, y1, z); + shape.lineTo(x2, y2, z); + shape.lineTo(x1, y2, z); + shape.lineTo(x1, y1, z); + shape.closeLastOutline(true); + shape.addEmptyOutline(); + } + { + // Inner OutlineShape as Winding.CW. + final float dxy0 = box.getWidth() < box.getHeight() ? box.getWidth() : box.getHeight(); + final float dxy = dxy0 * getDebugBox(); + shape.moveTo(x1+dxy, y1+dxy, z); + shape.lineTo(x1+dxy, y2-dxy, z); + shape.lineTo(x2-dxy, y2-dxy, z); + shape.lineTo(x2-dxy, y1+dxy, z); + shape.lineTo(x1+dxy, y1+dxy, z); + shape.closeLastOutline(true); + } + shape.setIsQuadraticNurbs(); + shape.setSharpness(oshapeSharpness); + region.addOutlineShape(shape, null, dbgColor); } protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { } protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { } + protected abstract void addShapeToRegion(); } -- cgit v1.2.3