From 59aa8737528743b83cf56b804c9d713bc325c97c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 May 2011 13:07:42 +0200 Subject: Merging OutlineShape.VerticesState enum type (John Pritchard https://github.com/syntelos/jogl/commit/05a7ec92d30e1e688b1eb7cc317cad83a0e8fd60#L0R59) --- .../com/jogamp/graph/curve/OutlineShape.java | 31 +++++++++++++++++----- .../jogamp/graph/curve/opengl/RegionRenderer.java | 4 +-- 2 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src/jogl/classes/com/jogamp') diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index c995b3749..d0413b1e4 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -35,6 +35,7 @@ import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.math.VectorUtil; +import com.jogamp.graph.curve.OutlineShape.VerticesState; import com.jogamp.graph.curve.tess.CDTriangulator2D; /** A Generic shape objects which is defined by a list of Outlines. @@ -53,7 +54,7 @@ import com.jogamp.graph.curve.tess.CDTriangulator2D; addVertex(...) addVertex(...) addVertex(...) - addEnptyOutline() + addEmptyOutline() addVertex(...) addVertex(...) addVertex(...) @@ -91,9 +92,21 @@ import com.jogamp.graph.curve.tess.CDTriangulator2D; * @see Region */ public class OutlineShape { + /** + * Outline has original user state (vertices) until transformed. + */ + public enum VerticesState { + ORIGINAL(0), QUADRATIC_NURBS(1); - public static final int QUADRATIC_NURBS = 10; + public final int state; + + VerticesState(int state){ + this.state = state; + } + } + private final Vertex.Factory vertexFactory; + private VerticesState outlineState; /** The list of {@link Outline}s that are part of this * outline shape. @@ -105,6 +118,7 @@ public class OutlineShape { public OutlineShape(Vertex.Factory factory) { vertexFactory = factory; outlines.add(new Outline()); + outlineState = VerticesState.ORIGINAL; } /** Returns the associated vertex factory of this outline shape @@ -205,11 +219,15 @@ public class OutlineShape { /** Make sure that the outlines represent * the specified destinationType, if not * transform outlines to destination type. - * @param destinationType The curve type needed + * @param destinationType TODO */ - public void transformOutlines(int destinationType){ - if(destinationType == QUADRATIC_NURBS){ - transformOutlinesQuadratic(); + public void transformOutlines(VerticesState destinationType){ + if(outlineState != destinationType){ + if(destinationType == VerticesState.QUADRATIC_NURBS){ + transformOutlinesQuadratic(); + } else { + throw new IllegalStateException("destinationType "+destinationType.name()+" not supported (currently "+outlineState.name()+")"); + } } } @@ -240,6 +258,7 @@ public class OutlineShape { newOutlines.add(newOutline); } outlines = newOutlines; + outlineState = VerticesState.QUADRATIC_NURBS; } private void generateVertexIds(){ 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 03a696f35..2d614d279 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -113,7 +113,7 @@ public abstract class RegionRenderer extends Renderer { protected Region createRegion(GL2ES2 gl, OutlineShape outlineShape) { Region region = RegionFactory.create(rs, renderType); - outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); + outlineShape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); ArrayList triangles = (ArrayList) outlineShape.triangulate(); ArrayList vertices = (ArrayList) outlineShape.getVertices(); region.addVertices(vertices); @@ -133,7 +133,7 @@ public abstract class RegionRenderer extends Renderer { int numVertices = region.getNumVertices(); for(OutlineShape outlineShape:outlineShapes){ - outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); + outlineShape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); ArrayList triangles = outlineShape.triangulate(); region.addTriangles(triangles); -- cgit v1.2.3