private void march() { for (int i = 0; i < this._dimX; i++) { for (int j = 0; j < this._dimY; j++) { for (int k = 0; k < this._dimZ; k++) { McBlock.mcCube mcCube = this._cubes[k + j * this.dimZ + i * this.dimZ * this.dimY]; if (mcCube != null && mcCube.cntr < this.pctr) { if (this.doCube(mcCube)) { this.recurseCube(mcCube); } mcCube.cntr = this.pctr; } } } } }
/*Generate the Cube Lattice * All shared vertices and edges are connected across cubes, * it's not perfect in that the edges along the lower index borders * are not connected, but all the rest are, this shouldn't make any * noticeable visual impact, and have no performance impact unless * a blob lies along those borders*/ private void startObjs() { // Debug.Log("startobjs"); int cubeCount = (dimX * dimY * dimZ); int pointCount = cubeCount * 8; int edgeCount = cubeCount * 12; //Ideal Edge Count int edgeNow = edgeCount + ((dimX * dimY) + (dimY * dimZ) + (dimZ * dimX)) * 2; //Haven't combined the edges of the 0 index borders int mc_VertexCount = 6500; //this.dimX * this.dimY * this.dimZ * 10; // Debug.Log("Vertex buffer size: " + mc_VertexCount); this.tadam = mc_VertexCount * 4; this.fv = new Vector3[mc_VertexCount]; this.fn = new Vector3[mc_VertexCount]; this.fuv = new Vector2[mc_VertexCount]; int i; // tris this.ft = new int[(int)((double)cubeCount * 3)]; this.newVertex = new Vector3[mc_VertexCount]; this.newTri = new int[mc_VertexCount]; this.newNormal = new Vector3[mc_VertexCount]; this.tada = new Vector3[this.tadam * 2]; this.tada2 = new Vector2[this.tadam * 2]; this._cubes = new McBlock.mcCube[cubeCount]; this._points = new McBlock.mcPoint[pointCount]; this._edges = new McBlock.mcEdge[edgeNow]; for (i = 0; i < this.tadam * 2; i++) { this.tada[i] = new Vector3(0f, 0f, 0f); this.tada2[i] = new Vector2(0f, 0f); } for (i = 0; i < edgeNow; i++) { this._edges[i] = new McBlock.mcEdge(-1); } i = 0; for (int stepX = 0; stepX < this.dimX + 1; stepX++) { for (int stepY = 0; stepY < this.dimY + 1; stepY++) { for (int stepZ = 0; stepZ < this.dimZ + 1; stepZ++) { this._points[i] = new McBlock.mcPoint(stepX / (float)this.dimX - 0.5f, stepY / (float)this.dimY - 0.5f, stepZ / (float)this.dimZ - 0.5f, (int)stepX, (int)stepY, (int)stepZ, this); i++; } } } // for (float stepX = 0f; stepX <= (float)this.dimX; stepX += 1f) { // for (float stepY = 0f; stepY <= (float)this.dimY; stepY += 1f) { // for (float stepZ = 0f; stepZ <= (float)this.dimZ; stepZ += 1f) { // // this._points[i] = new McBlock.mcPoint(stepX / (float)this.dimX - 0.5f, stepY / (float)this.dimY - 0.5f, stepZ / (float)this.dimZ - 0.5f, (int)stepX, (int)stepY, (int)stepZ, this); // i++; // // } // } // } // Debug.Log(i + " points created"); for (i = 0; i < cubeCount; i++) { this._cubes[i] = new McBlock.mcCube(); } int num9 = 0; i = 0; int num10 = 0; for (int j = 0; j < this.dimX; j++) { for (int k = 0; k < this.dimY; k++) { for (int l = 0; l < this.dimZ; l++) { McBlock.mcCube mcCube = this._cubes[i]; i++; mcCube.px = j; mcCube.py = k; mcCube.pz = l; McBlock.mcPoint[] points = mcCube.points; points[0] = this.getPoint(j, k, l); points[1] = this.getPoint(j + 1, k, l); points[2] = this.getPoint(j + 1, k + 1, l); points[3] = this.getPoint(j, k + 1, l); points[4] = this.getPoint(j, k, l + 1); points[5] = this.getPoint(j + 1, k, l + 1); points[6] = this.getPoint(j + 1, k + 1, l + 1); points[7] = this.getPoint(j, k + 1, l + 1); McBlock.mcEdge[] edges = mcCube.edges; edges[5] = this._edges[num9++]; edges[5].axisI = 1; edges[6] = this._edges[num9++]; edges[6].axisI = 0; edges[10] = this._edges[num9++]; edges[10].axisI = 2; McBlock.mcCube cube = this.getCube(j + 1, k, l); if (cube != null) { cube.edges[11] = edges[10]; cube.edges[7] = edges[5]; } cube = this.getCube(j, k + 1, l); if (cube != null) { cube.edges[4] = mcCube.edges[6]; cube.edges[9] = mcCube.edges[10]; } cube = this.getCube(j, k + 1, l + 1); if (cube != null) { cube.edges[0] = mcCube.edges[6]; } cube = this.getCube(j + 1, k, l + 1); if (cube != null) { cube.edges[3] = mcCube.edges[5]; } cube = this.getCube(j + 1, k + 1, l); if (cube != null) { cube.edges[8] = mcCube.edges[10]; } cube = this.getCube(j, k, l + 1); if (cube != null) { cube.edges[1] = mcCube.edges[5]; cube.edges[2] = mcCube.edges[6]; } if (edges[0] == null) { edges[0] = this._edges[num9++]; edges[0].axisI = 0; } if (edges[1] == null) { edges[1] = this._edges[num9++]; edges[1].axisI = 1; } if (edges[2] == null) { edges[2] = this._edges[num9++]; edges[2].axisI = 0; } else { num10++; } if (edges[3] == null) { edges[3] = this._edges[num9++]; edges[3].axisI = 1; } if (edges[4] == null) { edges[4] = this._edges[num9++]; edges[4].axisI = 0; } if (edges[7] == null) { edges[7] = this._edges[num9++]; edges[7].axisI = 1; } if (edges[8] == null) { edges[8] = this._edges[num9++]; edges[8].axisI = 2; } if (edges[9] == null) { edges[9] = this._edges[num9++]; edges[9].axisI = 2; } if (edges[11] == null) { edges[11] = this._edges[num9++]; edges[11].axisI = 2; } } } } }