+ public Mesh tile;
+ public Mesh goal;
+
+ private HashSet<MeshViewer> mvs = new HashSet<MeshViewer>();
+
+ public InteractiveMeshViewer(JFrame f) {
+ 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);
+ f.addKeyListener(this);
+ 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 (mvs != null)
+ for(MeshViewer mv : mvs)
+ mv.repaint();
+ }
+
+
+ public void setTile(Mesh tile) {
+ for(MeshViewer mv : mvs) mv.removeMesh(this.tile);
+ this.tile = tile;
+ for(MeshViewer mv : mvs) mv.addMesh(this.tile);
+ }
+ public void setGoal(Mesh goal) {
+ for(MeshViewer mv : mvs) mv.removeMesh(this.goal);
+ this.goal = goal;
+ goal.option_selectable = false;
+ goal.option_wireframe = true;
+ for(MeshViewer mv : mvs) mv.addMesh(this.goal);
+ }