diff --git a/build.xml b/build.xml
index 635a838..ef92040 100644
--- a/build.xml
+++ b/build.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/src/lsystem/Main2D.java b/src/lsystem/Main2D.java
deleted file mode 100644
index 50acf65..0000000
--- a/src/lsystem/Main2D.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package lsystem;
-
-import lsystem.screen.gl2d.SwingGLCanvas2D;
-import lsystem.screen.main.MainFrame;
-
-public class Main2D {
-
- /*public static MainFrame mainFrame;
- public static SwingGLCanvas2D joglFrame;
- public static void main(String[] args) {
- new Thread(() -> {
- mainFrame = new MainFrame();
- mainFrame.setVisible(true);
- }).start();
- new Thread(() -> joglFrame = new SwingGLCanvas2D()).start();
- } */
-
- /* public static void main(String[] args) {
-
- MainFrame frame = new MainFrame();
- frame.setVisible(true);
- SwingGLCanvas2D canvas = new SwingGLCanvas2D();
- canvas.setVisible(true);
- new Thread(() ->{
- SwingGLCanvas2D joglFrame = new SwingGLCanvas2D();
- String axiom="X";
- ArrayList> rules = new ArrayList<>();
- rules.add(new Pair<>("X=Y+[[X]-X]-Y[-YX]+X", "Y=YY"));
- joglFrame.setLSystem(axiom,rules,5);
- joglFrame.setVisible(true);
- }).start();
- } */
-
- public static MainFrame mainFrame;
- public static SwingGLCanvas2D joglFrame;
-
- public static void main(String[] args) {
- new Thread(() -> {
- mainFrame = new MainFrame();
- mainFrame.setVisible(true);
- }).start();
- new Thread(() -> joglFrame = new SwingGLCanvas2D()).start();
- }
-
-}
diff --git a/src/lsystem/screen/gl2d/JoglEventListener2D.java b/src/lsystem/screen/gl2d/JoglEventListener2D.java
deleted file mode 100644
index c88facf..0000000
--- a/src/lsystem/screen/gl2d/JoglEventListener2D.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package lsystem.screen.gl2d;
-
-import com.jogamp.opengl.GL2;
-import com.jogamp.opengl.GLAutoDrawable;
-
-import lsystem.engine.Element;
-import lsystem.engine.ElementProperties;
-import lsystem.screen.AbstractListener;
-import lsystem.screen.gl3d.DrawHelper;
-
-public class JoglEventListener2D extends AbstractListener {
-
- public JoglEventListener2D(SwingGLCanvas2D swingGLCanvas) {
- super(swingGLCanvas);
- }
-
- @Override
- public void drawLSystem(GL2 gl, Element element) {
- drawAll(gl, element, new lsystem.screen.gl2d.Point2(-1.0f, -1.0f));
- }
-
- private void drawAll(GL2 gl, Element actual, lsystem.screen.gl2d.Point2 origin) {
- if (actual.property == ElementProperties.DRAW) {
- System.out.println("DESSIN");
- lsystem.screen.gl2d.Point2 newOrigin = new lsystem.screen.gl2d.Point2(origin, actual.getRotation2D());
- DrawHelper.drawStick(gl, origin, newOrigin);
- }
- System.out.println(actual.children.isEmpty());
- for (Element children : actual.children) {
- System.out.println("CHILD");
- drawAll(gl, children, new lsystem.screen.gl2d.Point2(origin, actual.getRotation2D()));
- }
- }
-
- @Override
- public void display(GLAutoDrawable glAutoDrawable) {
-
- GL2 gl = glAutoDrawable.getGL().getGL2();
-
- drawLSystem(gl, canvas.getLSystem());
- drawAll(gl, canvas.getLSystem(), new lsystem.screen.gl2d.Point2(-1.0f, -1.0f));
-
- }
-}
diff --git a/src/lsystem/screen/gl2d/Point2.java b/src/lsystem/screen/gl2d/Point2.java
deleted file mode 100644
index 2383435..0000000
--- a/src/lsystem/screen/gl2d/Point2.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package lsystem.screen.gl2d;
-
-public class Point2 {
- private float x;
- private float y;
-
- public Point2 () {
-
- }
-
- public Point2 (float x, float y) {
- this.x = x;
- this.y = y;
- }
-
- public Point2 (Point2 old, int angle) {
- angle = compactAngle(angle);
- //Point a = new Point();
- //x = getNewOrigin(old, angle, 0.1f);
- getNewOrigin(old, angle, 0.1f);
- }
-
- public float getX() {
- return x;
- }
-
- public void setX(float x) {
- this.x = x;
- }
-
- public float getY() {
- return y;
- }
-
- public void setY(float y) {
- this.y = y;
- }
-
- public void getNewOrigin (Point2 old, int angle, float echelle) {
-
- int newX=0, newY=0;
- switch (angle) {
- case 0:
- newX = 1;
- newY = 1;
- break;
- case 45:
- newX = 1;
- newY = 0;
- break;
- case 90:
- newX = 1;
- newY = -1;
- break;
- case 135:
- newX = 0;
- newY = -1;
- break;
- case 180:
- newX = -1;
- newY = -1;
- break;
- case 225:
- newX = -1;
- newY = 0;
- break;
- case 270:
- newX = -1;
- newY = 1;
- break;
- case 315:
- newX = 0;
- newY = 1;
- break;
- }
-
- this.x = old.getX() + echelle * newX;
- this.y+= old.getY() + echelle * newY;
- //return old;
- }
-
- public String toString () {
- return "("+this.x+";"+this.y+")";
- }
-
- public static int compactAngle (int angle) {
- angle = angle - ((angle / 360) * 360);
- switch (angle) {
- case -315:
- angle = 45;
- break;
- case -270:
- angle = 90;
- break;
- case -225:
- angle = 135;
- break;
- case -180:
- angle = 180;
- break;
- case -135:
- angle = 225;
- break;
- case -90:
- angle = 270;
- break;
- case -45:
- angle = 315;
- break;
- }
- return angle;
- }
-
-}
diff --git a/src/lsystem/screen/gl2d/SwingGLCanvas2D.java b/src/lsystem/screen/gl2d/SwingGLCanvas2D.java
deleted file mode 100644
index 9c93afc..0000000
--- a/src/lsystem/screen/gl2d/SwingGLCanvas2D.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package lsystem.screen.gl2d;
-
-import lsystem.screen.AbstractCanvas;
-
-
-public class SwingGLCanvas2D extends AbstractCanvas {
-
- @Override
- protected void addEventsListeners() {
- glCanvas.addGLEventListener(new JoglEventListener2D(this));
- }
-}
diff --git a/src/lsystem/screen/gl3d/DrawHelper.java b/src/lsystem/screen/gl3d/DrawHelper.java
index 71c1bc0..1e963b8 100644
--- a/src/lsystem/screen/gl3d/DrawHelper.java
+++ b/src/lsystem/screen/gl3d/DrawHelper.java
@@ -3,7 +3,6 @@ package lsystem.screen.gl3d;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.util.gl2.GLUT;
import lsystem.screen.AbstractCanvas;
-import lsystem.screen.gl2d.Point2;
public class DrawHelper {
@@ -89,14 +88,6 @@ public class DrawHelper {
+ canvas.camera[3] + " pitch = " + canvas.camera[4] + " roll = " + canvas.camera[5]);
}
- public static void drawStick(GL2 gl, Point2 origin, Point2 newOrigin) {
-
- gl.glBegin(GL2.GL_LINES);
- gl.glVertex2f(origin.getX(), origin.getY());
- gl.glVertex2f(newOrigin.getX(), newOrigin.getY());
- gl.glEnd();
- }
-
}
diff --git a/src/lsystem/screen/gl3d/GLEventListener.java b/src/lsystem/screen/gl3d/GLEventListener.java
index 3ae258b..bb1eb8b 100644
--- a/src/lsystem/screen/gl3d/GLEventListener.java
+++ b/src/lsystem/screen/gl3d/GLEventListener.java
@@ -10,6 +10,7 @@ import lsystem.screen.AbstractListener;
public class GLEventListener extends AbstractListener {
private final float[] light_0_position = {1000f, 1000f, 1000f, 1f};
+ private boolean firstGen;
public GLEventListener(GLCanvas swingGLCanvas) {
@@ -38,6 +39,7 @@ public class GLEventListener extends AbstractListener {
gl.glDepthFunc(GL2.GL_LEQUAL);
gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
super.init(glAutoDrawable);
+ firstGen = true;
}
@Override
@@ -55,10 +57,11 @@ public class GLEventListener extends AbstractListener {
gl.glRotatef(90f, -1f, 0f, 0f);
gl.glColor3f(0f, 1f, 0f);
drawLSystem(gl, canvas.getLSystem());
+ firstGen = false;
gl.glPopMatrix();
DrawHelper.drawAxes(gl, glut);
- DrawHelper.drawDebugInformation(gl, glut, canvas);
+ // DrawHelper.drawDebugInformation(gl, glut, canvas);
gl.glFlush();
fps++;
}
@@ -67,10 +70,14 @@ public class GLEventListener extends AbstractListener {
gl.glPushMatrix();
gl.glRotatef(element.rotation[0] * 360, 1f, 0f, 0f);
gl.glRotatef(element.rotation[1] * 360, 0f, 1f, 0f);
- gl.glRotated(-Math.sin(element.rotation[0]) * 180, 0f, 0f, 1f);
- gl.glRotated(-Math.sin(element.rotation[1]) * 180, 0f, 0f, 1f);
+ gl.glRotated(-Math.sin(element.rotation[0]) * 180 - Math.sin(element.rotation[1]) * 180, 0f, 0f, 1f);
gl.glTranslated(-Math.sin(element.rotation[0]), -Math.sin(element.rotation[1]), -Math.sin(element.rotation[0] + element.rotation[1]));
+
if(element.property == ElementProperties.DRAW) {
+ if(firstGen) {
+ canvas.camera[1] += 0.10f;
+ canvas.camera[2] += 0.10f;
+ }
glut.glutSolidCylinder(0.25f, 1f, 10, 10);
gl.glTranslatef(0f, 0f, 1f);
}
diff --git a/src/lsystem/screen/main/Listener.java b/src/lsystem/screen/main/Listener.java
index 9b02dc6..ced979d 100644
--- a/src/lsystem/screen/main/Listener.java
+++ b/src/lsystem/screen/main/Listener.java
@@ -17,7 +17,7 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener
String type;
Integer nbAxioms = 0;
Thread parserThread = null;
- ImageIcon staticIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("loading-gif.gif")));
+ ImageIcon staticIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("./resources/loading-gif.gif")));
public Listener(MainFrame frame, Integer index, String type, Tab tab){
diff --git a/src/lsystem/utils/Pair.java b/src/lsystem/utils/Pair.java
index 20d95b5..4ed5df6 100644
--- a/src/lsystem/utils/Pair.java
+++ b/src/lsystem/utils/Pair.java
@@ -1,5 +1,7 @@
package lsystem.utils;
+import java.util.Objects;
+
/**
* tuple containing 2 unknown type elements
*
@@ -41,7 +43,7 @@ public class Pair {
@Override
public int hashCode() {
- return 31 + left.hashCode() * right.hashCode();
+ return Objects.hash(left.hashCode(), right.hashCode());
}
@Override