aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-30 20:55:53 +0200
committerSven Gothel <[email protected]>2023-03-30 20:55:53 +0200
commit4f2e451d9f6d8edadc1dc392d3831d3b25675693 (patch)
tree075ca416bd3a74e590600a52bf5a34e4ea50b36c /src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java
parent68092a50c3b5d7fca72b1b9dc01d59b4444bcefb (diff)
GraphUI: Fix debug-box and allow API access in Shape (off, thickness fractional to box size) and Scene for all Shapes.
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/GraphShape.java60
1 files changed, 37 insertions, 23 deletions
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();
}