- public boolean tileon = true;
- public boolean tilemeshon = false;
- public boolean goalon = false;
- public boolean anneal = true;
-
- public int breaks = 0;
- boolean alt = false;
- boolean shift = false;
- boolean control = false;
-
- public void mouseWheelMoved(MouseWheelEvent e) {
- tz -= e.getWheelRotation();
- }
-
- public void keyTyped(KeyEvent e) { }
- public void keyPressed(KeyEvent e) {
- switch(e.getKeyCode()) {
- case KeyEvent.VK_CONTROL: control = true; break;
- case KeyEvent.VK_ALT: alt = true; break;
- case KeyEvent.VK_SHIFT: shift = true; break;
- case KeyEvent.VK_SPACE: breaks++; break;
- case KeyEvent.VK_D: dump(); break;
- case KeyEvent.VK_A: anneal = !anneal; break;
- case KeyEvent.VK_T: tileon = !tileon; break;
- case KeyEvent.VK_G: goalon = !goalon; break;
- case KeyEvent.VK_M: tilemeshon = !tilemeshon; break;
- }
- }
- public synchronized void dump() {
- try {
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("dump.stl")));
- pw.println("solid dump");
- for(Mesh.T t : tile) {
- Vec normal = t.norm();
- pw.println("facet normal " + normal.x + " " + normal.y + " " + normal.z);
- pw.println(" outer loop");
- for(Mesh.Vertex v : new Mesh.Vertex[] { t.v1(), t.v2(), t.v3() }) {
- pw.println(" vertex " + v.p.x + " " + v.p.y + " " + v.p.z);
- }
- pw.println(" endloop");
- pw.println("endfacet");
- }
- pw.println("endsolid dump");
- pw.flush();
- pw.close();
- } catch (Exception e) { throw new RuntimeException(e); }
- }
- public void keyReleased(KeyEvent e) {
- switch(e.getKeyCode()) {
- case KeyEvent.VK_CONTROL: control = false; break;
- case KeyEvent.VK_ALT: alt = false; break;
- case KeyEvent.VK_SHIFT: shift = false; break;
- }
- }