private void CreatePreview() { GPUVoxelData data = GPUVoxelizer.Voxelize(shader, selectedMesh, resolution, false, false); previewMesh = VoxelMesh.Build(data.GetData(), data.UnitLength, true); selectedVoxelInfo = BuildVoxInfo(data.GetData(), data.UnitLength); CreatePreviewPalette(); }
Mesh BuildPoints(GPUVoxelData data, out int[] vIndices) { var voxels = data.GetData(); var vertices = new List <Vector3>(); var indices = new List <int>(); var vIndicesTmp = new List <int>(); var count = 0; for (int i = 0, n = voxels.Length; i < n; i++) { var v = voxels[i]; if (v.flag) { vertices.Add(v.position); indices.Add(count++); vIndicesTmp.Add(i); } } vIndices = vIndicesTmp.ToArray(); var mesh = new Mesh(); mesh.indexFormat = IndexFormat.UInt32; mesh.vertices = vertices.ToArray(); mesh.SetIndices(indices.ToArray(), MeshTopology.Points, 0); mesh.RecalculateBounds(); return(mesh); }