Ejemplo n.º 1
0
    public void RefreshMesh()
    {
        if (!_dirty)
        {
            return;
        }

        _dirty = false;
        if (_count == 0)
        {
            _parentController.DeleteSegment(_segmentIndex);
        }
        else
        {
            var ret = _marchingCubesEngine.Marching(_editSpace, _segmentIndex.multi(poly_object_segment_width));

            Mesh mesh       = new Mesh();
            var  meshFilter = GetComponent <MeshFilter> ();
            meshFilter.mesh = mesh;
            mesh.vertices   = ret.vertices.ToArray();
            mesh.triangles  = ret.triangles.ToArray();
            //		mesh.uv = _uvs.ToArray();
            mesh.RecalculateNormals();
            mesh.colors = ret.colors.ToArray();
            mesh.uv     = ret.uvs.ToArray();

            var meshColider = GetComponent <MeshCollider> ();
            meshColider.sharedMesh = mesh;
        }
    }