import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import java.util.*;
-import static edu.berkeley.qfat.Geom.*;
+import edu.berkeley.qfat.geom.*;
+import edu.berkeley.qfat.geom.Point;
// FIXME: recenter goal to have centroid coincident with tile
// FIXME: re-orient goal (how?)
/** magnification factor */
private static final float MAG = 1;
- Geom.M[] translations;
+ Matrix[] translations;
Geom.Vert[] points;
public Main(StlFile stlf) {
for(int i=0; i<stlf.coordArray.length; i+=3) {
- Geom.Vert p0 = goal.register(new Geom.Point(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG));
- Geom.Vert p1 = goal.register(new Geom.Point(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG));
- Geom.Vert p2 = goal.register(new Geom.Point(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG));
- Geom.Vec n = new Geom.Vec(stlf.normArray[i/3].x * MAG, stlf.normArray[i/3].y * MAG, stlf.normArray[i/3].z * MAG);
+ Geom.Vert p0 = goal.register(new Point(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG));
+ Geom.Vert p1 = goal.register(new Point(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG));
+ Geom.Vert p2 = goal.register(new Point(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG));
+ Vec n = new Vec(stlf.normArray[i/3].x * MAG, stlf.normArray[i/3].y * MAG, stlf.normArray[i/3].z * MAG);
Geom.T t = goal.newT(p0, p1, p2, n);
}
// rotate to align major axis -- this probably needs to be done by a human.
- goal.transform(new Geom.M(new Geom.Vec(0, 0, 1), (float)(Math.PI/2)));
+ goal.transform(new Matrix(new Vec(0, 0, 1), (float)(Math.PI/2)));
- float goal_width = goal.diagonal().dot(new Geom.Vec(1, 0, 0));
- float goal_height = goal.diagonal().dot(new Geom.Vec(0, 1, 0));
- float goal_depth = goal.diagonal().dot(new Geom.Vec(0, 0, 1));
+ 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;
- translations = new Geom.M[] {
-
- new Geom.M(new Geom.Vec(-(width/2), height, 0)),
- new Geom.M(new Geom.Vec( (width/2), height, 0)),
- new Geom.M(new Geom.Vec(-(width/2), -height, 0)),
- new Geom.M(new Geom.Vec( (width/2), -height, 0)),
- new Geom.M(new Geom.Vec(-(width/2), 0, depth)),
- new Geom.M(new Geom.Vec( (width/2), 0, depth)),
- new Geom.M(new Geom.Vec(-(width/2), 0, -depth)),
- new Geom.M(new Geom.Vec( (width/2), 0, -depth)),
-
- new Geom.M(new Geom.Vec( width, 0, 0)),
- new Geom.M(new Geom.Vec(-width, 0, 0)),
+ translations = new Matrix[] {
+
+ new Matrix(new Vec(-(width/2), height, 0)),
+ new Matrix(new Vec( (width/2), height, 0)),
+ new Matrix(new Vec(-(width/2), -height, 0)),
+ new Matrix(new Vec( (width/2), -height, 0)),
+ new Matrix(new Vec(-(width/2), 0, depth)),
+ new Matrix(new Vec( (width/2), 0, depth)),
+ new Matrix(new Vec(-(width/2), 0, -depth)),
+ new Matrix(new Vec( (width/2), 0, -depth)),
+
+ new Matrix(new Vec( width, 0, 0)),
+ new Matrix(new Vec(-width, 0, 0)),
/*
- new Geom.M(new Geom.Vec( 0, 0, depth)),
- new Geom.M(new Geom.Vec( 0, 0, -depth)),
+ new Matrix(new Vec( 0, 0, depth)),
+ new Matrix(new Vec( 0, 0, -depth)),
*/
};
- Geom.Vert ltf = tile.register(new Geom.Point(-(width/2), (height/2), (depth/2)));
- Geom.Vert mtf = tile.register(new Geom.Point( 0.0, (height/2), (depth/2)));
- Geom.Vert rtf = tile.register(new Geom.Point( (width/2), (height/2), (depth/2)));
- Geom.Vert ltn = tile.register(new Geom.Point(-(width/2), (height/2), -(depth/2)));
- Geom.Vert mtn = tile.register(new Geom.Point( 0.0, (height/2), -(depth/2)));
- Geom.Vert rtn = tile.register(new Geom.Point( (width/2), (height/2), -(depth/2)));
- Geom.Vert lbf = tile.register(new Geom.Point(-(width/2), -(height/2), (depth/2)));
- Geom.Vert mbf = tile.register(new Geom.Point( 0.0, -(height/2), (depth/2)));
- Geom.Vert rbf = tile.register(new Geom.Point( (width/2), -(height/2), (depth/2)));
- Geom.Vert lbn = tile.register(new Geom.Point(-(width/2), -(height/2), -(depth/2)));
- Geom.Vert mbn = tile.register(new Geom.Point( 0.0, -(height/2), -(depth/2)));
- Geom.Vert rbn = tile.register(new Geom.Point( (width/2), -(height/2), -(depth/2)));
+ Geom.Vert ltf = tile.register(new Point(-(width/2), (height/2), (depth/2)));
+ Geom.Vert mtf = tile.register(new Point( 0.0, (height/2), (depth/2)));
+ Geom.Vert rtf = tile.register(new Point( (width/2), (height/2), (depth/2)));
+ Geom.Vert ltn = tile.register(new Point(-(width/2), (height/2), -(depth/2)));
+ Geom.Vert mtn = tile.register(new Point( 0.0, (height/2), -(depth/2)));
+ Geom.Vert rtn = tile.register(new Point( (width/2), (height/2), -(depth/2)));
+ Geom.Vert lbf = tile.register(new Point(-(width/2), -(height/2), (depth/2)));
+ Geom.Vert mbf = tile.register(new Point( 0.0, -(height/2), (depth/2)));
+ Geom.Vert rbf = tile.register(new Point( (width/2), -(height/2), (depth/2)));
+ Geom.Vert lbn = tile.register(new Point(-(width/2), -(height/2), -(depth/2)));
+ Geom.Vert mbn = tile.register(new Point( 0.0, -(height/2), -(depth/2)));
+ Geom.Vert rbn = tile.register(new Point( (width/2), -(height/2), -(depth/2)));
points = new Geom.Vert[] {
ltf,
tile.newT(rtf, mtf, rbf);
tile.newT(rbf, mtf, mbf);
- for(Geom.M m : translations) {
+ for(Matrix m : translations) {
for(Geom.T t1 : tile) {
for(Geom.T t2 : tile) {
if (t1==t2) continue;
// rescale to match volume
float factor = (float)Math.pow(tile.volume() / goal.volume(), 1.0/3.0);
- goal.transform(new Geom.M(factor));
+ goal.transform(new Matrix(factor));
// translate to match centroid
- goal.transform(new Geom.M(tile.centroid().minus(goal.centroid())));
+ goal.transform(new Matrix(tile.centroid().minus(goal.centroid())));
//tx.e2.shatter();
//tx.e3.shatter();
tile.bind();
- //mid.move(new Geom.Vec((float)0,0,(float)-0.05));
- //ltn.move(new Geom.Vec((float)0,0,(float)-0.05));
+ //mid.move(new Vec((float)0,0,(float)-0.05));
+ //ltn.move(new Vec((float)0,0,(float)-0.05));
- //mtf.move(new Geom.Vec(0, (float)-0.05, (float)0.05));
+ //mtf.move(new Vec(0, (float)-0.05, (float)0.05));
System.out.println("tile volume: " + tile.volume());
r1 = r1 - (float)Math.floor(r1);
r1 = r1 * (float)0.01;
r1 = r1 - (float)0.005;
- Geom.Vec v = p.watchback().p.minus(p.p).norm().times(r1);
+ Vec v = p.watchback().p.minus(p.p).norm().times(r1);
//v = p.norm().times(v.dot(p.norm()));
boolean aspect = false;//(Math.abs(random.nextInt()) % 100) <= 2;
- Geom.M old_tile_aspect = null;//goal.aspect;
+ Matrix old_tile_aspect = null;//goal.aspect;
boolean good = true;
if (aspect) {
/*
v = v.times(10);
- tile.aspect = new Geom.M(tile.aspect.a / (v.x+1), tile.aspect.f / (v.y+1), tile.aspect.k / (v.z+1));
- tile.invaspect = new Geom.M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
+ tile.aspect = new Matrix(tile.aspect.a / (v.x+1), tile.aspect.f / (v.y+1), tile.aspect.k / (v.z+1));
+ tile.invaspect = new Matrix(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
goal.rescore();
tile.rescore();
*/
} else {
if (aspect) {
//tile.aspect = old_tile_aspect;
- //tile.invaspect = new Geom.M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
+ //tile.invaspect = new Matrix(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
goal.rescore();
tile.rescore();
} else {
int i = 0;
//gl.glDisable(GL.GL_DEPTH_TEST);
gl.glColor4f(1,1,1,1);
- for(Geom.M m : translations) {
+ for(Matrix m : translations) {
//if (v1.z==0 && v1.y==0) continue;
i++;
if (i != 1 /*&& i!=4*/) continue;
- Geom.Point p = new Geom.Point(0, 0, 0).times(m);
- Geom.Vec v = new Geom.Vec(p.x, p.y, p.z);
+ Point p = new Point(0, 0, 0).times(m);
+ Vec v = new Vec(p.x, p.y, p.z);
v = v.times((float)1.04);
gl.glTranslatef(v.x, v.y, v.z);
draw(gl, false, tile);
gl.glEnd();
}
- Geom.Point centroid = t.centroid();
+ Point centroid = t.centroid();
gl.glBegin(GL.GL_LINES);
gl.glColor3f(1, 1, 1);
/*