this.dialog = new ControlDialog(null, false);
this.mapRenderer = new MapRenderer(terreno);
this.heightMapRenderer = new HeightMapRenderer(terreno);
GLDisplay mapDisplay = GLDisplay.createGLDisplay("Trabalho 04 - Gerador de terrenos");
mapDisplay.addGLEventListener(this.mapRenderer);
Panel panel = new Panel();
panel.setSize(terreno.getLargura(), terreno.getProfundidade());
panel.setPreferredSize(new Dimension(terreno.getLargura(), terreno.getProfundidade()));
this.dialog.getJSpHeightMap().setMaximumSize(new Dimension(this.terreno.getLargura(), this.terreno.getProfundidade()));
GLDisplay heightMapDisplay = GLDisplay.createGLDisplay(panel, "HeightMap", this.terreno.getLargura(), this.terreno.getProfundidade(), false);
this.dialog.getJSpHeightMap().add(panel);
heightMapDisplay.addGLEventListener(heightMapRenderer);
dialog.getJRbSolido().setSelected(true);
this.dialog.getJRbSolido().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.getJRbWireFrame().setSelected(false);
mapRenderer.mudarModoPoligono(GL.GL_FILL);
mapRenderer.setMapaAlterado(true);
}
});
this.dialog.getJRbWireFrame().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.getJRbSolido().setSelected(false);
mapRenderer.mudarModoPoligono(GL.GL_LINE);
mapRenderer.setMapaAlterado(true);
}
});
this.dialog.getJRbCamLivre().setSelected(true);
this.dialog.getJRbCamLivre().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.getJRbCamSolo().setSelected(false);
mapRenderer.mudarCamera();
}
});
this.dialog.getJRbCamSolo().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.getJRbCamLivre().setSelected(false);
mapRenderer.mudarCamera();
}
});
InputHandler inputHandler = new InputHandler(this, mapDisplay);
mapDisplay.addKeyListener(inputHandler);
heightMapDisplay.addKeyListener(inputHandler);
heightMapDisplay.addMouseMotionListener(inputHandler);
heightMapDisplay.addMouseListener(inputHandler);
heightMapDisplay.start();
mapDisplay.start();
this.dialog.setVisible(true);
}