public void DeleateTri(int index) { Debug.Log("Removing Triangle"); List <Vector3> curVer = mesh.vertices.ToList(); curVer.RemoveAt(index); int[] oldTriangle = mesh.mesh.triangles; int[] newTriangle = new int[mesh.Triangle.Length - 3]; int i = 0; int j = 0; while (j < mesh.mesh.triangles.Length) { if (j != index * 3) { newTriangle[i++] = oldTriangle[j++]; newTriangle[i++] = oldTriangle[j++]; newTriangle[i++] = oldTriangle[j++]; } else { j += 3; } } mesh.Triangle = newTriangle; mesh.SetVertices(curVer); }
public void AddDepression(Vector3 depressurePoint, float radius) { int index = 0; var worldPos4 = this.transform.worldToLocalMatrix * depressurePoint; var worldPos = new Vector3(worldPos4.x, worldPos4.y, worldPos4.z); for (int i = 0; i < modifierVecrtices.Count; i++) { Vector3 worldPt = transform.TransformPoint(modifierVecrtices[i]); var distance = Vector3.Distance(worldPos, worldPt); if (distance < radius) { Vector3 direction = (depressurePoint - modifierVecrtices[i]).normalized; Debug.Log(direction); index = i; var newVertex = modifierVecrtices[i] + direction * maximumDepression; modifierVecrtices.RemoveAt(i); modifierVecrtices.Insert(i, newVertex); } } mesh.SetVertices(modifierVecrtices); }