aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-30 04:18:56 +0200
committerSven Gothel <[email protected]>2023-03-30 04:18:56 +0200
commit901df212f75db8cf51349f53abeaed6ef62b61d3 (patch)
tree8bf4f7c7ca9cab4ecd4180b98e8125d979a92dac /src/graphui/classes
parentf569ac9222125372b97bd73aa5cb5ad05a4f7da9 (diff)
GraphUI Shape.setTransform(..): Scale before rotate to preserve target-size in rotation
Diffstat (limited to 'src/graphui/classes')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
index 2d6f0950b..509479cc9 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
@@ -413,7 +413,7 @@ public abstract class Shape {
/**
* Setup the pre-selected {@link GLMatrixFunc#GL_MODELVIEW} {@link PMVMatrix} for this object.
* - Scale shape from its center position
- * - Rotate shape around optional pivot, see {@link #setRotationPivot(float[])}), otherwise rotate around its center (default)
+ * - Rotate shape around optional scaled pivot, see {@link #setRotationPivot(float[])}), otherwise rotate around its scaled center (default)
* <p>
* Shape's origin should be bottom-left @ 0/0 to have build-in drag-zoom work properly.
* </p>
@@ -435,29 +435,29 @@ public abstract class Shape {
if( sameScaleRotatePivot ) {
// Scale shape from its center position and rotate around its center
pmv.glTranslatef(ctr[0]*scale[0], ctr[1]*scale[1], ctr[2]*scale[2]); // add-back center, scaled
- pmv.glScalef(scale[0], scale[1], scale[2]);
pmv.glRotate(rotation);
+ pmv.glScalef(scale[0], scale[1], scale[2]);
pmv.glTranslatef(-ctr[0], -ctr[1], -ctr[2]); // move to center
} else if( hasRotate || hasScale ) {
- if( hasScale ) {
- // Scale shape from its center position
- pmv.glTranslatef(ctr[0]*scale[0], ctr[1]*scale[1], ctr[2]*scale[2]); // add-back center, scaled
- pmv.glScalef(scale[0], scale[1], scale[2]);
- pmv.glTranslatef(-ctr[0], -ctr[1], -ctr[2]); // move to center
- }
if( hasRotate ) {
if( hasRotPivot ) {
- // Rotate shape around its pivot
- pmv.glTranslatef(rotPivot[0], rotPivot[1], rotPivot[2]); // pivot back from rot-pivot
+ // Rotate shape around its scaled pivot
+ pmv.glTranslatef(rotPivot[0]*scale[0], rotPivot[1]*scale[1], rotPivot[2]*scale[2]); // pivot back from rot-pivot, scaled
pmv.glRotate(rotation);
- pmv.glTranslatef(-rotPivot[0], -rotPivot[1], -rotPivot[2]); // pivot to rot-pivot
+ pmv.glTranslatef(-rotPivot[0]*scale[0], -rotPivot[1]*scale[1], -rotPivot[2]*scale[2]); // pivot to rot-pivot, scaled
} else {
- // Rotate shape around its center
- pmv.glTranslatef(ctr[0], ctr[1], ctr[2]); // pivot back from center-pivot
+ // Rotate shape around its scaled center
+ pmv.glTranslatef(ctr[0]*scale[0], ctr[1]*scale[1], ctr[2]*scale[2]); // pivot back from center-pivot, scaled
pmv.glRotate(rotation);
- pmv.glTranslatef(-ctr[0], -ctr[1], -ctr[2]); // pivot to center-pivot
+ pmv.glTranslatef(-ctr[0]*scale[0], -ctr[1]*scale[1], -ctr[2]*scale[2]); // pivot to center-pivot, scaled
}
}
+ if( hasScale ) {
+ // Scale shape from its center position
+ pmv.glTranslatef(ctr[0]*scale[0], ctr[1]*scale[1], ctr[2]*scale[2]); // add-back center, scaled
+ pmv.glScalef(scale[0], scale[1], scale[2]);
+ pmv.glTranslatef(-ctr[0], -ctr[1], -ctr[2]); // move to center
+ }
}
// TODO: Add alignment features.
}