import edu.berkeley.qfat.geom.*;
import edu.berkeley.qfat.geom.Point;
-public class InteractiveMeshViewer extends JPanel {
+public class InteractiveMeshViewer extends JPanel implements KeyListener {
public Mesh tile;
public Mesh goal;
- private MeshViewer mv;
+ private HashSet<MeshViewer> mvs = new HashSet<MeshViewer>();
public InteractiveMeshViewer(JFrame f) {
- mv = new MeshViewer();
- setLayout(new BorderLayout());
- this.add(mv, BorderLayout.CENTER);
+ MeshViewer mv1 = new MeshViewer();
+ MeshViewer mv2 = new MeshViewer();
+ MeshViewer mv3 = new MeshViewer();
+ MeshViewer mv4 = new MeshViewer();
+ mvs.add(mv1);
+ mvs.add(mv2);
+ mvs.add(mv3);
+ mvs.add(mv4);
+ addKeyListener(this);
+ mv1.addKeyListener(this);
+ mv2.addKeyListener(this);
+ mv3.addKeyListener(this);
+ mv4.addKeyListener(this);
+ setLayout(new GridLayout(2,2));
+ this.add(mv1);
+ this.add(mv2);
+ this.add(mv3);
+ this.add(mv4);
setTile(new Mesh(false));
setGoal(new Mesh(false));
}
public void repaint() {
- if (mv != null) mv.repaint();
+ if (mvs != null)
+ for(MeshViewer mv : mvs)
+ mv.repaint();
}
public void setTile(Mesh tile) {
- mv.removeMesh(this.tile);
+ for(MeshViewer mv : mvs) mv.removeMesh(this.tile);
this.tile = tile;
- mv.addMesh(this.tile);
+ for(MeshViewer mv : mvs) mv.addMesh(this.tile);
}
public void setGoal(Mesh goal) {
- mv.removeMesh(this.goal);
+ for(MeshViewer mv : mvs) mv.removeMesh(this.goal);
this.goal = goal;
goal.option_selectable = false;
goal.option_wireframe = true;
- mv.addMesh(this.goal);
+ for(MeshViewer mv : mvs) mv.addMesh(this.goal);
}
public synchronized void dump() {
public int accepts;
public int vertss;
+ public void keyTyped(KeyEvent e) { }
+ public void keyReleased(KeyEvent e) { }
public void keyPressed(KeyEvent e) {
//super.keyPressed(e);
switch(e.getKeyCode()) {
- case KeyEvent.VK_SPACE: breaks++; force = true; break;
+ case KeyEvent.VK_SPACE:
+ synchronized(this) {
+ tile.subdivide();
+ }
+ //case KeyEvent.VK_SPACE: breaks++; force = true; break;
case KeyEvent.VK_UP: temp = temp * 2; break;
case KeyEvent.VK_ENTER: temp = 10; break;
case KeyEvent.VK_LEFT: whichNeighbor--; break;
import edu.berkeley.qfat.geom.Polygon;
// TO DO:
+//
+// - Implement "real" constraints (plane, line, point)
+//
+// - Constrained surface subdivision
+// - Edge.flip() gets us the triforce subdivision
+// - Edge.delete() gets us the catmull-clark subdivision
+// - Catmull-Clark: just don't move points if we can't. Need to average the influence of the points on a binding group.
+//
+// - Ability to snap three views to orthgonal
+// - SLIDE UI
+// - left button -> crystal ball
+// - translate
+// - rightbutton/mousewheel zoom
+// - v+click to select vertex
+// - show: constraints, bindings, faces
+//
+// Editing:
+// - fracture edge, face
+// - change aspect ratio
+// - ability to select a point, rotate the model, then move the point
+// - when moving a vertex in one window, show that window's axes in all other windows
+//
+
+
+// TO DO:
// - real anneal
// - solve self-intersection problem
// - get a better test model?
}
+ public void subdivide() {
+ for (T t : this) t.old = true;
+ for (Vertex v : vertices()) v.original = true;
+ OUTER: while(true) {
+ for (T t : this)
+ if (t.old) {
+ Point p = t.e1.midpoint();
+ System.out.println("shatter " + t.e1);
+ t.e1.shatter();
+ nearest(p).edge = true;
+ continue OUTER;
+ }
+ break;
+ }
+ }
+
// Vertexices //////////////////////////////////////////////////////////////////////////////
/** a vertex in the mesh */
public Point oldp;
E e; // some edge *leaving* this point
+ public boolean original = false;
+ public boolean edge = false;
+
private boolean illegal = false;
public boolean visible = false;
public final int color;
public final int colorclass;
+ public boolean old;
+
public final int serial = max_serial++;
public boolean occluded;
private Point clickPoint = null;
private GLCanvas glcanvas;
private boolean updateVisibilities = false;
+ private boolean mouseInside = false;
private HashSet<Mesh> meshes = new HashSet<Mesh>();
GL gl = glcanvas.getGL();//drawable.getGL();
GLU glu = new GLU();
+
+ if (!mouseInside) gl.glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
+ else gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glPointSize(5.0f);
gl.glLoadIdentity();
public void keyReleased(KeyEvent e) { }
public void mouseClicked(MouseEvent e) { }
- public void mouseEntered(MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseEntered(MouseEvent e) { mouseInside = true; }
+ public void mouseExited(MouseEvent e) { mouseInside = false; }
public void mousePressed(MouseEvent e) {
clickPoint = getMouse();
}