X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2FMain.java;h=fc8d2eed78d70375c14a1e2e065d2de001c597de;hb=895456322db6e2b117fc2188683f91304165b72d;hp=bd40d1301181a138e2df01ef132ccd1026b271d8;hpb=2c711bea0246aca2caeace0a704a97d1305970d6;p=anneal.git diff --git a/src/Main.java b/src/Main.java index bd40d13..fc8d2ee 100644 --- a/src/Main.java +++ b/src/Main.java @@ -4,6 +4,8 @@ import javax.swing.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; +// FEATURE: check google's 3D warehouse for sample shapes + public class Main implements GLEventListener { private Geom geom = new Geom(); @@ -11,7 +13,116 @@ public class Main implements GLEventListener { /** magnification factor */ private static final float MAG = 1; + Geom.V[] translations; + Geom.P[] points; + public Main(StlFile stlf) { + + + Geom.P ltf = geom.newP(-0.2, 0.1, 0.1); + Geom.P mtf = geom.newP( 0.0, 0.1, 0.1); + Geom.P rtf = geom.newP( 0.2, 0.1, 0.1); + Geom.P ltn = geom.newP(-0.2, 0.1, -0.1); + Geom.P mtn = geom.newP( 0.0, 0.1, -0.1); + Geom.P rtn = geom.newP( 0.2, 0.1, -0.1); + Geom.P lbf = geom.newP(-0.2, -0.1, 0.1); + Geom.P mbf = geom.newP( 0.0, -0.1, 0.1); + Geom.P rbf = geom.newP( 0.2, -0.1, 0.1); + Geom.P lbn = geom.newP(-0.2, -0.1, -0.1); + Geom.P mbn = geom.newP( 0.0, -0.1, -0.1); + Geom.P rbn = geom.newP( 0.2, -0.1, -0.1); + + points = new Geom.P[] { + ltf, + mtf, + rtf, + ltn, + mtn, + rtn, + lbf, + mbf, + rbf, + lbn, + mbn, + rbn + }; + + translations = new Geom.V[] { + geom.new V(-0.2, 0.2, 0), + geom.new V( 0.2, 0.2, 0), + geom.new V(-0.2, -0.2, 0), + geom.new V( 0.2, -0.2, 0), + geom.new V( 0.4, 0, 0), + geom.new V(-0.4, 0, 0), + geom.new V( 0, 0, 0.2), + geom.new V( 0, 0, -0.2), + }; + + // top + geom.newT(ltf, mtf, mtn); + geom.newT(mtn, ltn, ltf); + geom.newT(mtf, rtf, rtn); + geom.newT(rtn, mtn, mtf); + + // bottom (swap normals) + geom.newT(mbf, lbf, mbn); + geom.newT(lbn, mbn, lbf); + geom.newT(rbf, mbf, rbn); + geom.newT(mbn, rbn, mbf); + + // left + geom.newT(ltf, ltn, lbn); + geom.newT(lbn, lbf, ltf); + + // right (swap normals) + geom.newT(rtn, rtf, rbn); + geom.newT(rbf, rbn, rtf); + + // front + geom.newT(ltn, mtn, mbn); + geom.newT(ltn, mbn, lbn); + geom.newT(mtn, rtn, rbn); + geom.newT(mtn, rbn, mbn); + + // back + geom.newT(mtf, ltf, mbf); + geom.newT(mbf, ltf, lbf); + geom.newT(rtf, mtf, rbf); + geom.newT(rbf, mtf, mbf); + + for(Geom.V v : translations) { + for(Geom.T t1 : geom) { + for(Geom.T t2 : geom) { + if (t1==t2) continue; + + if ((t1.p1().plus(v).minus(t2.p1()).mag() < Geom.EPSILON) && + (t1.p2().plus(v).minus(t2.p3()).mag() < Geom.EPSILON) && + (t1.p3().plus(v).minus(t2.p2()).mag() < Geom.EPSILON)) + t1.bind(t2, 0); + if ((t1.p2().plus(v).minus(t2.p1()).mag() < Geom.EPSILON) && + (t1.p3().plus(v).minus(t2.p3()).mag() < Geom.EPSILON) && + (t1.p1().plus(v).minus(t2.p2()).mag() < Geom.EPSILON)) + t1.bind(t2, 1); + if ((t1.p3().plus(v).minus(t2.p1()).mag() < Geom.EPSILON) && + (t1.p1().plus(v).minus(t2.p3()).mag() < Geom.EPSILON) && + (t1.p2().plus(v).minus(t2.p2()).mag() < Geom.EPSILON)) + t1.bind(t2, 2); + } + } + } + + //Geom.P mid = geom.newE(ltf, lbn).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)); + mtf.move(geom.new V(0, (float)-0.05, (float)0.00)); + + /* + for(int i=0; i