Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e991f4ff6c
@ -13,7 +13,7 @@
|
|||||||
<javac srcdir="${project.sources.dir}" destdir="${project.bin.dir}" debug="on" optimize="off" deprecation="on" includeantruntime="false">
|
<javac srcdir="${project.sources.dir}" destdir="${project.bin.dir}" debug="on" optimize="off" deprecation="on" includeantruntime="false">
|
||||||
<classpath refid="project.classpath"/>
|
<classpath refid="project.classpath"/>
|
||||||
</javac>
|
</javac>
|
||||||
<copy todir="${basedir}/${project.bin.dir}">
|
<copy todir="${basedir}/${project.bin.dir}/${project.resources.dir}">
|
||||||
<fileset dir="${basedir}/${project.resources.dir}">
|
<fileset dir="${basedir}/${project.resources.dir}">
|
||||||
<exclude name="**/*.java"/>
|
<exclude name="**/*.java"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
@ -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<Pair<String, String>> 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,6 @@ package lsystem.screen.gl3d;
|
|||||||
import com.jogamp.opengl.GL2;
|
import com.jogamp.opengl.GL2;
|
||||||
import com.jogamp.opengl.util.gl2.GLUT;
|
import com.jogamp.opengl.util.gl2.GLUT;
|
||||||
import lsystem.screen.AbstractCanvas;
|
import lsystem.screen.AbstractCanvas;
|
||||||
import lsystem.screen.gl2d.Point2;
|
|
||||||
|
|
||||||
public class DrawHelper {
|
public class DrawHelper {
|
||||||
|
|
||||||
@ -89,14 +88,6 @@ public class DrawHelper {
|
|||||||
+ canvas.camera[3] + " pitch = " + canvas.camera[4] + " roll = " + canvas.camera[5]);
|
+ 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import lsystem.screen.AbstractListener;
|
|||||||
public class GLEventListener extends AbstractListener {
|
public class GLEventListener extends AbstractListener {
|
||||||
|
|
||||||
private final float[] light_0_position = {1000f, 1000f, 1000f, 1f};
|
private final float[] light_0_position = {1000f, 1000f, 1000f, 1f};
|
||||||
|
private boolean firstGen;
|
||||||
|
|
||||||
|
|
||||||
public GLEventListener(GLCanvas swingGLCanvas) {
|
public GLEventListener(GLCanvas swingGLCanvas) {
|
||||||
@ -38,6 +39,7 @@ public class GLEventListener extends AbstractListener {
|
|||||||
gl.glDepthFunc(GL2.GL_LEQUAL);
|
gl.glDepthFunc(GL2.GL_LEQUAL);
|
||||||
gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
|
gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
|
||||||
super.init(glAutoDrawable);
|
super.init(glAutoDrawable);
|
||||||
|
firstGen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,10 +57,11 @@ public class GLEventListener extends AbstractListener {
|
|||||||
gl.glRotatef(90f, -1f, 0f, 0f);
|
gl.glRotatef(90f, -1f, 0f, 0f);
|
||||||
gl.glColor3f(0f, 1f, 0f);
|
gl.glColor3f(0f, 1f, 0f);
|
||||||
drawLSystem(gl, canvas.getLSystem());
|
drawLSystem(gl, canvas.getLSystem());
|
||||||
|
firstGen = false;
|
||||||
gl.glPopMatrix();
|
gl.glPopMatrix();
|
||||||
|
|
||||||
DrawHelper.drawAxes(gl, glut);
|
DrawHelper.drawAxes(gl, glut);
|
||||||
DrawHelper.drawDebugInformation(gl, glut, canvas);
|
// DrawHelper.drawDebugInformation(gl, glut, canvas);
|
||||||
gl.glFlush();
|
gl.glFlush();
|
||||||
fps++;
|
fps++;
|
||||||
}
|
}
|
||||||
@ -67,10 +70,14 @@ public class GLEventListener extends AbstractListener {
|
|||||||
gl.glPushMatrix();
|
gl.glPushMatrix();
|
||||||
gl.glRotatef(element.rotation[0] * 360, 1f, 0f, 0f);
|
gl.glRotatef(element.rotation[0] * 360, 1f, 0f, 0f);
|
||||||
gl.glRotatef(element.rotation[1] * 360, 0f, 1f, 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[0]) * 180 - Math.sin(element.rotation[1]) * 180, 0f, 0f, 1f);
|
||||||
gl.glRotated(-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]));
|
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(element.property == ElementProperties.DRAW) {
|
||||||
|
if(firstGen) {
|
||||||
|
canvas.camera[1] += 0.10f;
|
||||||
|
canvas.camera[2] += 0.10f;
|
||||||
|
}
|
||||||
glut.glutSolidCylinder(0.25f, 1f, 10, 10);
|
glut.glutSolidCylinder(0.25f, 1f, 10, 10);
|
||||||
gl.glTranslatef(0f, 0f, 1f);
|
gl.glTranslatef(0f, 0f, 1f);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener
|
|||||||
String type;
|
String type;
|
||||||
Integer nbAxioms = 0;
|
Integer nbAxioms = 0;
|
||||||
Thread parserThread = null;
|
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){
|
public Listener(MainFrame frame, Integer index, String type, Tab tab){
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package lsystem.utils;
|
package lsystem.utils;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tuple containing 2 unknown type elements
|
* tuple containing 2 unknown type elements
|
||||||
*
|
*
|
||||||
@ -41,7 +43,7 @@ public class Pair<U, K> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 31 + left.hashCode() * right.hashCode();
|
return Objects.hash(left.hashCode(), right.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user