// --------------------------------------------------------------------------------------------- // create single voxel // --------------------------------------------------------------------------------------------- private VoxelUtils.VoxelChunk createVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d) { GameObject cube = GameObject.Instantiate(_prefabChunk); cube.transform.SetParent(_voxelChunkContainer); _iCount++; cube.name = "cube_" + _iCount.ToString(); float width = w * VoxelUtils.CHUNK_SIZE; float height = h * VoxelUtils.CHUNK_SIZE; float depth = d * VoxelUtils.CHUNK_SIZE; Vector3 pos = new Vector3((p.x * VoxelUtils.CHUNK_SIZE) + (width / 2f), (p.y * VoxelUtils.CHUNK_SIZE) + (height / 2f), (p.z * VoxelUtils.CHUNK_SIZE) + (depth / 2f)); Bounds b = new Bounds(); b.size = new Vector3(width, height, depth); b.center = pos; VoxelUtils.VoxelChunk vs = new VoxelUtils.VoxelChunk(); vs.go = cube; vs.goPos = pos; vs.pos = p; vs.size = new VoxelUtils.VoxelVector3Int(w, h, d); vs.bounds = b; //coll.bounds; vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d); return(vs); }
// --------------------------------------------------------------------------------------------- // // --------------------------------------------------------------------------------------------- private VoxelUtils.VoxelChunk createCutVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d) { float width = w * VoxelUtils.CHUNK_SIZE; float height = h * VoxelUtils.CHUNK_SIZE; float depth = d * VoxelUtils.CHUNK_SIZE; Vector3 pos = new Vector3((p.x * VoxelUtils.CHUNK_SIZE) + (width / 2f), (p.y * VoxelUtils.CHUNK_SIZE) + (height / 2f), (p.z * VoxelUtils.CHUNK_SIZE) + (depth / 2f)); Bounds b = new Bounds(); //coll.bounds; b.size = new Vector3(width - VoxelUtils.CHUNK_SIZE, height - VoxelUtils.CHUNK_SIZE, depth - VoxelUtils.CHUNK_SIZE); b.center = pos; VoxelUtils.VoxelChunk vs = new VoxelUtils.VoxelChunk(); vs.pos = p; vs.size = new VoxelUtils.VoxelVector3Int(w, h, d); vs.bounds = b; //coll.bounds; vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d); return(vs); }