From d75835796900cac602f7e5789601ffba0a27efe2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 May 2011 14:39:17 +0200 Subject: Graph: More std. functionality (equals, clone) / Better in-place transformation (cubic -> quadratic) Impl. more of John Pritchard proposal https://github.com/syntelos/jogl/commit/05a7ec92d30e1e688b1eb7cc317cad83a0e8fd60 +++ More std. functionality (equals, deep clone) of AABBox, Vertex, Outline and OutlineShape. Simplify Vertex: - Remove 2 component constructor - Add on-curve in Vertex.Factory / Constructor - Adding equals(Object) - Remove Comparable/compareTo, since we only can make an equals statement Outline/OutlineShape: Handle dirty flag for boundary (new set/remove operation) OutlineShape: Better in-place transformation (cubic -> quadratic) --- .../com/jogamp/graph/geom/opengl/SVertex.java | 116 ++++++++++----------- 1 file changed, 56 insertions(+), 60 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java') diff --git a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java index 6241d60df..9dade17e9 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java @@ -27,7 +27,6 @@ */ package com.jogamp.graph.geom.opengl; - import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.math.VectorUtil; @@ -38,7 +37,7 @@ import com.jogamp.graph.math.VectorUtil; public class SVertex implements Vertex { private int id = Integer.MAX_VALUE; protected float[] coord = new float[3]; - protected boolean onCurve = true; + protected boolean onCurve; private float[] texCoord = new float[2]; static final Factory factory = new Factory(); @@ -46,133 +45,130 @@ public class SVertex implements Vertex { public static Factory factory() { return factory; } public static class Factory implements Vertex.Factory { - @Override public SVertex create() { return new SVertex(); } - @Override - public SVertex create(float x, float y) { - return new SVertex(x, y); - } - - @Override - public SVertex create(float x, float y, float z) { - return new SVertex(x, y, z); + public SVertex create(float x, float y, float z, boolean onCurve) { + return new SVertex(x, y, z, onCurve); } - @Override - public SVertex create(float[] coordsBuffer, int offset, int length) { - return new SVertex(coordsBuffer, offset, length); + public SVertex create(float[] coordsBuffer, int offset, int length, boolean onCurve) { + return new SVertex(coordsBuffer, offset, length, onCurve); } } public SVertex() { } - public SVertex(float x, float y) { - setCoord(x, y); - } - public SVertex(float x, float y, float z) { + public SVertex(float x, float y, float z, boolean onCurve) { setCoord(x, y, z); - } - public SVertex(float[] coordsBuffer, int offset, int length) { + setOnCurve(onCurve); + } + + public SVertex(float[] coordsBuffer, int offset, int length, boolean onCurve) { setCoord(coordsBuffer, offset, length); + setOnCurve(onCurve); } - public void setCoord(float x, float y) { - this.coord[0] = x; - this.coord[1] = y; - this.coord[2] = 0f; + public SVertex(float[] coordsBuffer, int offset, int length, + float[] texCoordsBuffer, int offsetTC, int lengthTC, boolean onCurve) { + setCoord(coordsBuffer, offset, length); + setTexCoord(texCoordsBuffer, offsetTC, lengthTC); + setOnCurve(onCurve); } - - public void setCoord(float x, float y, float z) { + + public final void setCoord(float x, float y, float z) { this.coord[0] = x; this.coord[1] = y; this.coord[2] = z; } - public void setCoord(float[] coordsBuffer, int offset, int length) { - if(length > coordsBuffer.length - offset) { - throw new IndexOutOfBoundsException("coordsBuffer too small: "+coordsBuffer.length+" - "+offset+" < "+length); - } - if(length > 3) { - throw new IndexOutOfBoundsException("length too big: "+length+" > "+3); - } - int i=0; - while(i