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;
public void _display(GLAutoDrawable drawable, GL gl) {
if (transforms==null) return;
-
-
glcanvas.setSize(f.getWidth(), f.getHeight() - 100);
Graphics2D g = (Graphics2D)f.getGraphics();
g.setColor(Color.black);
public abstract class Viewer implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
Mesh.Vertex closest = null;
+ Matrix projection = null;
- public boolean force = false;
public Mesh tile = new Mesh(false);
public Mesh goal = new Mesh(false);
- public Matrix[] transforms;
- public Mesh.Vertex[] points;
-
- 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 int breaks = 0;
- boolean alt = false;
- boolean shift = false;
- boolean control = false;
- Matrix projection = null;
+
JFrame f;
GLCanvas glcanvas;
Point clickPoint = null;
float anglex = 0;
float angley = 0;
+ boolean alt = false;
+ boolean shift = false;
+ boolean control = false;
+
public abstract void _display(GLAutoDrawable drawable, GL gl);
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
this.projection = Matrix.getProjectionMatrix(gl);
}
+ /** return the position of the mouse as a point in window-space */
public Point getMouse() {
return new Point(mousex, glcanvas.getHeight()-mousey, 0);
}
clickPoint = getMouse();
clickClosest = closest == null ? null : closest.getPoint();
}
+
public void mouseReleased(MouseEvent e) {
clickPoint = null;
clickClosest = null;
}
-
public void mouseMoved(MouseEvent e) {
mousex = e.getX();
mousey = e.getY();
public Viewer(JFrame f) {
this.f = f;
-
- GLCapabilities glcaps = new GLCapabilities();
glcanvas = new GLCanvas();
glcanvas.addGLEventListener(this);
f.add(glcanvas, BorderLayout.CENTER);
-
glcanvas.addMouseListener(this);
glcanvas.addMouseMotionListener(this);
glcanvas.addMouseWheelListener(this);
glcanvas.addKeyListener(this);
}
+
public void repaint() {
glcanvas.repaint();
}