X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMain.java;h=8b5b51fe1f3cf3a0f27d1df5b29fb55cdbd4f432;hp=2b3640578a71e712ee91b65837e81de5db395b1e;hb=5f15a6155bf7fbf2d62b3ab9fd992a54af10a95a;hpb=d2a95aac1e76caacb65a8d17d9b6b32740edacb1 diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 2b36405..8b5b51f 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -7,222 +7,580 @@ import javax.media.opengl.glu.*; import java.util.*; import edu.berkeley.qfat.geom.*; import edu.berkeley.qfat.geom.Point; +import edu.berkeley.qfat.geom.Polygon; -// FIXME: recenter goal to have centroid coincident with tile -// FIXME: re-orient goal (how?) -// fish case: ensure that spinal axis of fish is the x-axis of the tile +// TO DO: +// - real anneal +// - solve self-intersection problem +// - get a better test model? +// - symmetry constraints withing the tile +// - rotation matrices +// - overbinding results in forced equational constraints on the leader +// - shatter in invertd-triforce pattern brian mentioned +// - aspect ratio? non-uniform deformation? +// - rotational alignment -public class Main implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { - - boolean alt = false; - boolean shift = false; - boolean control = false; +// - movie-style user interface like +// http://www.coleran.com/markcoleranreell.html ? - public void mouseWheelMoved(MouseWheelEvent e) { - tz -= e.getWheelRotation(); - } +// - consider recasting the Shewchuk predicates in Java? +// http://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c - public void keyTyped(KeyEvent e) { } - public void keyPressed(KeyEvent e) { - switch(e.getKeyCode()) { - case KeyEvent.VK_CONTROL: control = true; break; - case KeyEvent.VK_ALT: alt = true; break; - case KeyEvent.VK_SHIFT: shift = true; break; - } - } - public void keyReleased(KeyEvent e) { - switch(e.getKeyCode()) { - case KeyEvent.VK_CONTROL: control = false; break; - case KeyEvent.VK_ALT: alt = false; break; - case KeyEvent.VK_SHIFT: shift = false; break; - } - } +/* + blender keys + - middle mouse = option+click + - right mouse = command+click - public void mouseClicked(MouseEvent e) { } - public void mouseEntered(MouseEvent e) { } - public void mouseExited(MouseEvent e) { } - public void mousePressed(MouseEvent e) { } - public void mouseReleased(MouseEvent e) { } - - int mousex; - int mousey; - public void mouseMoved(MouseEvent e) { - mousex = e.getX(); - mousey = e.getY(); - } + 3,7,1 = view along axes (control for opp direction) + 4, 8, 7, 2 = rotate in discrete increments (+control to translate) + middle trag: rotate space + shift+middle drag: translate space + wheel: zoom + home: home view: take current angle, zoom to whole scnee + 5 = ortho vs non-ortho + +*/ + +/* + + + */ - float tx = 0; - float ty = 0; - float tz = 0; - float anglex = 0; - float angley = 0; - public void mouseDragged(MouseEvent e) { - if (shift) { - tx += (mousex - e.getX())/(float)20; - ty += (mousey - e.getY())/(float)20; - } else { - anglex -= mousex - e.getX(); - angley += mousey - e.getY(); - } - mousex = e.getX(); - mousey = e.getY(); - } - private Mesh tile = new Mesh(); - private Mesh goal = new Mesh(); +// FIXME: re-orient goal (how?) + +public class Main extends MeshViewer { + + public static int verts = 1; + public static final Random random = new Random(); + /** magnification factor */ private static final float MAG = 1; + public static final float MATCHING_EPSILON = 0.001f; + + private static boolean small(float f) { return Math.abs(f) < 0.001; } + public void generateTile(Matrix[] matrices, Mesh mesh) { + mesh.coalesce = true; + HashSet halfSpaces = new HashSet(); + HashSet polygons = new HashSet(); + for(Matrix m : matrices) { + Vec v = m.getTranslationalComponent(); + if (v.mag() < 0.0001) continue; + v = v.times(0.5f); + Point p = Point.ORIGIN.plus(v); + Vec v0 = v; + /* + if (small(v.x) && small(v.y)) v = new Vec(0,0,1); + else if (small(v.y) && small(v.z)) v = new Vec(1,0,0); + else if (small(v.z) && small(v.x)) v = new Vec(0,1,0); + else if (small(v.x)) v = new Vec(0,v.y,0).minus(new Vec(0,0,v.z)).cross(new Vec(1,0,0)); + else if (small(v.y)) v = new Vec(0,0,v.z).minus(new Vec(v.x,0,0)).cross(new Vec(0,1,0)); + else if (small(v.z)) v = new Vec(v.x,0,0).minus(new Vec(0,v.y,0)).cross(new Vec(0,0,1)); + else { + Point v1 = new Point(v.x, 0, 0); + Point v2 = new Point(0, v.y, 0); + Point v3 = new Point(0, 0, v.z); + v = v3.minus(v2).cross(v1.minus(v2)); + } + */ + if (v.dot(Point.ORIGIN.minus(p)) < 0) v = v.times(-1); + + System.out.println(v); + HalfSpace hs = new HalfSpace(p, v.norm()); + halfSpaces.add(hs); + polygons.add(new Polygon(hs)); + } + for(Polygon p : polygons) { + System.out.println(p.plane.norm + " " + p.plane.dvalue); + for(HalfSpace hs : halfSpaces) { + if (p.plane==hs) continue; + p = p.intersect(hs); + } + p.tesselate(mesh); + } + } - Matrix[] translations; - Mesh.Vert[] points; + private void quad(Mesh mesh, Matrix m, Point p1_, Point p2_, Point p3_, Point p4_) { + Point p1 = m.times(p1_); + Point p2 = m.times(p2_); + Point p3 = m.times(p3_); + Point p4 = m.times(p4_); + Point c = new Point((p1.x+p2.x+p3.x+p4.x)/4, + (p1.y+p2.y+p3.y+p4.y)/4, + (p1.z+p2.z+p3.z+p4.z)/4); + mesh.newT(p1, p2, c, null, 0); + mesh.newT(p2, p3, c, null, 0); + mesh.newT(p3, p4, c, null, 0); + mesh.newT(p4, p1, c, null, 0); + } - public Main(StlFile stlf) { + public Main(StlFile stlf, Frame f) { + super(f); for(int i=0; i es = new HashSet(); + for(Mesh.T t : tile) { + es.add(t.e1()); + es.add(t.e2()); + es.add(t.e3()); + } + for(Mesh.E e : es) { + if (e.p1.p.x == e.p2.p.x && e.p1.p.y == e.p2.p.y) continue; + if (e.p1.p.z == e.p2.p.z && e.p1.p.y == e.p2.p.y) continue; + if (e.p1.p.x == e.p2.p.x && e.p1.p.z == e.p2.p.z) continue; + e.shatter(); + } + */ + + + height = 4; + width = 4; + depth = 1; + + Matrix mm = Matrix.scale(0.1f); + // top + quad(tile, mm, + new Point( 2, 2, 0), + new Point( 1, 1, -1), + new Point(-1, 1, -1), + new Point(-2, 2, 0)); + quad(tile, mm, + new Point(-2, 2, 0), + new Point(-1, 1, 1), + new Point( 1, 1, 1), + new Point( 2, 2, 0)); + quad(tile, mm, + new Point( 1, 1, -1), + new Point( 1, 1, 1), + new Point(-1, 1, 1), + new Point(-1, 1, -1)); + + // bottom + quad(tile, mm, + new Point(-2, -2, 0), + new Point(-1, -1, -1), + new Point( 1, -1, -1), + new Point( 2, -2, 0)); + quad(tile, mm, + new Point( 2, -2, 0), + new Point( 1, -1, 1), + new Point(-1, -1, 1), + new Point(-2, -2, 0)); + quad(tile, mm, + new Point(-1, -1, -1), + new Point(-1, -1, 1), + new Point( 1, -1, 1), + new Point( 1, -1, -1)); - for(Matrix m : translations) { + // left + quad(tile, mm, + new Point( 2, -2, 0), + new Point( 1, -1, -1), + new Point( 1, 1, -1), + new Point( 2, 2, 0)); + quad(tile, mm, + new Point( 2, 2, 0), + new Point( 1, 1, 1), + new Point( 1, -1, 1), + new Point( 2, -2, 0)); + quad(tile, mm, + new Point( 1, -1, -1), + new Point( 1, -1, 1), + new Point( 1, 1, 1), + new Point( 1, 1, -1)); + + // bottom + quad(tile, mm, + new Point(-2, 2, 0), + new Point(-1, 1, -1), + new Point(-1, -1, -1), + new Point(-2, -2, 0)); + quad(tile, mm, + new Point(-2, -2, 0), + new Point(-1, -1, 1), + new Point(-1, 1, 1), + new Point(-2, 2, 0)); + quad(tile, mm, + new Point(-1, 1, -1), + new Point(-1, 1, 1), + new Point(-1, -1, 1), + new Point(-1, -1, -1)); + + + + translations = new Matrix[] { + /* + Matrix.translate(new Vec(0, 0.2f,0)) + .times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))), + + Matrix.translate(new Vec(0,-0.2f,0)) + .times(Matrix.rotate(new Vec(0,1,0), (float)(-1*Math.PI/2))), + + Matrix.translate(new Vec( 0.2f,0,0)) + .times(Matrix.rotate(new Vec(1,0,0), (float)( 1*Math.PI/2))), + + Matrix.translate(new Vec(-0.2f,0,0)) + .times(Matrix.rotate(new Vec(1,0,0), (float)(-1*Math.PI/2))), + */ + + /* + Matrix.rotate(new Vec(0,0,1), (float)(1*Math.PI/2)), + Matrix.rotate(new Vec(0,0,1), (float)(2*Math.PI/2)), + Matrix.rotate(new Vec(0,0,1), (float)(3*Math.PI/2)), + */ + Matrix.rotate(new Vec(1,0,0), (float)(2*Math.PI/2)), + + //Matrix.rotate(new Vec(0,0,1), (float)(2*Math.PI/2)), + //Matrix.scale(1,-1,1), + + //Matrix.translate(new Vec( 0.2f, 0,0)) + //.times(Matrix.rotate(new Vec(0,0,1), (float)( 1*Math.PI/2))) + //.times(Matrix.rotate(new Vec(0,1,0), (float)( 3*Math.PI/2))), + + //Matrix.translate(new Vec(-0.2f, 0,0)) + //.times(Matrix.rotate(new Vec(0,0,1), (float)( 3*Math.PI/2))) + //.times(Matrix.rotate(new Vec(0,1,0), (float)( 3*Math.PI/2))), + + //Matrix.rotate(new Vec(0,0,1), (float)( 0*Math.PI/2)) + //.times(Matrix.translate(new Vec(0, -0.2f, 0))) + //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))), + //Matrix.rotate(new Vec(0,0,1), (float)( 1*Math.PI/2)) + //.times(Matrix.translate(new Vec(0, -0.2f, 0))) + //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))), + + //Matrix.rotate(new Vec(0,0,1), (float)( 0*Math.PI/2)) + //.times(Matrix.translate(new Vec(0, -0.2f, 0))) + //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))), + //Matrix.rotate(new Vec(0,0,1), (float)( 0*Math.PI/2)) + //.times(Matrix.translate(new Vec(0, -0.2f, 0))) + //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))), + + Matrix.ONE, + }; + + + + for(Matrix m1 : translations) { + for(Matrix m2 : translations) { for(Mesh.T t1 : tile) { for(Mesh.T t2 : tile) { if (t1==t2) continue; - if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) && - (t1.v2().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) && - (t1.v3().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) { - t1.e1().bind(t2.e3().pair); - t1.e2().bind(t2.e2().pair); - t1.e3().bind(t2.e1().pair); + Matrix m = m1.inverse().times(m2); + if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) && + (t1.v2().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) && + (t1.v3().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) { + t2.e3().bindEdge(t1.e1(), m); + t2.e2().bindEdge(t1.e2(), m); + t2.e1().bindEdge(t1.e3(), m); + } + if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) && + (t1.v3().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) && + (t1.v1().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) { + t2.e3().bindEdge(t1.e2(), m); + t2.e2().bindEdge(t1.e3(), m); + t2.e1().bindEdge(t1.e1(), m); + } + if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) && + (t1.v1().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) && + (t1.v2().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) { + t2.e3().bindEdge(t1.e3(), m); + t2.e2().bindEdge(t1.e1(), m); + t2.e1().bindEdge(t1.e2(), m); + } + + if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) && + (t1.v2().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON) && + (t1.v3().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON)) { + t2.e1().bindEdge(t1.e1().pair, m); + t2.e2().bindEdge(t1.e2().pair, m); + t2.e3().bindEdge(t1.e3().pair, m); } - if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) && - (t1.v3().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) && - (t1.v1().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) { - t1.e2().bind(t2.e3().pair); - t1.e3().bind(t2.e2().pair); - t1.e1().bind(t2.e1().pair); + if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) && + (t1.v3().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON) && + (t1.v1().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON)) { + t2.e2().bindEdge(t1.e1().pair, m); + t2.e3().bindEdge(t1.e2().pair, m); + t2.e1().bindEdge(t1.e3().pair, m); } - if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) && - (t1.v1().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) && - (t1.v2().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) { - t1.e3().bind(t2.e3().pair); - t1.e1().bind(t2.e2().pair); - t1.e2().bind(t2.e1().pair); + if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) && + (t1.v1().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON) && + (t1.v2().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON)) { + t2.e3().bindEdge(t1.e1().pair, m); + t2.e1().bindEdge(t1.e2().pair, m); + t2.e2().bindEdge(t1.e3().pair, m); } + } } } + } - //xMesh.Vert mid = lbf.getE(mbn).shatter(); + //xMesh.Vertex mid = lbf.getE(mbn).shatter(); // rescale to match volume + + float factor = (float)Math.pow(tile.volume() / goal.volume(), 1.0/3.0); - goal.transform(new Matrix(factor)); + goal.transform(Matrix.scale(factor/2.4f)); + goal.transform(Matrix.rotate(new Vec(0, 1, 0), (float)(Math.PI/2))); // translate to match centroid - goal.transform(new Matrix(tile.centroid().minus(goal.centroid()))); + goal.transform(Matrix.translate(tile.centroid().minus(goal.centroid()))); + goal.makeVerticesImmutable(); //tx.e2.shatter(); //tx.e3.shatter(); - tile.bind(); + tile.rebindPoints(); //mid.move(new Vec((float)0,0,(float)-0.05)); //ltn.move(new Vec((float)0,0,(float)-0.05)); @@ -233,245 +591,188 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener System.out.println("tile volume: " + tile.volume()); System.out.println("goal volume: " + goal.volume()); - tile.score_against = goal; - goal.score_against = tile; + tile.error_against = goal; + goal.error_against = tile; } - Random random = new Random(); - public synchronized void breakit() { - if (verts > 50) return; - //double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts)); - //if (verts>0 && tile.es.peek().length() < min) return; + public void breakit() { + int oldverts = verts; + System.out.println("doubling vertices."); PriorityQueue es = new PriorityQueue(); - for(Mesh.E e : tile.edges()) es.add(e); - for(int i=0; i<10; i++) { + for(Mesh.T t : tile) { + es.add(t.e1()); + es.add(t.e2()); + es.add(t.e3()); + Thread.yield(); + repaint(); + } + for(int i=0; i 0) { + while (breaks>0) { + breaks--; + breakit(); + } + seek_upward = true; + } else if (acceptance > 0.96) gamma = 0.1f; + else if (acceptance > 0.9) gamma = 0.2f; + else if (acceptance > 0.8) gamma = 0.3f; + else if (acceptance > 0.6) gamma = 0.4f; + else if (acceptance > 0.3) gamma = 0.6f; + else if (acceptance > 0.15) gamma = 0.9f; + else if (acceptance > 0.05) gamma = 0.94f; + else if (acceptance > 0.01) gamma = 0.98f; + else { /*breaks++;*/ } + + /* + if (seek_upward) { + if (acceptance > 0.2) seek_upward = false; + else gamma = 2-gamma; + } + */ - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { } - public synchronized void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - GLU glu = new GLU(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glPointSize(5.0f); - gl.glLoadIdentity(); - glu.gluPerspective(50-tz, ((float)drawable.getWidth())/drawable.getHeight(), 0.5, 10); - glu.gluLookAt(0, 0, -1, 0, 0, 0, 0, 1, 0); - gl.glTranslatef(tx/(float)20, ty/(float)20, 0); - gl.glRotatef(anglex/3, 0, 1, 0); - gl.glRotatef(angley/3, 1, 0, 0); - - gl.glBegin(GL.GL_TRIANGLES); - draw(gl, true, tile); - gl.glEnd(); - - gl.glBegin(GL.GL_TRIANGLES); - gl.glColor4f((float)0.5, (float)0.5, (float)0.5, (float)0.8); - //draw(gl, false, goal); - gl.glEnd(); - - - int i = 0; - //gl.glDisable(GL.GL_DEPTH_TEST); - gl.glColor4f(1,1,1,1); - for(Matrix m : translations) { - //if (v1.z==0 && v1.y==0) continue; - i++; - if (i != 1 /*&& i!=4*/) continue; - Point p = new Point(0, 0, 0).times(m); - Vec v = new Vec(p.x, p.y, p.z); - v = v.times((float)1.04); - gl.glTranslatef(v.x, v.y, v.z); - draw(gl, false, tile); - gl.glTranslatef(-v.x, -v.y, -v.z); - } - //gl.glEnable(GL.GL_DEPTH_TEST); - } + if (anneal) + temp = temp * gamma; - private synchronized void draw(GL gl, boolean triangles, Mesh mesh) { - float red = 0.0f; - float green = 0.0f; - float blue = 0.0f; - for(Mesh.T t : mesh) { - if (red < 0.15) red = 1.0f; - if (green < 0.15) green = 1.0f; - if (blue < 0.15) blue = 1.0f; - red -= .09f; - green -= .12f; - blue -= .15f; - - if (triangles) switch(t.color) { - case 0: gl.glColor4f((float)0.25, (float)0.25, (float)0.75, (float)0.3); break; - case 1: gl.glColor4f((float)0.25, (float)0.75, (float)0.25, (float)0.3); break; - case 2: gl.glColor4f((float)0.75, (float)0.25, (float)0.25, (float)0.3); break; - case 3: gl.glColor4f((float)0.50, (float)0.50, (float)0.50, (float)0.3); break; - } - //gl.glBegin(GL.GL_LINES); - - if (triangles) { - gl.glBegin(GL.GL_TRIANGLES); - t.glVertices(gl); - gl.glEnd(); - } else { - gl.glBegin(GL.GL_LINES); - t.e1().p1.p.glVertex(gl); - t.e1().p2.p.glVertex(gl); - t.e2().p1.p.glVertex(gl); - t.e2().p2.p.glVertex(gl); - t.e3().p1.p.glVertex(gl); - t.e3().p2.p.glVertex(gl); - gl.glEnd(); - } - Point centroid = t.centroid(); - gl.glBegin(GL.GL_LINES); - gl.glColor3f(1, 1, 1); - /* - centroid.glVertex(gl); - centroid.plus(t.norm().times(t.diameter())).glVertex(gl); - */ + HashSet hs = new HashSet(); + for(Mesh.Vertex p : tile.vertices()) hs.add(p); + Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]); - if (mesh==goal) - for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) { - p.p.glVertex(gl); - //p.plus(p.norm().times(p.score()*10)).glVertex(gl); - //p.partner().p.glVertex(gl); - //tile.nearest(p).centroid().glVertex(gl); + int count = 0; + long then = System.currentTimeMillis(); + for(int i=0; i<400; i++) { + if (anneal) { + count++; + Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length]; + rand(temp,v); + v.recomputeFundamentalQuadricIfStale(); + v.recomputeFundamentalQuadricIfNeighborChanged(); + } + Thread.yield(); + repaint(); + } + + /* + PriorityQueue es = new PriorityQueue(); + for(Mesh.T t : tile) { + float max = 5; + for(Mesh.E e : new Mesh.E[] { t.e1(), t.e2(), t.e3() }) { + if (e==null) continue; + if (e.stretchRatio() > max) es.add(e); + if (t.aspect() < 0.1 && e.length()>e.next.length() && e.length()>e.prev.length()) es.add(e); + } } + for(int i=0; i<5; i++) { + Mesh.E e = es.poll(); + if (e==null) break; + e.shatter(); + } + + + tile.rebindPoints(); + */ - gl.glEnd(); + System.out.println("temp="+temp + " ratio="+(Math.ceil(acceptance*100)) + " " + + "points_per_second=" + + (count*1000)/((double)(System.currentTimeMillis()-then))); + for(Mesh.Vertex p : goal.vertices()) p.recomputeFundamentalQuadricIfNeighborChanged(); + + synchronized(safeTriangles) { + safeTriangles.clear(); + for(Mesh.T t : tile) + //if (t.shouldBeDrawn()) + safeTriangles.add(t); + } + } } } + public static void main(String[] s) throws Exception { StlFile stlf = new StlFile(); - stlf.load("simplefish.stl"); - Main main = new Main(stlf); + stlf.load("torus.stl"); + //stlf.load("fish.stl"); + //stlf.load("monkey.stl"); Frame f = new Frame(); - GLCapabilities glcaps = new GLCapabilities(); - GLCanvas glcanvas = new GLCanvas(); - glcanvas.addGLEventListener(main); - f.add(glcanvas, BorderLayout.CENTER); + Main main = new Main(stlf, f); f.pack(); f.show(); f.setSize(900, 900); f.doLayout(); - - glcanvas.addMouseListener(main); - glcanvas.addMouseMotionListener(main); - glcanvas.addMouseWheelListener(main); - glcanvas.addKeyListener(main); - - main.anneal(glcanvas); - } - public static int verts = 0; - public void anneal(GLCanvas glcanvas) throws Exception { - int verts = 0; - while(true) { - //Thread.sleep(10); - for(int i=0; i<1; i++) { - glcanvas.repaint(); - //tile.ts.get(Math.abs(random.nextInt()) % tile.ts.size()).e1().p1 - for(Mesh.T t : tile) - for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) { - rand(10,p); - } - goal.rescore(); - tile.rescore(); - } - breakit(); - } - + main.anneal(); } } \ No newline at end of file