From 7b14b546c47ee1680fc8064771ad725c60649d71 Mon Sep 17 00:00:00 2001 From: Antonin Boyon Date: Tue, 23 Mar 2021 15:53:10 +0100 Subject: [PATCH] correction Point --- src/lsystem/Main2D.java | 14 +++++++++++++- src/lsystem/screen/gl2d/JoglEventListener2D.java | 8 ++++---- .../screen/gl2d/{Point.java => Point2.java} | 10 +++++----- src/lsystem/screen/gl3d/DrawHelper.java | 3 ++- 4 files changed, 24 insertions(+), 11 deletions(-) rename src/lsystem/screen/gl2d/{Point.java => Point2.java} (88%) diff --git a/src/lsystem/Main2D.java b/src/lsystem/Main2D.java index abcd7e8..c7eb203 100644 --- a/src/lsystem/Main2D.java +++ b/src/lsystem/Main2D.java @@ -3,6 +3,7 @@ package lsystem; import java.util.ArrayList; import lsystem.screen.gl2d.SwingGLCanvas2D; +import lsystem.screen.gl3d.GLCanvas; import lsystem.screen.main.MainFrame; import lsystem.utils.Pair; @@ -18,7 +19,7 @@ public class Main2D { new Thread(() -> joglFrame = new SwingGLCanvas2D()).start(); } */ - public static void main(String[] args) { + /* public static void main(String[] args) { MainFrame frame = new MainFrame(); frame.setVisible(true); @@ -32,6 +33,17 @@ public class Main2D { 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 index dfec901..3b2368c 100644 --- a/src/lsystem/screen/gl2d/JoglEventListener2D.java +++ b/src/lsystem/screen/gl2d/JoglEventListener2D.java @@ -54,16 +54,16 @@ public class JoglEventListener2D implements GLEventListener { public void dispose(GLAutoDrawable glAutoDrawable) { } - public void drawAll (GL2 gl, Element actual, lsystem.screen.gl2d.Point origin) { + public void drawAll (GL2 gl, Element actual, lsystem.screen.gl2d.Point2 origin) { if (actual.property == ElementProperties.DRAW) { System.out.println("DESSIN"); - lsystem.screen.gl2d.Point newOrigin = new lsystem.screen.gl2d.Point (origin, actual.getRotation2D()); + 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.Point (origin, actual.getRotation2D())); + drawAll(gl, children, new lsystem.screen.gl2d.Point2 (origin, actual.getRotation2D())); } } @@ -82,7 +82,7 @@ public class JoglEventListener2D implements GLEventListener { GL2 gl = glAutoDrawable.getGL().getGL2(); - drawAll (gl, canvas.getLSystem(), new lsystem.screen.gl2d.Point(-1.0f, -1.0f)); + drawAll (gl, canvas.getLSystem(), new lsystem.screen.gl2d.Point2(-1.0f, -1.0f)); } diff --git a/src/lsystem/screen/gl2d/Point.java b/src/lsystem/screen/gl2d/Point2.java similarity index 88% rename from src/lsystem/screen/gl2d/Point.java rename to src/lsystem/screen/gl2d/Point2.java index d1877f2..2383435 100644 --- a/src/lsystem/screen/gl2d/Point.java +++ b/src/lsystem/screen/gl2d/Point2.java @@ -1,19 +1,19 @@ package lsystem.screen.gl2d; -public class Point { +public class Point2 { private float x; private float y; - public Point () { + public Point2 () { } - public Point (float x, float y) { + public Point2 (float x, float y) { this.x = x; this.y = y; } - public Point (Point old, int angle) { + public Point2 (Point2 old, int angle) { angle = compactAngle(angle); //Point a = new Point(); //x = getNewOrigin(old, angle, 0.1f); @@ -36,7 +36,7 @@ public class Point { this.y = y; } - public void getNewOrigin (Point old, int angle, float echelle) { + public void getNewOrigin (Point2 old, int angle, float echelle) { int newX=0, newY=0; switch (angle) { diff --git a/src/lsystem/screen/gl3d/DrawHelper.java b/src/lsystem/screen/gl3d/DrawHelper.java index 65d2231..b534cb3 100644 --- a/src/lsystem/screen/gl3d/DrawHelper.java +++ b/src/lsystem/screen/gl3d/DrawHelper.java @@ -4,6 +4,7 @@ import com.jogamp.opengl.GL2; import com.jogamp.opengl.util.gl2.GLUT; import lsystem.screen.gl2d.Point; +import lsystem.screen.gl2d.Point2; import lsystem.screen.gl2d.SwingGLCanvas2D; public class DrawHelper { @@ -103,7 +104,7 @@ public class DrawHelper { + canvas.camera[3] + " pitch = " + canvas.camera[4] + " roll = " + canvas.camera[5]); } - public static void drawStick(GL2 gl, Point origin, Point newOrigin) { + public static void drawStick(GL2 gl, Point2 origin, Point2 newOrigin) { gl.glBegin(GL2.GL_LINES); gl.glVertex2f(origin.getX(), origin.getY());