-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 class MeshViewer implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
+
+ Mesh.Vertex closest = null;
+
+ private HashSet<Mesh> meshes = new HashSet<Mesh>();
+ public synchronized void addMesh(Mesh m) { meshes.add(m); }
+ public synchronized void removeMesh(Mesh m) { meshes.remove(m); }
+
+ private int mousex;
+ private int mousey;
+ private Matrix projection = null;
+ private Point clickPoint = null;
+
+ private GLCanvas glcanvas;
+
+ Point clickClosest = null;
+
+ float tz = 0;
+ float anglex = 0;
+ float angley = 0;
+
+ 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 init(GLAutoDrawable gld) {
+ GL gl = gld.getGL();
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ gl.glViewport(0, 0, 500, 300);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glClearDepth(1.0);
+ gl.glDepthFunc(GL.GL_LEQUAL);
+ gl.glMatrixMode(GL.GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glMatrixMode(GL.GL_MODELVIEW);
+
+ float mat_specular[] = { 0.5f, 0.5f, 0.5f, 0.5f };
+ float mat_shininess[] = { 50.0f };
+ gl.glShadeModel(GL.GL_SMOOTH);
+ //gl.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, mat_specular, 0);
+ //gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, mat_specular, 0);
+ //gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, new float[] { 0.3f, 0.3f, 0.3f, 0.3f }, 0);
+ //gl.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, mat_shininess, 0);
+ gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { 1.0f, 4.0f, -10.0f, 0.0f }, 0);
+ gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, new float[] { -10.0f, 10.0f, 10.0f, 0.0f }, 0);
+ gl.glLightfv(GL.GL_LIGHT2, GL.GL_POSITION, new float[] { 10.0f, -10.0f, 10.0f, 0.0f }, 0);
+ gl.glLightfv(GL.GL_LIGHT3, GL.GL_POSITION, new float[] { 10.0f, 10.0f, -10.0f, 0.0f }, 0);
+ gl.glLightfv(GL.GL_LIGHT4, GL.GL_POSITION, new float[] { -10.0f, 10.0f, -10.0f, 0.0f }, 0);
+ gl.glLightfv(GL.GL_LIGHT5, GL.GL_POSITION, new float[] { 10.0f, -10.0f, -10.0f, 0.0f }, 0);
+ gl.glEnable(GL.GL_LIGHTING);
+ gl.glEnable(GL.GL_LIGHT0);