From 88b6b350e7e46ae7c51ba9bd0edd704260dd7a44 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 4 Feb 2011 02:23:58 +0000 Subject: Some code added to test planar --- src/tesseract/tests/EggTest.java | 65 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/tesseract/tests/EggTest.java b/src/tesseract/tests/EggTest.java index 2e254b2..6aebccf 100644 --- a/src/tesseract/tests/EggTest.java +++ b/src/tesseract/tests/EggTest.java @@ -15,6 +15,8 @@ import javax.vecmath.*; import tesseract.objects.Ellipsoid; +//import tesseract.objects.Ellipsoid; + @SuppressWarnings("restriction") public class EggTest { private JFrame appFrame; @@ -22,6 +24,23 @@ public class EggTest { private Transform3D icc3D; private TransformGroup iccTG; + private double[] m_VertexArray = { 1, 1, 0, //0 + 0, 3, 0, //1 + 1, 5, 0, //2 + 2, 4, 0, //3 + 4, 5, 0, //4 + 3, 3, 0, //5 + 4, 2, 0, //6 + 4, 0, 0, //7 + 3, 0, 0, //8 + 2, 1, 0, //9 + // these are vertices for the hole + 1, 3, 0, //10 + 2, 3, 0, //11 + 3, 2, 0, //12 + 3, 1, 0, //13 + 2, 2, 0 };//14 + public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -41,7 +60,7 @@ public class EggTest { icc3D = new Transform3D(); iccTG = new TransformGroup(); iccTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); - iccTG.addChild(createEllipsoid()); + iccTG.addChild(createPlanar()); scene.addChild(iccTG); scene.compile(); @@ -101,5 +120,49 @@ public class EggTest { return bg; } + + private Group createPlanar() { + + TransformGroup objTrans = new TransformGroup(); + // triangulate the polygon + GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); + + gi.setCoordinates(m_VertexArray); + + int[] stripCountArray = { 10, 5 }; + int[] countourCountArray = { stripCountArray.length }; + + gi.setContourCounts(countourCountArray); + gi.setStripCounts(stripCountArray); + + Triangulator triangulator = new Triangulator(); + triangulator.triangulate(gi); + + NormalGenerator normalGenerator = new NormalGenerator(); + normalGenerator.generateNormals(gi); + + // create an appearance + Appearance ap = new Appearance(); + + // render as a wireframe + PolygonAttributes polyAttrbutes = new PolygonAttributes(); + polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE); + polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE); + ap.setPolygonAttributes(polyAttrbutes); + + // add both a wireframe and a solid version + // of the triangulated surface + Shape3D shape1 = new Shape3D(gi.getGeometryArray(), ap); + Shape3D shape2 = new Shape3D(gi.getGeometryArray()); + + objTrans.addChild(shape1); + objTrans.addChild(shape2); + //objRoot.addChild(objTrans); + + return objTrans; + } + + + } -- cgit v1.2.3