private void calculateBounds(){

		float xMin = Float.MAX_VALUE;
		float yMin = Float.MAX_VALUE;
		float zMin = Float.MAX_VALUE;
		float xMax = -Float.MAX_VALUE;
		float yMax = -Float.MAX_VALUE;
		float zMax = -Float.MAX_VALUE;

		for(Polygon p : polygons){
			Rectangle2D.Float r = p.getBounds();
			if(r == null){System.out.println("Null bounds in polygon"); continue;}
			float rxMax = r.x + r.width;
			float ryMax = r.y + r.height;
			float zMi = p.getZMin();
			float zMa = p.getZMax();

			xMin = r.x < xMin ? r.x : xMin;
			yMin = r.y < yMin ? r.y : yMin;
			zMin = zMi < zMin ? zMi : zMin;
			xMax = rxMax > xMax ? rxMax : xMax;
			yMax = ryMax > yMax ? ryMax : yMax;
			zMax = zMa > zMax ? zMa : zMax;
		}

		this.zMin = zMin;
		this.zMax = zMax;
		bounds = new Rectangle2D.Float(xMin, yMin, xMax - xMin, yMax - yMin);
	}