/// <summary> /// TESTING VON NEUMANN NEIGHBORS /// We can look at the specific voxels above,below,left,right,front,back and color.... /// We can get all von neumann neighbors and color /// </summary> /// void VonNeumannLookup() { //color specific voxel in the grid - [1,1,1] GameObject voxel_1 = voxelGrid[1, 1, 1]; voxel_1.GetComponent <VoxelOld>().SetState(1); voxel_1.GetComponent <VoxelOld>().VoxelDisplay(1, 0, 0); //color specific voxel in the grid - [10,10,10] GameObject voxel_2 = voxelGrid[10, 10, 10]; voxel_2.GetComponent <VoxelOld>().SetState(1); voxel_2.GetComponent <VoxelOld>().VoxelDisplay(1, 0, 0); //get neighbor right and color green VoxelOld voxel_1right = voxel_1.GetComponent <VoxelOld>().getVoxelRight(); voxel_1right.SetState(1); voxel_1right.VoxelDisplay(0, 1, 0); //get neighbor above and color green VoxelOld voxel_1above = voxel_1.GetComponent <VoxelOld>().getVoxelAbove(); voxel_1above.SetState(1); voxel_1above.VoxelDisplay(1, 0, 1); //get neighbor above and color magenta VoxelOld voxel_2above = voxel_2.GetComponent <VoxelOld>().getVoxelAbove(); voxel_2above.SetState(1); voxel_2above.VoxelDisplay(1, 0, 1); //get all VN neighbors of a cell and color yellow //color specific voxel in the grid - [12,12,12] GameObject voxel_3 = voxelGrid[12, 12, 12]; VoxelOld[] tempVNNeighbors = voxel_3.GetComponent <VoxelOld>().getNeighbors3dVN(); foreach (VoxelOld vox in tempVNNeighbors) { vox.SetState(1); vox.VoxelDisplay(1, 1, 0); } }
//voxel in back of this public void setVoxelBack(VoxelOld _voxelBack) { voxelBack = _voxelBack; }
/// <summary> /// SETUP MOORES & VON NEUMANN 3D NEIGHBORS /// </summary> void SetupNeighbors3d() { for (int i = 1; i < width - 1; i++) { for (int j = 1; j < length - 1; j++) { for (int k = 1; k < height - 1; k++) { //the current voxel we are looking at... GameObject currentVoxelObj = voxelGrid[i, j, k]; ////SETUP Von Neumann Neighborhood Cells//// VoxelOld[] tempNeighborsVN = new VoxelOld[6]; //left VoxelOld VoxelLeft = voxelGrid[i - 1, j, k].GetComponent <VoxelOld>(); currentVoxelObj.GetComponent <VoxelOld>().setVoxelLeft(VoxelLeft); tempNeighborsVN[0] = VoxelLeft; //right VoxelOld VoxelRight = voxelGrid[i + 1, j, k].GetComponent <VoxelOld>(); currentVoxelObj.GetComponent <VoxelOld>().setVoxelRight(VoxelRight); tempNeighborsVN[2] = VoxelRight; //back VoxelOld VoxelBack = voxelGrid[i, j - 1, k].GetComponent <VoxelOld>(); currentVoxelObj.GetComponent <VoxelOld>().setVoxelBack(VoxelBack); tempNeighborsVN[3] = VoxelBack; //front VoxelOld VoxelFront = voxelGrid[i, j + 1, k].GetComponent <VoxelOld>(); currentVoxelObj.GetComponent <VoxelOld>().setVoxelFront(VoxelFront); tempNeighborsVN[1] = VoxelFront; //below VoxelOld VoxelBelow = voxelGrid[i, j, k - 1].GetComponent <VoxelOld>(); currentVoxelObj.GetComponent <VoxelOld>().setVoxelBelow(VoxelBelow); tempNeighborsVN[4] = VoxelBelow; //above VoxelOld VoxelAbove = voxelGrid[i, j, k + 1].GetComponent <VoxelOld>(); currentVoxelObj.GetComponent <VoxelOld>().setVoxelAbove(VoxelAbove); tempNeighborsVN[5] = VoxelAbove; //Set the Von Neumann Neighbors [] in this Voxel currentVoxelObj.GetComponent <VoxelOld>().setNeighbors3dVN(tempNeighborsVN); ////SETUP Moore's Neighborhood//// VoxelOld[] tempNeighborsMO = new VoxelOld[26]; int tempcount = 0; for (int m = -1; m < 2; m++) { for (int n = -1; n < 2; n++) { for (int p = -1; p < 2; p++) { if ((i + m >= 0) && (i + m < width) && (j + n >= 0) && (j + n < length) && (k + p >= 0) && (k + p < height)) { GameObject neighborVoxelObj = voxelGrid[i + m, j + n, k + p]; if (neighborVoxelObj != currentVoxelObj) { VoxelOld neighborvoxel = voxelGrid[i + m, j + n, k + p].GetComponent <VoxelOld>(); tempNeighborsMO[tempcount] = neighborvoxel; tempcount++; } } } } } currentVoxelObj.GetComponent <VoxelOld>().setNeighbors3dMO(tempNeighborsMO); } } } }
//voxel in front of this public void setVoxelFront(VoxelOld _voxelFront) { voxelFront = _voxelFront; }
//voxel left of this public void setVoxelLeft(VoxelOld _voxelLeft) { voxelLeft = _voxelLeft; }
//voxel right of this public void setVoxelRight(VoxelOld _voxelRight) { voxelRight = _voxelRight; }
//voxel below this public void setVoxelBelow(VoxelOld _voxelBelow) { voxelBelow = _voxelBelow; }
//voxel above this public void setVoxelAbove(VoxelOld _voxelAbove) { voxelAbove = _voxelAbove; }