X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2FMain.java;fp=src%2FMain.java;h=a5365f095bdb5f3c5b7b4c2517e248741a84fbce;hb=212e1516923584fac360e0084d38291cc99bef74;hp=7830f5c87d1422050bcae5c75f4720f3f5b73a60;hpb=04b2e2c139e2087242fa911a6d3a8991d285bbb3;p=anneal.git diff --git a/src/Main.java b/src/Main.java index 7830f5c..a5365f0 100644 --- a/src/Main.java +++ b/src/Main.java @@ -174,26 +174,23 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener } } - //Geom.P mid = geom.newE(ltf, lbn).shatter(); + Geom.P mid = ltn.getE(mbn).shatter(); //tx.e2.shatter(); //tx.e3.shatter(); - //mid.move(geom.new V((float)-0.05,0,0)); - //mtf.move(geom.new V(0, (float)-0.05, (float)0.05)); + geom.bind(); + mid.move(geom.new V((float)0,0,(float)-0.05)); + //ltn.move(geom.new V((float)0,0,(float)-0.05)); - for(Geom.T t : geom) { - t.e1().dobind(); - t.e2().dobind(); - t.e3().dobind(); - } - + //mtf.move(geom.new V(0, (float)-0.05, (float)0.05)); + /* for(int i=0; i<100; i++) { rand(); } - + */ /* @@ -210,17 +207,27 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener } Random random = new Random(); - public void rand() { - int which = Math.abs(random.nextInt()) % points.length; + public synchronized void breakit() { + int i = Math.abs(random.nextInt()) % geom.es.size(); + Geom.E e = geom.es.poll(); + System.out.println("shatter " + e); + e.shatter(); + geom.unbind(); + geom.bind(); + } + public synchronized void rand() { + for(int i=0; i<10; i++) { + Geom.P p = geom.ts.get(Math.abs(random.nextInt()) % geom.ts.size()).e1().p1; float r1 = Math.abs(random.nextFloat()); r1 = r1 - (float)Math.floor(r1); r1 = r1 * (float)0.01; r1 = r1 - (float)0.005; switch(Math.abs(random.nextInt()) % 3) { - case 0: points[which].move(geom.new V((float)0, (float)r1, (float)0.00)); break; - case 1: points[which].move(geom.new V((float)r1, (float)0, (float)0.00)); break; - case 2: points[which].move(geom.new V((float)0, (float)0, (float)r1)); break; + case 0: p.move(geom.new V((float)0, (float)r1, (float)0)); break; + case 1: p.move(geom.new V((float)r1, (float)0, (float)0)); break; + case 2: p.move(geom.new V((float)0, (float)0, (float)r1)); break; } + } } /** @@ -241,7 +248,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { } - public void display(GLAutoDrawable drawable) { + public synchronized void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); GLU glu = new GLU(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); @@ -250,8 +257,8 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener glu.gluPerspective(50-tz, ((float)drawable.getWidth())/drawable.getHeight(), 0.5, 10); glu.gluLookAt(0, 0, -1, 0, 0, 0, 0, 1, 0); gl.glTranslatef(tx/(float)20, ty/(float)20, 0); - gl.glRotatef(anglex, 0, 1, 0); - gl.glRotatef(angley, 1, 0, 0); + gl.glRotatef(anglex/3, 0, 1, 0); + gl.glRotatef(angley/3, 1, 0, 0); gl.glBegin(GL.GL_TRIANGLES); draw(gl, true); @@ -263,11 +270,12 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener gl.glTranslatef(v.x, v.y, v.z); draw(gl, false); gl.glTranslatef(-v.x, -v.y, -v.z); + break; } } - private void draw(GL gl, boolean triangles) { + private synchronized void draw(GL gl, boolean triangles) { float red = 0.0f; float green = 0.0f; float blue = 0.0f; @@ -340,10 +348,12 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener glcanvas.addMouseWheelListener(main); glcanvas.addKeyListener(main); + int i = 0; while(true) { - Thread.sleep(100); + Thread.sleep(10); glcanvas.repaint(); main.rand(); + if (i++>10) { main.breakit(); i = 0; } } }