aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java70
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java51
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java14
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java17
4 files changed, 65 insertions, 87 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index 9b71865f6..30987ec7e 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -34,14 +34,15 @@ import java.util.Comparator;
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.SVertex;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.geom.plane.Path2F;
import com.jogamp.graph.geom.plane.Winding;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.VectorUtil;
+import com.jogamp.opengl.math.Vert2fImmutable;
import com.jogamp.opengl.math.geom.AABBox;
/**
@@ -142,8 +143,6 @@ public final class OutlineShape implements Comparable<OutlineShape> {
*/
public static final int DIRTY_TRIANGLES = 1 << 2;
- private final Vertex.Factory<? extends Vertex> vertexFactory;
-
/** The list of {@link Outline}s that are part of this
* outline shape.
*/
@@ -161,25 +160,14 @@ public final class OutlineShape implements Comparable<OutlineShape> {
private float sharpness;
- private final float[] tmpV1 = new float[3];
- private final float[] tmpV2 = new float[3];
- private final float[] tmpV3 = new float[3];
-
- /** Returns the default Vertex.Factory. */
- public static Vertex.Factory<? extends Vertex> getDefaultVertexFactory() { return SVertex.factory(); }
-
- /**
- * Create a new Outline based Shape using {@link #getDefaultVertexFactory()}
- */
- public OutlineShape() {
- this(getDefaultVertexFactory());
- }
+ private final Vec3f tmpV1 = new Vec3f();
+ private final Vec3f tmpV2 = new Vec3f();
+ private final Vec3f tmpV3 = new Vec3f();
/**
* Create a new Outline based Shape
*/
- public OutlineShape(final Vertex.Factory<? extends Vertex> factory) {
- this.vertexFactory = factory;
+ public OutlineShape() {
this.outlines = new ArrayList<Outline>(3);
this.outlines.add(new Outline());
this.outlineState = VerticesState.UNDEFINED;
@@ -230,12 +218,6 @@ public final class OutlineShape implements Comparable<OutlineShape> {
dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES;
}
- /**
- * Returns the associated vertex factory of this outline shape
- * @return Vertex.Factory object
- */
- public final Vertex.Factory<? extends Vertex> vertexFactory() { return vertexFactory; }
-
/** Returns the number of {@link Outline}s. */
public final int getOutlineCount() {
return outlines.size();
@@ -437,7 +419,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* @see <a href="#windingrules">see winding rules</a>
*/
public final void addVertex(final float x, final float y, final boolean onCurve) {
- addVertex(vertexFactory.create(x, y, 0f, onCurve));
+ addVertex(new Vertex(x, y, 0f, onCurve));
}
/**
@@ -451,7 +433,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* @see <a href="#windingrules">see winding rules</a>
*/
public final void addVertex(final int position, final float x, final float y, final boolean onCurve) {
- addVertex(position, vertexFactory.create(x, y, 0f, onCurve));
+ addVertex(position, new Vertex(x, y, 0f, onCurve));
}
/**
@@ -464,7 +446,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* @see <a href="#windingrules">see winding rules</a>
*/
public final void addVertex(final float x, final float y, final float z, final boolean onCurve) {
- addVertex(vertexFactory.create(x, y, z, onCurve));
+ addVertex(new Vertex(x, y, z, onCurve));
}
/**
@@ -478,7 +460,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* @see <a href="#windingrules">see winding rules</a>
*/
public final void addVertex(final int position, final float x, final float y, final float z, final boolean onCurve) {
- addVertex(position, vertexFactory.create(x, y, z, onCurve));
+ addVertex(position, new Vertex(x, y, z, onCurve));
}
/**
@@ -495,7 +477,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* @see <a href="#windingrules">see winding rules</a>
*/
public final void addVertex(final float[] coordsBuffer, final int offset, final int length, final boolean onCurve) {
- addVertex(vertexFactory.create(coordsBuffer, offset, length, onCurve));
+ addVertex(new Vertex(coordsBuffer, offset, length, onCurve));
}
/**
@@ -513,7 +495,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* @see <a href="#windingrules">see winding rules</a>
*/
public final void addVertex(final int position, final float[] coordsBuffer, final int offset, final int length, final boolean onCurve) {
- addVertex(position, vertexFactory.create(coordsBuffer, offset, length, onCurve));
+ addVertex(position, new Vertex(coordsBuffer, offset, length, onCurve));
}
/**
@@ -578,9 +560,9 @@ public final class OutlineShape implements Comparable<OutlineShape> {
}
{
// Skip if last vertex in last outline matching this point -> already connected.
- final float[] llc = lo.getVertex(lo_sz-1).getCoord();
- if( llc[0] == points[idx+0] &&
- llc[1] == points[idx+1] ) {
+ final Vert2fImmutable llc = lo.getVertex(lo_sz-1);
+ if( llc.x() == points[idx+0] &&
+ llc.y() == points[idx+1] ) {
break;
}
}
@@ -652,9 +634,9 @@ public final class OutlineShape implements Comparable<OutlineShape> {
}
{
// Skip if last vertex in last outline matching this point -> already connected.
- final float[] llc = lo.getVertex(0).getCoord();
- if( llc[0] == points[idx+0] &&
- llc[1] == points[idx+1] ) {
+ final Vert2fImmutable llc = lo.getVertex(0);
+ if( llc.x() == points[idx+0] &&
+ llc.y() == points[idx+1] ) {
break;
}
}
@@ -790,11 +772,11 @@ public final class OutlineShape implements Comparable<OutlineShape> {
VectorUtil.midVec3(tmpV2, tmpV1, tmpV3);
//drop off-curve vertex to image on the curve
- b.setCoord(tmpV2, 0, 3);
+ b.setCoord(tmpV2);
b.setOnCurve(true);
- outline.addVertex(index, vertexFactory.create(tmpV1, 0, 3, false));
- outline.addVertex(index+2, vertexFactory.create(tmpV3, 0, 3, false));
+ outline.addVertex(index, new Vertex(tmpV1, false));
+ outline.addVertex(index+2, new Vertex(tmpV3, false));
addedVerticeCount += 2;
}
@@ -934,7 +916,7 @@ public final class OutlineShape implements Comparable<OutlineShape> {
if ( !currentVertex.isOnCurve() && !nextVertex.isOnCurve() ) {
VectorUtil.midVec3(tmpV1, currentVertex.getCoord(), nextVertex.getCoord());
System.err.println("XXX: Cubic: "+i+": "+currentVertex+", "+j+": "+nextVertex);
- final Vertex v = vertexFactory.create(tmpV1, 0, 3, true);
+ final Vertex v = new Vertex(tmpV1, true);
i++;
vertexCount++;
addedVerticeCount++;
@@ -946,8 +928,8 @@ public final class OutlineShape implements Comparable<OutlineShape> {
outlines.remove(outline);
cc--;
count--;
- } else if( 0 < vertexCount &&
- VectorUtil.isVec3Equal( outline.getVertex(0).getCoord(), 0, outline.getLastVertex().getCoord(), 0, FloatUtil.EPSILON )) {
+ } else if( 0 < vertexCount &&
+ outline.getVertex(0).getCoord().isEqual( outline.getLastVertex().getCoord() ) ) {
outline.removeVertex(vertexCount-1);
}
}
@@ -1047,10 +1029,10 @@ public final class OutlineShape implements Comparable<OutlineShape> {
* </p>
*/
public final OutlineShape transform(final AffineTransform t) {
- final OutlineShape newOutlineShape = new OutlineShape(vertexFactory);
+ final OutlineShape newOutlineShape = new OutlineShape();
final int osize = outlines.size();
for(int i=0; i<osize; i++) {
- newOutlineShape.addOutline( outlines.get(i).transform(t, vertexFactory) );
+ newOutlineShape.addOutline( outlines.get(i).transform(t) );
}
return newOutlineShape;
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index b3cee629c..799b8b7bd 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -47,6 +47,8 @@ import com.jogamp.common.util.PerfCounterCtrl;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.opengl.GLCapabilitiesImmutable;
import com.jogamp.opengl.GLProfile;
+import com.jogamp.opengl.math.Vec3f;
+import com.jogamp.opengl.math.Vec4f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.math.geom.Frustum;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -256,9 +258,9 @@ public abstract class Region {
*/
public abstract void setBufferCapacity(int verticesCount, int indicesCount);
- protected abstract void pushVertex(final float[] coords, final float[] texParams, float[] rgba);
- protected abstract void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3,
- final float[] texParams1, final float[] texParams2, final float[] texParams3, float[] rgba);
+ protected abstract void pushVertex(final Vec3f coords, final Vec3f texParams, Vec4f rgba);
+ protected abstract void pushVertices(final Vec3f coords1, final Vec3f coords2, final Vec3f coords3,
+ final Vec3f texParams1, final Vec3f texParams2, final Vec3f texParams3, Vec4f rgba);
protected abstract void pushIndex(int idx);
protected abstract void pushIndices(int idx1, int idx2, int idx3);
@@ -336,12 +338,9 @@ public abstract class Region {
this.frustum = frustum;
}
- private void pushNewVertexImpl(final Vertex vertIn, final AffineTransform transform, final float[] rgba) {
+ private void pushNewVertexImpl(final Vertex vertIn, final AffineTransform transform, final Vec4f rgba) {
if( null != transform ) {
- final float[] coordsEx1 = new float[3];
- final float[] coordsIn = vertIn.getCoord();
- transform.transform(coordsIn, coordsEx1);
- coordsEx1[2] = coordsIn[2];
+ final Vec3f coordsEx1 = transform.transform(vertIn.getCoord(), new Vec3f());
box.resize(coordsEx1);
pushVertex(coordsEx1, vertIn.getTexCoord(), rgba);
} else {
@@ -351,20 +350,11 @@ public abstract class Region {
numVertices++;
}
- private void pushNewVerticesImpl(final Vertex vertIn1, final Vertex vertIn2, final Vertex vertIn3, final AffineTransform transform, final float[] rgba) {
+ private void pushNewVerticesImpl(final Vertex vertIn1, final Vertex vertIn2, final Vertex vertIn3, final AffineTransform transform, final Vec4f rgba) {
if( null != transform ) {
- final float[] coordsEx1 = new float[3];
- final float[] coordsEx2 = new float[3];
- final float[] coordsEx3 = new float[3];
- final float[] coordsIn1 = vertIn1.getCoord();
- final float[] coordsIn2 = vertIn2.getCoord();
- final float[] coordsIn3 = vertIn3.getCoord();
- transform.transform(coordsIn1, coordsEx1);
- transform.transform(coordsIn2, coordsEx2);
- transform.transform(coordsIn3, coordsEx3);
- coordsEx1[2] = coordsIn1[2];
- coordsEx2[2] = coordsIn2[2];
- coordsEx3[2] = coordsIn3[2];
+ final Vec3f coordsEx1 = transform.transform(vertIn1.getCoord(), new Vec3f());
+ final Vec3f coordsEx2 = transform.transform(vertIn2.getCoord(), new Vec3f());
+ final Vec3f coordsEx3 = transform.transform(vertIn3.getCoord(), new Vec3f());
box.resize(coordsEx1);
box.resize(coordsEx2);
box.resize(coordsEx3);
@@ -381,11 +371,11 @@ public abstract class Region {
}
@SuppressWarnings("unused")
- private void pushNewVertexIdxImpl(final Vertex vertIn, final AffineTransform transform, final float[] rgba) {
+ private void pushNewVertexIdxImpl(final Vertex vertIn, final AffineTransform transform, final Vec4f rgba) {
pushIndex(numVertices);
pushNewVertexImpl(vertIn, transform, rgba);
}
- private void pushNewVerticesIdxImpl(final Vertex vertIn1, final Vertex vertIn2, final Vertex vertIn3, final AffineTransform transform, final float[] rgba) {
+ private void pushNewVerticesIdxImpl(final Vertex vertIn1, final Vertex vertIn2, final Vertex vertIn3, final AffineTransform transform, final Vec4f rgba) {
pushIndices(numVertices, numVertices+1, numVertices+2);
pushNewVerticesImpl(vertIn1, vertIn2, vertIn3, transform, rgba);
}
@@ -396,12 +386,15 @@ public abstract class Region {
protected static void put3s(final ShortBuffer b, final short v1, final short v2, final short v3) {
b.put(v1); b.put(v2); b.put(v3);
}
- protected static void put3f(final FloatBuffer b, final float v1, final float v2, final float v3) {
- b.put(v1); b.put(v2); b.put(v3);
+ protected static void put3f(final FloatBuffer b, final Vec3f v) {
+ b.put(v.x()); b.put(v.y()); b.put(v.z());
}
protected static void put4f(final FloatBuffer b, final float v1, final float v2, final float v3, final float v4) {
b.put(v1); b.put(v2); b.put(v3); b.put(v4);
}
+ protected static void put4f(final FloatBuffer b, final Vec4f v) {
+ b.put(v.x()); b.put(v.y()); b.put(v.z()); b.put(v.w());
+ }
private final AABBox tmpBox = new AABBox();
@@ -529,7 +522,7 @@ public abstract class Region {
* @param t the optional {@link AffineTransform} to be applied on each vertex
* @param rgbaColor if {@link #hasColorChannel()} RGBA color must be passed, otherwise value is ignored.
*/
- public final void addOutlineShape(final OutlineShape shape, final AffineTransform t, final float[] rgbaColor) {
+ public final void addOutlineShape(final OutlineShape shape, final AffineTransform t, final Vec4f rgbaColor) {
if( null != frustum ) {
final AABBox shapeBox = shape.getBounds();
final AABBox shapeBoxT;
@@ -550,7 +543,7 @@ public abstract class Region {
}
markShapeDirty();
}
- private final void addOutlineShape0(final OutlineShape shape, final AffineTransform t, final float[] rgbaColor) {
+ private final void addOutlineShape0(final OutlineShape shape, final AffineTransform t, final Vec4f rgbaColor) {
final List<Triangle> trisIn = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS);
final ArrayList<Vertex> vertsIn = shape.getVertices();
{
@@ -587,7 +580,7 @@ public abstract class Region {
}
}
}
- private final void addOutlineShape1(final OutlineShape shape, final AffineTransform t, final float[] rgbaColor) {
+ private final void addOutlineShape1(final OutlineShape shape, final AffineTransform t, final Vec4f rgbaColor) {
++perf.count;
final long t0 = Clock.currentNanos();
final List<Triangle> trisIn = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS);
@@ -682,7 +675,7 @@ public abstract class Region {
* @param t the optional {@link AffineTransform} to be applied on each vertex
* @param rgbaColor if {@link #hasColorChannel()} RGBA color must be passed, otherwise value is ignored.
*/
- public final void addOutlineShapes(final List<OutlineShape> shapes, final AffineTransform transform, final float[] rgbaColor) {
+ public final void addOutlineShapes(final List<OutlineShape> shapes, final AffineTransform transform, final Vec4f rgbaColor) {
for (int i = 0; i < shapes.size(); i++) {
addOutlineShape(shapes.get(i), transform, rgbaColor);
}
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 2f518d1cc..89a48e0c8 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -33,6 +33,7 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLUniformData;
+import com.jogamp.opengl.math.Vec4f;
import jogamp.common.os.PlatformPropsImpl;
import jogamp.graph.curve.opengl.shader.UniformNames;
@@ -241,13 +242,14 @@ public class RenderState {
weight[0] = v;
}
-
- public final float[] getColorStatic(final float[] rgbaColor) {
- System.arraycopy(colorStatic, 0, rgbaColor, 0, 4);
- return rgbaColor;
+ public final Vec4f getColorStatic(final Vec4f rgbaColor) {
+ return rgbaColor.set(colorStatic);
}
- public final void setColorStatic(final float[] rgbaColor){
- System.arraycopy(rgbaColor, 0, colorStatic, 0, 4);
+ public final void setColorStatic(final Vec4f rgbaColor){
+ colorStatic[0] = rgbaColor.x();
+ colorStatic[1] = rgbaColor.y();
+ colorStatic[2] = rgbaColor.z();
+ colorStatic[3] = rgbaColor.w();
}
public final void setColorStatic(final float r, final float g, final float b, final float a){
colorStatic[0] = r;
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
index 237d93184..6beb11be1 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -33,6 +33,7 @@ import java.util.Iterator;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLException;
+import com.jogamp.opengl.math.Vec4f;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
@@ -82,7 +83,7 @@ public class TextRegionUtil {
* @return the bounding box of the given string by taking each glyph's font em-sized [0..1] OutlineShape into account.
*/
public static AABBox addStringToRegion(final Region region, final Font font, final AffineTransform transform,
- final CharSequence str, final float[] rgbaColor) {
+ final CharSequence str, final Vec4f rgbaColor) {
return addStringToRegion(region, font, transform, str, rgbaColor, new AffineTransform(), new AffineTransform());
}
@@ -105,7 +106,7 @@ public class TextRegionUtil {
* @return the bounding box of the given string by taking each glyph's font em-sized [0..1] OutlineShape into account.
*/
public static AABBox addStringToRegion(final Region region, final Font font, final AffineTransform transform,
- final CharSequence str, final float[] rgbaColor,
+ final CharSequence str, final Vec4f rgbaColor,
final AffineTransform temp1, final AffineTransform temp2) {
final Font.GlyphVisitor visitor = new Font.GlyphVisitor() {
@Override
@@ -113,7 +114,7 @@ public class TextRegionUtil {
if( glyph.isWhiteSpace() ) {
return;
}
- region.addOutlineShape(glyph.getShape(), t, region.hasColorChannel() ? rgbaColor : null);
+ region.addOutlineShape(glyph.getShape(), t, rgbaColor);
}
};
return font.processString(visitor, transform, str, temp1, temp2);
@@ -167,7 +168,7 @@ public class TextRegionUtil {
*/
public AABBox drawString3D(final GL2ES2 gl,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ final Vec4f rgbaColor, final int[/*1*/] sampleCount) {
if( !renderer.isInitialized() ) {
throw new GLException("TextRendererImpl01: not initialized!");
}
@@ -193,7 +194,7 @@ public class TextRegionUtil {
*/
public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ final Vec4f rgbaColor, final int[/*1*/] sampleCount) {
return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform());
}
@@ -228,7 +229,7 @@ public class TextRegionUtil {
*/
public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final float[] rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
+ final Vec4f rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
@@ -246,7 +247,7 @@ public class TextRegionUtil {
* </p>
*/
public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
- final Font font, final CharSequence str, final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ final Font font, final CharSequence str, final Vec4f rgbaColor, final int[/*1*/] sampleCount) {
return drawString3D(gl, region, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform());
}
@@ -278,7 +279,7 @@ public class TextRegionUtil {
* @throws Exception if TextRenderer not initialized
*/
public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
- final Font font, final CharSequence str, final float[] rgbaColor,
+ final Font font, final CharSequence str, final Vec4f rgbaColor,
final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");