void CreateChunk(int x, int y, int z) { VoxelGrid grid = Instantiate(voxelGridPrefab); grid.transform.parent = transform; grid.transform.localPosition = new Vector3((x * chunkSize.x - halfMapSize.x), (y * chunkSize.y - halfMapSize.y), (z * chunkSize.z - halfMapSize.z)); grid.Initialize(voxelResolution, voxelSize); chunks[MathUtils.getIndexFromXYZ(x, y, z, chunkResolution)] = grid; if (x > 0) { chunks[MathUtils.getIndexFromXYZ(x - 1, y, z, chunkResolution)].xNeighbor = grid; } if (y > 0) { chunks[MathUtils.getIndexFromXYZ(x, y - 1, z, chunkResolution)].yNeighbor = grid; } if (z > 0) { chunks[MathUtils.getIndexFromXYZ(x, y, z - 1, chunkResolution)].zNeighbor = grid; if (x > 0 && y > 0) { chunks[MathUtils.getIndexFromXYZ(x - 1, y - 1, z - 1, chunkResolution)].xyzNeighbor = grid; } } }
private void CreateChunk(int i, int x, int y) { VoxelGrid chunk = Instantiate(voxelGridPrefab) as VoxelGrid; chunk.Initialize(voxelResolution, chunkSize); chunk.transform.parent = transform; chunk.transform.localPosition = new Vector3(x * chunkSize - halfSize, y * chunkSize - halfSize); chunks[i] = chunk; }
private void CreateChunk(int i, int x, int y) { VoxelGrid chunk = Instantiate(voxelGridPrefab) as VoxelGrid; chunk.Initialize(voxelResolution, chunkSize); chunk.transform.parent = transform; chunk.transform.localPosition = new Vector3(x * chunkSize - halfSize, y * chunkSize - halfSize); chunks[i] = chunk; if (x > 0) { chunks[i - 1].xNeighbor = chunk; } if (y > 0) { chunks[i - chunkResolution].yNeighbor = chunk; if (x > 0) { chunks[i - chunkResolution - 1].xyNeighbor = chunk; } } }
private void CreateChunk(int i, int x, int y, float z, int matID, bool isLast) { VoxelGrid chunk = Instantiate(voxelGridPrefab) as VoxelGrid; chunk.Initialize(voxelResolution, chunkSize, maxFeatureAngle, matID, isLast, InitCallback); chunk.transform.parent = transform; chunk.transform.localPosition = new Vector3(x * chunkSize - halfSize, y * chunkSize - halfSize, z); chunks[i] = chunk; if (x > 0) { chunks[i - 1].xNeighbor = chunk; } if (y > 0) { chunks[i - chunkResolutionX].yNeighbor = chunk; if (x > 0) { chunks[i - chunkResolutionX - 1].xyNeighbor = chunk; } } }