summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java44
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java13
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java4
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java10
-rw-r--r--src/jogl/classes/com/jogamp/graph/geom/Outline.java44
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Quaternion.java37
6 files changed, 111 insertions, 41 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index cb99fbfa4..0d3a61fac 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -29,12 +29,16 @@ package com.jogamp.graph.curve;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
+
+import jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.curve.tess.Triangulation;
import com.jogamp.graph.curve.tess.Triangulator;
import com.jogamp.graph.geom.Outline;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
+import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.math.geom.AABBox;
@@ -643,29 +647,51 @@ public class OutlineShape implements Comparable<OutlineShape> {
return triangles;
}
- /** Sort the outlines from large
- * to small depending on the AABox
+ /**
+ * Return a transformed instance with all {@link Outline}s are copied and transformed.
+ * <p>
+ * Note: Triangulated data is lost in returned instance!
+ * </p>
+ */
+ public OutlineShape transform(AffineTransform t) {
+ final OutlineShape newOutlineShape = new OutlineShape(vertexFactory);
+ final int osize = outlines.size();
+ for(int i=0; i<osize; i++) {
+ newOutlineShape.addOutline( outlines.get(i).transform(t) );
+ }
+ return newOutlineShape;
+ }
+
+ /**
+ * Sort the outlines from large
+ * to small depending on the AABox
*/
private void sortOutlines() {
- Collections.sort(outlines);
- Collections.reverse(outlines);
+ Collections.sort(outlines, reversSizeComparator);
}
+ private static Comparator<Outline> reversSizeComparator = new Comparator<Outline>() {
+ @Override
+ public int compare(Outline o1, Outline o2) {
+ return o2.compareTo(o1); // reverse !
+ } };
+
/**
- * Compare two outline shapes with Bounding Box area
- * as criteria.
+ * Compare two outline shape's Bounding Box size.
+ * @see AABBox#getSize()
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public final int compareTo(final OutlineShape other) {
final float thisSize = getBounds().getSize();
final float otherSize = other.getBounds().getSize();
- if( thisSize < otherSize ){
+ if( FloatUtil.equals(thisSize, otherSize, FloatUtil.EPSILON) ) {
+ return 0;
+ } else if( thisSize < otherSize ){
return -1;
- } else if( thisSize > otherSize ) {
+ } else {
return 1;
}
- return 0; // FIXME: No epsilon, i.e. smallest accurate float value ?
}
private void validateBoundingBox() {
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java
new file mode 100644
index 000000000..b1c99f5ed
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShapeXForm.java
@@ -0,0 +1,13 @@
+package com.jogamp.graph.curve;
+
+import jogamp.graph.geom.plane.AffineTransform;
+
+public class OutlineShapeXForm {
+ public final OutlineShape shape;
+ public final AffineTransform t;
+
+ public OutlineShapeXForm(final OutlineShape shape, final AffineTransform t) {
+ this.shape = shape;
+ this.t = t;
+ }
+} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index bff7c905f..741121343 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -74,7 +74,7 @@ public abstract class RegionRenderer {
gl.glEnable(GL.GL_BLEND);
gl.glBlendEquation(GL.GL_FUNC_ADD); // default
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- renderer.rs.setHintBits(RenderState.BITHINT_BLENDING_ENABLED);
+ renderer.rs.setHintMask(RenderState.BITHINT_BLENDING_ENABLED);
}
};
@@ -90,7 +90,7 @@ public abstract class RegionRenderer {
public static final GLCallback defaultBlendDisable = new GLCallback() {
@Override
public void run(final GL gl, final RegionRenderer renderer) {
- renderer.rs.clearHintBits(RenderState.BITHINT_BLENDING_ENABLED);
+ renderer.rs.clearHintMask(RenderState.BITHINT_BLENDING_ENABLED);
gl.glDisable(GL.GL_BLEND);
}
};
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
index d6eac19de..490af140a 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -44,10 +44,10 @@ public abstract class RenderState {
private static final String thisKey = "jogamp.graph.curve.RenderState" ;
/**
- * Bitfield hint, {@link #isHintBitSet(int) if set}
+ * Bitfield hint, {@link #isHintMaskSet(int) if set}
* stating <i>enabled</i> {@link GL#GL_BLEND}, otherwise <i>disabled</i>.
* <p>
- * Shall be set via {@link #setHintBits(int)} and cleared via {@link #clearHintBits(int)}.
+ * Shall be set via {@link #setHintMask(int)} and cleared via {@link #clearHintMask(int)}.
* </p>
* <p>
* Due to alpha blending and multipass rendering, e.g. {@link Region#VBAA_RENDERING_BIT},
@@ -94,13 +94,13 @@ public abstract class RenderState {
public final PMVMatrix pmvMatrix() { return pmvMatrix; }
public final GLUniformData getPMVMatrix() { return gcu_PMVMatrix; }
- public final boolean isHintBitSet(int mask) {
+ public final boolean isHintMaskSet(int mask) {
return mask == ( hintBitfield & mask );
}
- public final void setHintBits(int mask) {
+ public final void setHintMask(int mask) {
hintBitfield |= mask;
}
- public final void clearHintBits(int mask) {
+ public final void clearHintMask(int mask) {
hintBitfield &= ~mask;
}
diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java
index 2d9d74966..b299524c0 100644
--- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java
+++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java
@@ -29,7 +29,10 @@ package com.jogamp.graph.geom;
import java.util.ArrayList;
+import jogamp.graph.geom.plane.AffineTransform;
+
import com.jogamp.graph.geom.Vertex;
+import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.math.geom.AABBox;
@@ -181,21 +184,18 @@ public class Outline implements Cloneable, Comparable<Outline> {
return false;
}
- /** Compare two outlines with Bounding Box area
- * as criteria.
- * @see java.lang.Comparable#compareTo(java.lang.Object)
+ /**
+ * Return a transformed instance with all vertices are copied and transformed.
*/
- @Override
- public final int compareTo(Outline outline) {
- float size = getBounds().getSize();
- float newSize = outline.getBounds().getSize();
- if(size < newSize){
- return -1;
- }
- else if(size > newSize){
- return 1;
+ public final Outline transform(AffineTransform t) {
+ final Outline newOutline = new Outline();
+ final int vsize = vertices.size();
+ for(int i=0; i<vsize; i++) {
+ final Vertex v = vertices.get(i);
+ newOutline.addVertex(t.transform(v, null));
}
- return 0;
+ newOutline.closed = this.closed;
+ return newOutline;
}
private final void validateBoundingBox() {
@@ -214,6 +214,24 @@ public class Outline implements Cloneable, Comparable<Outline> {
}
/**
+ * Compare two outline's Bounding Box size.
+ * @see AABBox#getSize()
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public final int compareTo(final Outline other) {
+ final float thisSize = getBounds().getSize();
+ final float otherSize = other.getBounds().getSize();
+ if( FloatUtil.equals(thisSize, otherSize, FloatUtil.EPSILON) ) {
+ return 0;
+ } else if(thisSize < otherSize){
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
+ /**
* @param obj the Object to compare this Outline with
* @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order
*/
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
index ab419e3cd..56d270380 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
@@ -380,18 +380,31 @@ public class Quaternion {
final float vecX = vecIn[0+vecInOffset];
final float vecY = vecIn[1+vecInOffset];
final float vecZ = vecIn[2+vecInOffset];
- vecOut[0+vecOutOffset] = w * w * vecX + 2f * y * w * vecZ
- - 2f * z * w * vecY + x * x * vecX
- + 2f * y * x * vecY + 2f * z * x * vecZ
- - z * z * vecX - y * y * vecX;
- vecOut[1+vecOutOffset] = 2f * x * y * vecX + y * y * vecY
- + 2f * z * y * vecZ + 2f * w * z * vecX
- - z * z * vecY + w * w * vecY
- - 2f * x * w * vecZ - x * x * vecY;
- vecOut[2+vecOutOffset] = 2f * x * z * vecX + 2f * y * z * vecY
- + z * z * vecZ - 2f * w * y * vecX
- - y * y * vecZ + 2f * w * x * vecY
- - x * x * vecZ + w * w * vecZ;
+ final float x_x = x*x;
+ final float y_y = y*y;
+ final float z_z = z*z;
+ final float w_w = w*w;
+
+ vecOut[0+vecOutOffset] = w_w * vecX
+ + x_x * vecX
+ - z_z * vecX
+ - y_y * vecX
+ + 2f * ( y*w*vecZ - z*w*vecY + y*x*vecY + z*x*vecZ );
+ ;
+
+ vecOut[1+vecOutOffset] = y_y * vecY
+ - z_z * vecY
+ + w_w * vecY
+ - x_x * vecY
+ + 2f * ( x*y*vecX + z*y*vecZ + w*z*vecX - x*w*vecZ );
+ ;
+
+ vecOut[2+vecOutOffset] = z_z * vecZ
+ - y_y * vecZ
+ - x_x * vecZ
+ + w_w * vecZ
+ + 2f * ( x*z*vecX + y*z*vecY - w*y*vecX + w*x*vecY );
+ ;
}
return vecOut;
}