aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-20 05:01:38 +0100
committerSven Göthel <[email protected]>2024-01-20 05:01:38 +0100
commitc1531c3d99b19032040018b9414263b0d3000147 (patch)
tree93ad05df0398d430884350166a88371f82143947 /src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
parent5cca51e32999a882e2a5f00cb45ecafc824ffd86 (diff)
Graph Clipping: Use Frustum Clipping using AABBox -> Mv transformed Cube -> Frustum mapping + GraphUI Support
AABBox clipping naturally couldn't be transformed into 3D Model-View (Mv) Space, as it is axis aligned and only provided 2 points (min/max). Therefor we map the Group's AABBox to a 8-point Cube, perform the Mv-transformation and then produce the 6-plane Frustum. As before, we cull fully outside shapes within the Group's draw method and perform fragment clipping with same Frustum planes in the shader. With clipping enabled, the 3D z-axis getBounds() depth will be slightly increased for functional Frustum operation. This is also done for setFixedSize(Vec2f). The Frustum planes are copied to the Graph shader via float[4*6] -> uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F each {n.x, n.y, n.z, d} +++ Concludes related work of below commits - 1040bed4ecc6f4598ea459f1073a9240583fc3c3 - 5cca51e32999a882e2a5f00cb45ecafc824ffd86
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
index f84c3cf5a..838a39254 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
@@ -39,6 +39,9 @@ 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.Cube;
+import com.jogamp.math.geom.Frustum;
+import com.jogamp.math.util.PMVMatrix4f;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -134,7 +137,7 @@ public class RangedGroup extends Widget {
}
public Group getContent() { return content; }
- public Vec2f getContentSize() { return clippedContent.getFixedSize(); }
+ public Vec2f getContentSize(final Vec2f out) { return clippedContent.getFixedSize(out); }
public Group getClippedContent() { return clippedContent; }
public RangeSlider getHorizSlider() { return horizSlider; }
public RangeSlider getVertSlider() { return vertSlider; }
@@ -145,7 +148,7 @@ public class RangedGroup extends Widget {
super.validateImpl(gl, glp);
final AABBox b = content.getBounds();
- final Vec2f contentSize = getContentSize();
+ final Vec3f contentSize = clippedContent.getFixedSize();
contentPosZero.set(0, 0);
if( null != horizSlider ) {
horizSlider.setMinMax(new Vec2f(0, content.getBounds().getWidth()), 0);
@@ -164,12 +167,15 @@ public class RangedGroup extends Widget {
@Override
protected void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final Vec4f rgba) {
if( content.isVisible() ) {
- // Mv pre-multiplied AABBox, clippedContent is on same PMV
- final AABBox clipBBox = clippedContent.getBounds().transform(renderer.getMatrix().getMv(), tempBB);
- content.setClipBBox(clipBBox);
+ final PMVMatrix4f pmv = renderer.getMatrix();
+
+ // Mv pre-multiplied Frustum, clippedContent is on same PMV
+ final Frustum clipFrustum = tempC00.set( clippedContent.getBounds() ).transform( pmv.getMv() ).updateFrustumPlanes(tempF00);
+ content.setClipFrustum(clipFrustum);
super.drawImpl0(gl, renderer, rgba);
- content.setClipBBox(null);
+ content.setClipFrustum(null);
}
}
- private final AABBox tempBB = new AABBox(); // OK, synchronized
+ private final Frustum tempF00 = new Frustum(); // OK, synchronized
+ private final Cube tempC00 = new Cube(); // OK, synchronized
}