X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMeshViewer.java;h=3f57d77e35b62a418785036e4b0b1833df73c035;hp=3799ab5a042bb7bfc11b711b8aa8d6b1a1048337;hb=2a2e64829786ee415fd0c0f16957c55e174b793b;hpb=ebf227e9a3373f74682716dedc9ba4c3e5882f6e diff --git a/src/edu/berkeley/qfat/MeshViewer.java b/src/edu/berkeley/qfat/MeshViewer.java index 3799ab5..3f57d77 100644 --- a/src/edu/berkeley/qfat/MeshViewer.java +++ b/src/edu/berkeley/qfat/MeshViewer.java @@ -13,6 +13,82 @@ import edu.berkeley.qfat.geom.Point; public class MeshViewer extends Viewer { + public int whichNeighbor = 1; + public double temp; + public boolean tileon = true; + public boolean tilemeshon = false; + public boolean goalon = true; + public boolean anneal = false; + public boolean hillclimb = false; + public boolean neighbors = false; + public boolean neighborsWire = false; + public boolean neighborsWireOne = false; + public boolean errorNormals = false; + + public boolean force = false; + public Matrix[] transforms; + public Mesh.Vertex[] points; + public int breaks = 0; + + public int temps; + public int accepts; + public int vertss; + protected HashSet safeTriangles = new HashSet(); + public MeshViewer(JFrame f) { super(f); } + public void _display(GLAutoDrawable drawable, GL gl) { + + if (transforms==null) return; + glcanvas.setSize(f.getWidth(), f.getHeight() - 100); + + 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, ((float)drawable.getWidth())/drawable.getHeight(), 0.5, 10); + glu.gluLookAt(0, 0, -((tz/10)-1), 0, 0, 0, 0, 1, 0); + gl.glRotatef(anglex/3, 0, 1, 0); + gl.glRotatef(-(angley/3), 1, 0, 0); + + tile.render(gl, Matrix.ONE); + goal.render(gl, Matrix.ONE); + + int i = 0; + gl.glColor4f(1,1,1,1); + for(Matrix m : transforms) { + i++; + if (neighborsWireOne && i!=whichNeighbor) continue; + if (neighbors) tile.render(gl, m); + else if (neighborsWire || neighborsWireOne) tile.render(gl, m); + } + + gl.glDisable(GL.GL_LIGHTING); + gl.glShadeModel(GL.GL_FLAT); + if (closest != null) { + gl.glColor3f(1,1,1); + gl.glBegin(gl.GL_POINTS); + closest.getPoint().glVertex(gl); + gl.glEnd(); + } + + updateVisibility(gl, tile); + + Matrix projection = Matrix.getProjectionMatrix(gl); + double dist = Double.MAX_VALUE; + if (clickPoint != null) return; + closest = null; + for(Mesh.Vertex v : tile.vertices()) { + if (!v.visible) continue; + Point p = projection.times(v.getPoint()); + int x = (int)p.x; + int y = (int)p.y; + y = glcanvas.getHeight()-y; + if (closest==null || (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey) < dist) { + dist = (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey); + closest = v; + } + } + } + } \ No newline at end of file