public void Initialize(int resolution, float size, float maxFeatureAngle, Action initCallback) { this.initCallback = initCallback; callbacksCount = 0; sharpFeatureLimit = Mathf.Cos(maxFeatureAngle * Mathf.Deg2Rad); this.resolution = resolution; gridSize = size; voxelSize = size / resolution; voxels = new Voxel[resolution * resolution]; voxelMaterials = new Material[voxels.Length]; dummyX = new Voxel(); dummyY = new Voxel(); dummyT = new Voxel(); for (int i = 0, y = 0; y < resolution; y++) { for (int x = 0; x < resolution; x++, i++) { CreateVoxel(i, x, y); } } surface = Instantiate(surfacePrefab) as VoxelGridSurface; surface.transform.parent = transform; surface.transform.localPosition = Vector3.zero; surface.Initialize(resolution, InitCallback); wall = Instantiate(wallPrefab) as VoxelGridWall; wall.transform.parent = transform; wall.transform.localPosition = Vector3.zero; wall.Initialize(resolution, InitCallback); }
private void CreateRenderers() { renderers = new VoxelRenderer[materials.Length + 1]; for (int i = 0; i < materials.Length; i++) { VoxelGridSurface surface = Instantiate(surfacePrefab) as VoxelGridSurface; surface.transform.parent = transform; surface.transform.localPosition = Vector3.zero; surface.Initialize(resolution, materials[i].surfaceMaterial); VoxelGridWall wall = Instantiate(wallPrefab) as VoxelGridWall; wall.transform.parent = transform; wall.transform.localPosition = Vector3.zero; wall.Initialize(resolution, materials[i].wallMaterial); renderers[i + 1] = new VoxelRenderer(surface, wall); } }
public VoxelRenderer(VoxelGridSurface surface, VoxelGridWall wall) { this.surface = surface; this.wall = wall; }