Merge branch 'master' of https://forge.info.unicaen.fr/git/l-system
This commit is contained in:
commit
764a0fe710
@ -3,10 +3,12 @@ package lsystem;
|
|||||||
import lsystem.screen.MainFrame;
|
import lsystem.screen.MainFrame;
|
||||||
import lsystem.screen.SwingGLCanvas;
|
import lsystem.screen.SwingGLCanvas;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
System.out.println(-180%360);
|
||||||
MainFrame frame = new MainFrame();
|
MainFrame frame = new MainFrame();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
SwingGLCanvas canvas = new SwingGLCanvas();
|
SwingGLCanvas canvas = new SwingGLCanvas();
|
||||||
|
@ -12,6 +12,7 @@ public class MainFrame extends JFrame {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -7898079642230075807L;
|
private static final long serialVersionUID = -7898079642230075807L;
|
||||||
private int nbTabs;
|
private int nbTabs;
|
||||||
|
private int nbHelpWindow;
|
||||||
private JPanel basePanel;
|
private JPanel basePanel;
|
||||||
private JTabbedPane tabs;
|
private JTabbedPane tabs;
|
||||||
private JButton newGen;
|
private JButton newGen;
|
||||||
@ -45,18 +46,29 @@ public class MainFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void newHelp() {
|
public void newHelp() {
|
||||||
JFrame aide = new JFrame();
|
if(nbHelpWindow>0){
|
||||||
aide.setTitle("Aide");
|
JOptionPane.showMessageDialog(null, "Une fenêtre d'aide est déjà ouverte.");
|
||||||
aide.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
}
|
||||||
aide.setSize(700,800);
|
else {
|
||||||
aide.setLocationRelativeTo(null);
|
nbHelpWindow++;
|
||||||
aide.setVisible(true);
|
|
||||||
|
|
||||||
JTextArea helpText = new JTextArea();
|
JFrame aide = new JFrame();
|
||||||
helpText.setText(Constants.HELP);
|
aide.setTitle("Aide");
|
||||||
helpText.setEditable(false);
|
aide.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
aide.setSize(700,500);
|
||||||
|
aide.setLocationRelativeTo(null);
|
||||||
|
aide.setVisible(true);
|
||||||
|
|
||||||
aide.add(helpText);
|
JTextArea helpText = new JTextArea();
|
||||||
|
helpText.setText(Constants.HELP);
|
||||||
|
helpText.setEditable(false);
|
||||||
|
|
||||||
|
JScrollPane scrollbar = new JScrollPane(helpText);
|
||||||
|
scrollbar.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
scrollbar.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||||
|
|
||||||
|
aide.add(scrollbar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void newTab() {
|
public void newTab() {
|
||||||
if(nbTabs>2)
|
if(nbTabs>2)
|
||||||
|
@ -84,6 +84,9 @@ public class JoglEventListener implements GLEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void display(GLAutoDrawable glAutoDrawable) {
|
public void display(GLAutoDrawable glAutoDrawable) {
|
||||||
|
for (int i = 0; i < canvas.camera.length; i++) {
|
||||||
|
canvas.camera[i] = canvas.camera[i] % 360;
|
||||||
|
}
|
||||||
GL2 gl = glAutoDrawable.getGL().getGL2();
|
GL2 gl = glAutoDrawable.getGL().getGL2();
|
||||||
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
|
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
|
||||||
gl.glLoadIdentity();
|
gl.glLoadIdentity();
|
||||||
|
@ -53,7 +53,7 @@ public class JoglMouseListener implements MouseListener, MouseMotionListener, Mo
|
|||||||
if(origine != null) {
|
if(origine != null) {
|
||||||
double xDiff = origine.getX() - e.getPoint().getX();
|
double xDiff = origine.getX() - e.getPoint().getX();
|
||||||
double yDiff = origine.getY() - e.getPoint().getY();
|
double yDiff = origine.getY() - e.getPoint().getY();
|
||||||
/* if(button == 2) {
|
/* if(button == 1) {
|
||||||
canvas.camera[0] += Math.cos(canvas.camera[3]) * xDiff * 0.01;
|
canvas.camera[0] += Math.cos(canvas.camera[3]) * xDiff * 0.01;
|
||||||
canvas.camera[1] += Math.cos(canvas.camera[4]) * yDiff * 0.01;
|
canvas.camera[1] += Math.cos(canvas.camera[4]) * yDiff * 0.01;
|
||||||
canvas.camera[2] += Math.sin(canvas.camera[3]) * xDiff * 0.01;
|
canvas.camera[2] += Math.sin(canvas.camera[3]) * xDiff * 0.01;
|
||||||
@ -64,9 +64,6 @@ public class JoglMouseListener implements MouseListener, MouseMotionListener, Mo
|
|||||||
}
|
}
|
||||||
origine = e.getPoint();
|
origine = e.getPoint();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < canvas.camera.length; i++) {
|
|
||||||
canvas.camera[i] = canvas.camera[i] % 360;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,15 +72,41 @@ public class JoglMouseListener implements MouseListener, MouseMotionListener, Mo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
if( 45 > Math.abs(canvas.camera[3]) && 45>Math.abs(canvas.camera[4]))
|
// Gestion de la position x:
|
||||||
|
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3]) > 270 ) {
|
||||||
canvas.camera[0] += e.getWheelRotation() * Math.tan(Math.toRadians(-canvas.camera[3])) * 0.25;
|
canvas.camera[0] += e.getWheelRotation() * Math.tan(Math.toRadians(-canvas.camera[3])) * 0.25;
|
||||||
else
|
}
|
||||||
|
else if(Math.abs(canvas.camera[3]) > 90 || Math.abs(canvas.camera[3]) < 270){
|
||||||
canvas.camera[0] += e.getWheelRotation() * Math.tan(Math.toRadians(canvas.camera[3])) * 0.25;
|
canvas.camera[0] += e.getWheelRotation() * Math.tan(Math.toRadians(canvas.camera[3])) * 0.25;
|
||||||
canvas.camera[1] += e.getWheelRotation() * Math.tan(Math.toRadians(canvas.camera[4])) * 0.25;
|
}
|
||||||
if( 45 < Math.abs(canvas.camera[3]) || 45 < Math.abs(canvas.camera[4]))
|
// Gestion de la position y:
|
||||||
canvas.camera[2] += -e.getWheelRotation()*0.25;
|
if(Math.abs(canvas.camera[4]) < 90 || Math.abs(canvas.camera[4]) > 270) {
|
||||||
else
|
canvas.camera[1] += e.getWheelRotation() * Math.tan(Math.toRadians(canvas.camera[4])) * 0.25;
|
||||||
|
}
|
||||||
|
else if(Math.abs(canvas.camera[4]) > 90 || Math.abs(canvas.camera[4]) < 270){
|
||||||
|
canvas.camera[1] += e.getWheelRotation() * Math.tan(Math.toRadians(-canvas.camera[4])) * 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( 90 == canvas.camera[3]){
|
||||||
|
canvas.camera[0] +=e.getWheelRotation()*0.25;
|
||||||
|
canvas.camera[2] += 0;
|
||||||
|
}
|
||||||
|
if( 90 == canvas.camera[4]){
|
||||||
|
canvas.camera[1] +=e.getWheelRotation()*0.25;
|
||||||
|
canvas.camera[2] += 0;
|
||||||
|
}
|
||||||
|
if( -90 == canvas.camera[3]){
|
||||||
|
canvas.camera[0] +=-e.getWheelRotation()*0.25;
|
||||||
|
canvas.camera[2] += 0;
|
||||||
|
}
|
||||||
|
if( -90 == canvas.camera[4]){
|
||||||
|
canvas.camera[1] +=e.getWheelRotation()*0.25;
|
||||||
|
canvas.camera[2] += 0;
|
||||||
|
}
|
||||||
|
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3]) > 270 && Math.abs(canvas.camera[4]) < 90 || Math.abs(canvas.camera[4]) > 270){
|
||||||
canvas.camera[2] += e.getWheelRotation()*0.25;
|
canvas.camera[2] += e.getWheelRotation()*0.25;
|
||||||
|
}else
|
||||||
|
canvas.camera[2] += -e.getWheelRotation()*0.25;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,40 @@ public class KeyboardListener implements KeyListener {
|
|||||||
|
|
||||||
switch (e.getKeyChar()) {
|
switch (e.getKeyChar()) {
|
||||||
case 'z':
|
case 'z':
|
||||||
canvas.camera[2] -= 0.1f;
|
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){
|
||||||
|
canvas.camera[2] -= 0.1f;
|
||||||
|
canvas.camera[0] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}else{
|
||||||
|
canvas.camera[2] += 0.1f;
|
||||||
|
canvas.camera[0] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
canvas.camera[2] += 0.1f;
|
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){
|
||||||
|
canvas.camera[2] += 0.1f;
|
||||||
|
canvas.camera[0] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}else{
|
||||||
|
canvas.camera[2] -= 0.1f;
|
||||||
|
canvas.camera[0] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
canvas.camera[0] -= 0.1f;
|
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){
|
||||||
|
canvas.camera[0] -= 0.1f;
|
||||||
|
canvas.camera[2] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}else{
|
||||||
|
canvas.camera[0] += 0.1f;
|
||||||
|
canvas.camera[2] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
canvas.camera[0] += 0.1f;
|
if(Math.abs(canvas.camera[3]) < 180 || Math.abs(canvas.camera[3])>0 ){
|
||||||
|
canvas.camera[0] += 0.1f;
|
||||||
|
canvas.camera[2] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}else{
|
||||||
|
canvas.camera[0] -= 0.1f;
|
||||||
|
canvas.camera[2] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3]));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
canvas.camera[3] -= 1;
|
canvas.camera[3] -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user