//<pre>

import java.awt.*;

public class Shape3D {

	double vertices[][];
	int faces[][];
	double transformedVertices[][];
	Matrix3D transformationMatrix;
	Color myColor;
	double x, y, z;
	double vx, vy, vz;
	double ax, ay, az;
	World world;
	
	public Shape3D(World w) {

		world = w;
		transformationMatrix = new Matrix3D();
		transformationMatrix.identity();
		setColor(Color.yellow);
		x = 0;
		y = 0;
		z = 0;
	}
	
	public void transform( ) {
	
//		System.out.println("Entering transform with the following matrix");
//		transformationMatrix.print();
		
		for (int i = 0; i < vertices.length; i++) {
				for (int j = 0; j < vertices[i].length; j++) {
					transformationMatrix.transform(vertices[i],transformedVertices[i]);
//				if ((((int)world.time) % 3) == 0) {
//					System.out.println("I know camera is at " + world.myCamera.z + " and I thought a vertex with z = " + vertices[i][2] + " should be drawn.");
//					System.out.println("And I'm taking " + vertices[i][0] + " " + vertices[i][1] + " " + vertices[i][2] + " to ---> " + transformedVertices[i][0] + " " + transformedVertices[i][1] + " " + transformedVertices[i][2]);
//				}
			}
		}
	}
	
	public int size() {
		return faces.length;
	}
	
	public void setVertices( double[][] v ) {
	
		vertices = v;
	
	}

	public void setFaces( int[][] f) {
	
		faces = f;
	}
	
	public Color getColor() {
		return myColor;
	}
	
	public void setColor(Color c) {
		myColor = c;
	}
	
	public void update() {
	}

	public void animate() {
	}

	public void centerAt(double a, double b, double c) {
	}

	public void update(Matrix3D wMatrix) {
		transformationMatrix.copy(wMatrix);
		this.transform();
	}
	
	public void scale(double a, double b, double c) {
		transformationMatrix.scale(a, b, c);
	}

	public void translate(double a, double b, double c) {
		transformationMatrix.translate(a, b, c);
	}
	
	public void rotateX(double theta) {
		transformationMatrix.rotateX(theta);
	}

	public void rotateY(double theta) {
		transformationMatrix.rotateY(theta);
	}

	public void rotateZ(double theta) {
		transformationMatrix.rotateZ(theta);
	}

	public void print() {
	
		System.out.println(vertices.length + " vertices are... x,y,z,nx,ny,nz");
		for (int i = 0; i < vertices.length; i++) {
			System.out.println(vertices[i][0] + ", " + vertices[i][1] + ", " + vertices[i][2]);
		}

		System.out.println(vertices.length + " transformed vertices are... x,y,z,nx,ny,nz");
		for (int i = 0; i < vertices.length; i++) {
			System.out.println(transformedVertices[i][0] + ", " + transformedVertices[i][1] + ", " + transformedVertices[i][2]);
		}

		System.out.println("\n" + faces.length + "faces are...");
		String aFace;
		for (int i = 0; i < faces.length; i++) {
			aFace = "";
			for (int j = 0; j < faces[i].length; j++) {
				aFace = aFace + "\t\t" + faces[i][j];
			}
			System.out.println(aFace);
		}


		System.out.println("<printing complete>");
	}
}
