private void AddHeightMapVoxelIJL() { float sqdist = heightmap_radius * heightmap_radius; int max = Mathf.CeilToInt(heightmap_radius); for (int i = -max; i <= max; i++) { for (int j = -max; j <= max; j++) { //distance validity check Vector3 v = VMD.VoxelVertex(new IJL(i, j, 0)); if (VMD.VoxelVertex(new IJL(i, j, 0)).sqrMagnitude > sqdist) { continue; } float h = height * Mathf.PerlinNoise(perlin_scale * (j + 0.1f), perlin_scale * (i + 0.1f)); int max_l = Mathf.CeilToInt(h); for (int l = 0; l < max_l; l++) { if (l > h) { continue; } AddVoxelIJL(new IJL(i, j, l)); } } } }
private void InitializeChunkObject(int index) { if (index < 0 || index >= _chunkobjs.Count || _chunkobjs[index] != null) { return; } IJL chunk = _chunksobj_ijls[index]; _chunkobjs[index] = new GameObject("Chunk " + chunk.ToString()); _chunkobjs[index].transform.localPosition = VMD.VoxelVertex(Vx.ChunkVoxelIJL(chunk, chunk_radius)); _chunkobjs[index].AddComponent <MeshFilter>(); MeshRenderer renderer = _chunkobjs[index].AddComponent <MeshRenderer>(); renderer.sharedMaterial = material; }