import java.util.ArrayList; public class Geometry { double vertices[][]; int faces[][]; int draw[][]; int what = 0; ArrayList children = new ArrayList(); Matrix globalMatrix = new Matrix(); Matrix relativeMatrix = new Matrix(); public Geometry() { globalMatrix.identity(); relativeMatrix.identity(); } /* public void asWorld() { globalMatrix.identity(); relativeMatrix.identity(); } */ public Matrix getMatrix() { return relativeMatrix; } public Geometry add() { Geometry Child = new Geometry(); children.add(Child); return Child; } public void remove(Geometry Child) { children.remove(Child); } public int getNumChildren() { return children.size(); } public Geometry getChild(int index) { return children.get(index); } public void copy(double vertice[][], int face[][]) { // copy Matrix for (int row = 0; row < vertices.length ; row++) for (int col = 0 ; col < vertices[row].length ; col++) vertice[row][col] = vertices[row][col]; for (int row = 0; row < faces.length ; row++) for (int col = 0 ; col < faces[row].length ; col++) face[row][col] = faces[row][col]; } public void cube() { vertices = new double[][] { // all vertices in one face are counterclockwise {-1,-1,-1,1},{1,-1,-1,1},{1,-1,1,1},{-1,-1,1,1}, // low face {-1,-1,-1,1},{-1,1,-1,1},{1,1,-1,1},{1,-1,-1,1}, // back face {-1,-1,-1,1},{-1,-1,1,1},{-1,1,1,1},{-1,1,-1,1}, // left face {1,1,1,1},{1,1,-1,1},{-1,1,-1,1},{-1,1,1,1}, // up face {1,1,1,1},{-1,1,1,1},{-1,-1,1,1},{1,-1,1,1}, // front face {1,1,1,1},{1,-1,1,1},{1,-1,-1,1},{1,1,-1,1}, // right face }; faces = new int[][] { {0,1,2,3},{4,5,6,7},{8,9,10,11},{12,13,14,15},{16,17,18,19},{20,21,22,23} }; draw = new int[24][4]; } // by default it just give a unit cube public void globe (int m) { this.globe (m, m); } public void globe(int m, int n) { vertices = new double[(m+1)*(n+1)][4]; faces = new int[m*n][4]; draw = new int[(m+1)*(n+1)][4]; for (int i=0; i