- // rotate to align major axis -- this probably needs to be done by a human.
- //goal.transform(Matrix.rotate(new Vec(0, 0, 1), (float)(Math.PI/2)));
-
-
- float goal_width = goal.diagonal().dot(new Vec(1, 0, 0));
- float goal_height = goal.diagonal().dot(new Vec(0, 1, 0));
- float goal_depth = goal.diagonal().dot(new Vec(0, 0, 1));
-
- /*
- float width = (float)0.6;
- float height = (float)0.08;
- float depth = (float)0.3;
- */
-
- float width = (float)0.8;
- float depth = (float)0.08;
- float height = (float)0.4;
-
- float rshift = width/2;
- float lshift = -(width/2);
- float halfup = 0;
- //float shift = height/2;
- //width = (width*2)/3;
- float shift = 0;
- translations = new Matrix[] {
-
- Matrix.translate(new Vec(lshift/2, depth, -shift)),
- Matrix.translate(new Vec(rshift/2, depth, -shift)),
- Matrix.translate(new Vec(lshift/2, -depth, -shift)),
- Matrix.translate(new Vec(rshift/2, -depth, -shift)),
-
- Matrix.translate(new Vec(lshift, depth/2, -shift)),
- Matrix.translate(new Vec(rshift, depth/2, -shift)),
- Matrix.translate(new Vec(lshift, -depth/2, -shift)),
- Matrix.translate(new Vec(rshift, -depth/2, -shift)),
-
-
- /*
- Matrix.translate(new Vec(lshift, depth, -shift)),
- Matrix.translate(new Vec(rshift, depth, -shift)),
- Matrix.translate(new Vec(lshift, -depth, -shift)),
- Matrix.translate(new Vec(rshift, -depth, -shift)),
- */
- /*
- Matrix.translate(new Vec(lshift, depth, shift)),
- Matrix.translate(new Vec(rshift, depth, shift)),
- Matrix.translate(new Vec(lshift, -depth, shift)),
- Matrix.translate(new Vec(rshift, -depth, shift)),
- */
- //Matrix.translate(new Vec(0, depth, 0)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
- //Matrix.translate(new Vec(0, -depth, 0)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
- //Matrix.translate(new Vec(0, 0, height)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
- //Matrix.translate(new Vec(0, 0, -height)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
-
- //Matrix.translate(new Vec(0, depth, 0)),
- //Matrix.translate(new Vec(0, -depth, 0)),
- Matrix.translate(new Vec(0, 0, height)),
- Matrix.translate(new Vec(0, 0, -height)),
-
- //Matrix.translate(new Vec(lshift, depth, height/2)),
- //Matrix.translate(new Vec(lshift, depth, -height/2)),
- //Matrix.translate(new Vec(rshift, -depth, height/2)),
- //Matrix.translate(new Vec(rshift, -depth, -height/2)),
- //Matrix.translate(new Vec(rshift, 0, height)),
- //Matrix.translate(new Vec(rshift, 0, -height)),
-
- Matrix.translate(new Vec( width, 0, 0)),
- Matrix.translate(new Vec(-width, 0, 0)),
-
- Matrix.ONE
- };
-
- float unit = 0.1f;
- float r = unit/2;
- float sin = (float)(unit * Math.sin(Math.PI/3));
- float cos = (float)(unit * Math.cos(Math.PI/3));
- float x = (float)(r*Math.tan(Math.PI/6));
- float z = (float)(r/Math.cos(Math.PI/6));
- height = 2*r*(float)Math.sqrt(2f/3f);
-
-
- r *= 0.3f;
- cos *= 0.3f;
- unit *= 0.3f;
-
-
- /*
- sin *= 0.3f;
- x *= 0.3f;
- z *= 0.3f;
- */
- translations = new Matrix[] {
- Matrix.translate(new Vec(-unit, 0, 0)),
- Matrix.translate(new Vec( unit, 0, 0)),
- Matrix.translate(new Vec(-cos, 0, sin)),
- Matrix.translate(new Vec( cos, 0, sin)),
- Matrix.translate(new Vec(-cos, 0, -sin)),
- Matrix.translate(new Vec( cos, 0, -sin)),
- Matrix.translate(new Vec( 0, height, z)),
- Matrix.translate(new Vec(-r, height, -x)),
- Matrix.translate(new Vec( r, height, -x)),
- Matrix.translate(new Vec( 0, -height, -z)),
- Matrix.translate(new Vec(-r, -height, x)),
- Matrix.translate(new Vec( r, -height, x)),
- };
-
-
- /*
- translations = new Matrix[] {
-
- //Matrix.translate(new Vec(lshift, depth, halfup)),
- //Matrix.translate(new Vec(rshift, depth, halfup)),
- //Matrix.translate(new Vec(lshift, -depth, halfup)),
- //Matrix.translate(new Vec(rshift, -depth, halfup)),
-
-
- //Matrix.translate(new Vec(0, depth, 0)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
- //Matrix.translate(new Vec(0, -depth, 0)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
-
- Matrix.translate(new Vec(0, 0, height)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
- Matrix.translate(new Vec(0, 0, -height)).times(Matrix.rotate(new Vec(0, 0, 1), (float)Math.PI)),
-
- //Matrix.translate(new Vec(0, depth, 0)),
- //Matrix.translate(new Vec(0, -depth, 0)),
- //Matrix.translate(new Vec(0, 0, height)),
- //Matrix.translate(new Vec(0, 0, -height)),
-
- //Matrix.translate(new Vec(lshift, depth, height/2)),
- //Matrix.translate(new Vec(lshift, depth, -height/2)),
- //Matrix.translate(new Vec(rshift, -depth, height/2)),
- //Matrix.translate(new Vec(rshift, -depth, -height/2)),
- //Matrix.translate(new Vec(rshift, 0, height)),
- //Matrix.translate(new Vec(rshift, 0, -height)),
-
- Matrix.translate(new Vec( width, 0, 0)),
- Matrix.translate(new Vec(-width, 0, 0)),
-
- };
- */
- //
-
-
- //generateTile(translations, tile);
-
- Point ltf = new Point(lshift, (depth/2), (height/2));
- Point mtf = new Point( 0.0, (depth/2), (height/2));
- Point rtf = new Point(rshift, (depth/2), (height/2));
- Point lbf = new Point(lshift, -(depth/2), (height/2));
- Point mbf = new Point( 0.0, -(depth/2), (height/2));
- Point rbf = new Point(rshift, -(depth/2), (height/2));
-
- Point ltc = new Point(lshift, (depth/2), 0);
- Point mtc = new Point( 0.0, (depth/2), 0);
- Point rtc = new Point(rshift, (depth/2), 0);
- Point lbc = new Point(lshift, -(depth/2), 0);
- Point mbc = new Point( 0.0, -(depth/2), 0);
- Point rbc = new Point(rshift, -(depth/2), 0);
-
- Point ltn = new Point(lshift, (depth/2), -(height/2));
- Point mtn = new Point( 0.0, (depth/2), -(height/2));
- Point rtn = new Point(rshift, (depth/2), -(height/2));
- Point lbn = new Point(lshift, -(depth/2), -(height/2));
- Point mbn = new Point( 0.0, -(depth/2), -(height/2));
- Point rbn = new Point(rshift, -(depth/2), -(height/2));
-
-
- Point[] points = new Point[] {
- ltf,
- mtf,
- rtf,
- lbf,
- mbf,
- rbf,
-
- ltc,
- mtc,
- rtc,
- lbc,
- mbc,
- rbc,
-
- ltn,
- mtn,
- rtn,
- lbn,
- mbn,
- rbn
- };
- /*
-
- // top
- tile.newT(ltf, mtf, mtc, null, 1);
- tile.newT(mtc, ltc, ltf, null, 1);
- tile.newT(mtf, rtf, rtc, null, 1);
- tile.newT(rtc, mtc, mtf, null, 1);
-
- tile.newT(ltc, mtc, mtn, null, 1);
- tile.newT(mtn, ltn, ltc, null, 1);
- tile.newT(mtc, rtc, rtn, null, 1);
- tile.newT(rtn, mtn, mtc, null, 1);
-
- // bottom (swap normals)
- tile.newT(mbf, lbf, mbc, null, 2);
- tile.newT(lbc, mbc, lbf, null, 2);
- tile.newT(rbf, mbf, rbc, null, 2);
- tile.newT(mbc, rbc, mbf, null, 2);
-
- tile.newT(mbc, lbc, mbn, null, 2);
- tile.newT(lbn, mbn, lbc, null, 2);
-
- tile.newT(rbc, mbc, rbn, null, 2);
- tile.newT(mbn, rbn, mbc, null, 2);
-
-
- // left
- tile.newT(ltf, ltc, lbc, null, 3);
- tile.newT(lbc, lbf, ltf, null, 3);
- tile.newT(ltc, ltn, lbn, null, 3);
- tile.newT(lbn, lbc, ltc, null, 3);
-
- // right (swap normals)
- tile.newT(rtc, rtf, rbc, null, 4);
- tile.newT(rbf, rbc, rtf, null, 4);
- tile.newT(rtn, rtc, rbn, null, 4);
- tile.newT(rbc, rbn, rtc, null, 4);
-
- // front
- tile.newT(ltn, mtn, mbn, null, 5);
- tile.newT(ltn, mbn, lbn, null, 5);
- tile.newT(mtn, rtn, rbn, null, 5);
- tile.newT(mtn, rbn, mbn, null, 5);
-
- // back
- tile.newT(mtf, ltf, mbf, null, 6);
- tile.newT(mbf, ltf, lbf, null, 6);
- tile.newT(rtf, mtf, rbf, null, 6);
- tile.newT(rbf, mtf, mbf, null, 6);
-*/
- /*
- HashSet<Mesh.E> es = new HashSet<Mesh.E>();
- for(Mesh.T t : tile) {
- es.add(t.e1());
- es.add(t.e2());
- es.add(t.e3());
- }
- for(Mesh.E e : es) {
- if (e.p1.p.x == e.p2.p.x && e.p1.p.y == e.p2.p.y) continue;
- if (e.p1.p.z == e.p2.p.z && e.p1.p.y == e.p2.p.y) continue;
- if (e.p1.p.x == e.p2.p.x && e.p1.p.z == e.p2.p.z) continue;
- e.shatter();
- }
- */
-
-
- height = 4;
- width = 4;
- depth = 1;
-
- Matrix mm = Matrix.scale(0.1f);
- // top
- quad(tile, mm,
- new Point( 2, 2, 0),
- new Point( 1, 1, -1),
- new Point(-1, 1, -1),
- new Point(-2, 2, 0));
- quad(tile, mm,
- new Point(-2, 2, 0),
- new Point(-1, 1, 1),
- new Point( 1, 1, 1),
- new Point( 2, 2, 0));
- quad(tile, mm,
- new Point( 1, 1, -1),
- new Point( 1, 1, 1),
- new Point(-1, 1, 1),
- new Point(-1, 1, -1));
-
- // bottom
- quad(tile, mm,
- new Point(-2, -2, 0),
- new Point(-1, -1, -1),
- new Point( 1, -1, -1),
- new Point( 2, -2, 0));
- quad(tile, mm,
- new Point( 2, -2, 0),
- new Point( 1, -1, 1),
- new Point(-1, -1, 1),
- new Point(-2, -2, 0));
- quad(tile, mm,
- new Point(-1, -1, -1),
- new Point(-1, -1, 1),
- new Point( 1, -1, 1),
- new Point( 1, -1, -1));
-
- // left
- quad(tile, mm,
- new Point( 2, -2, 0),
- new Point( 1, -1, -1),
- new Point( 1, 1, -1),
- new Point( 2, 2, 0));
- quad(tile, mm,
- new Point( 2, 2, 0),
- new Point( 1, 1, 1),
- new Point( 1, -1, 1),
- new Point( 2, -2, 0));
- quad(tile, mm,
- new Point( 1, -1, -1),
- new Point( 1, -1, 1),
- new Point( 1, 1, 1),
- new Point( 1, 1, -1));
-
- // bottom
- quad(tile, mm,
- new Point(-2, 2, 0),
- new Point(-1, 1, -1),
- new Point(-1, -1, -1),
- new Point(-2, -2, 0));
- quad(tile, mm,
- new Point(-2, -2, 0),
- new Point(-1, -1, 1),
- new Point(-1, 1, 1),
- new Point(-2, 2, 0));
- quad(tile, mm,
- new Point(-1, 1, -1),
- new Point(-1, 1, 1),
- new Point(-1, -1, 1),
- new Point(-1, -1, -1));
-
-
-
- translations = new Matrix[] {
- /*
- Matrix.translate(new Vec(0, 0.2f,0))
- .times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))),
-
- Matrix.translate(new Vec(0,-0.2f,0))
- .times(Matrix.rotate(new Vec(0,1,0), (float)(-1*Math.PI/2))),
-
- Matrix.translate(new Vec( 0.2f,0,0))
- .times(Matrix.rotate(new Vec(1,0,0), (float)( 1*Math.PI/2))),
-
- Matrix.translate(new Vec(-0.2f,0,0))
- .times(Matrix.rotate(new Vec(1,0,0), (float)(-1*Math.PI/2))),
- */
-
- /*
- Matrix.rotate(new Vec(0,0,1), (float)(1*Math.PI/2)),
- Matrix.rotate(new Vec(0,0,1), (float)(2*Math.PI/2)),
- Matrix.rotate(new Vec(0,0,1), (float)(3*Math.PI/2)),
- */
- Matrix.rotate(new Vec(1,0,0), (float)(2*Math.PI/2)),
-
- //Matrix.rotate(new Vec(0,0,1), (float)(2*Math.PI/2)),
- //Matrix.scale(1,-1,1),
-
- //Matrix.translate(new Vec( 0.2f, 0,0))
- //.times(Matrix.rotate(new Vec(0,0,1), (float)( 1*Math.PI/2)))
- //.times(Matrix.rotate(new Vec(0,1,0), (float)( 3*Math.PI/2))),
-
- //Matrix.translate(new Vec(-0.2f, 0,0))
- //.times(Matrix.rotate(new Vec(0,0,1), (float)( 3*Math.PI/2)))
- //.times(Matrix.rotate(new Vec(0,1,0), (float)( 3*Math.PI/2))),
-
- //Matrix.rotate(new Vec(0,0,1), (float)( 0*Math.PI/2))
- //.times(Matrix.translate(new Vec(0, -0.2f, 0)))
- //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))),
- //Matrix.rotate(new Vec(0,0,1), (float)( 1*Math.PI/2))
- //.times(Matrix.translate(new Vec(0, -0.2f, 0)))
- //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))),
-
- //Matrix.rotate(new Vec(0,0,1), (float)( 0*Math.PI/2))
- //.times(Matrix.translate(new Vec(0, -0.2f, 0)))
- //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))),
- //Matrix.rotate(new Vec(0,0,1), (float)( 0*Math.PI/2))
- //.times(Matrix.translate(new Vec(0, -0.2f, 0)))
- //.times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))),
-
- Matrix.ONE,
- };
-
-
-
- for(Matrix m1 : translations) {
- for(Matrix m2 : translations) {
- for(Mesh.T t1 : tile) {
- for(Mesh.T t2 : tile) {
- if (t1==t2) continue;
-
- Matrix m = m1.inverse().times(m2);
- if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v2().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) &&
- (t1.v3().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) {
- t2.e3().bindEdge(t1.e1(), m);
- t2.e2().bindEdge(t1.e2(), m);
- t2.e1().bindEdge(t1.e3(), m);
- }
- if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v3().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) &&
- (t1.v1().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) {
- t2.e3().bindEdge(t1.e2(), m);
- t2.e2().bindEdge(t1.e3(), m);
- t2.e1().bindEdge(t1.e1(), m);
- }
- if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v1().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) &&
- (t1.v2().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) {
- t2.e3().bindEdge(t1.e3(), m);
- t2.e2().bindEdge(t1.e1(), m);
- t2.e1().bindEdge(t1.e2(), m);
- }