public void doPowder(Color[] colors, Powder powder, VectorInt3 min, VectorInt3 max) { VectorInt3 mi = min + this._offset; //VectorInt3 mx = max + this._offset; foreach (VoxelFace.Rect r in powder.rect) { for (int x = r.min.x; x < r.max.x; ++x) { for (int y = r.min.y; y < r.max.y; ++y) { for (int z = r.min.z; z < r.max.z; ++z) { VoxelHandler handler = _mesh.getVoxel(new VectorInt3(x, y, z) + mi); // Debug.Log ("x" + x + "y" +y +"z" + z); if (handler != null) { foreach (VectorInt4 vertice in handler.vertices) { colors[vertice.x] = r.color; colors[vertice.y] = r.color; colors[vertice.z] = r.color; colors[vertice.w] = r.color; } } } } } } foreach (VoxelFace.Point p in powder.point) { VoxelHandler handler = _mesh.getVoxel(p.position + mi); if (handler != null) { foreach (VectorInt4 vertice in handler.vertices) { colors[vertice.x] = p.color; colors[vertice.y] = p.color; colors[vertice.z] = p.color; colors[vertice.w] = p.color; } } } }
public void change(int index) { Debug.Log(index); VoxelModel model = _model [index]; VoxelData[] datas = model.data; Color[] colors = _voxelMesh._mesh.mesh.colors; Debug.LogWarning("datas" + datas); for (int i = 0; i < datas.Length; ++i) { VoxelHandler handler = _voxelMesh.getVoxel(new VectorInt3(datas[i].pos.x, datas[i].pos.y, datas[i].pos.z)); if (handler != null) { foreach (VectorInt4 vertice in handler.vertices) { colors[vertice.x] = datas[i].color; colors[vertice.y] = datas[i].color; colors[vertice.z] = datas[i].color; colors[vertice.w] = datas[i].color; } } } _voxelMesh._mesh.mesh.colors = colors; }