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<Mesh.T> safeTriangles = new HashSet<Mesh.T>();
+
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