public void Update() { if (this.needsUpdate && !this.original.IsNull()) { if (this.type == MeshSmoothType.Laplacian) { //this.current = MeshSmoothing.LaplacianFilter(this.original.Copy(),this.iterations); this.current = this.original.Copy(); for (int index = 0; index < this.iterations; ++index) { this.current.vertices = SmoothFilter.laplacianFilter(this.current.vertices, this.current.triangles); } } if (this.type == MeshSmoothType.HCLaplacian) { //this.current = MeshSmoothing.HCFilter(this.original.Copy(),this.iterations,this.hcAlpha,this.hcBeta); this.current = this.original.Copy(); for (int index = 0; index < this.iterations; ++index) { this.current.vertices = SmoothFilter.hcFilter(this.original.vertices, this.current.vertices, this.current.triangles, this.hcAlpha, this.hcBeta); } } this.source.SetMesh(this.current); this.needsUpdate = false; } }
//not used public static Mesh Smooth(MeshFilter meshfilter) { Mesh sourceMesh; Mesh workingMesh; // Clone the cloth mesh to work on sourceMesh = new Mesh(); // Get the sourceMesh from the originalSkinnedMesh sourceMesh = meshfilter.mesh; // Clone the sourceMesh workingMesh = CloneMesh(sourceMesh); // Reference workingMesh to see deformations meshfilter.mesh = workingMesh; // Apply Laplacian Smoothing Filter to Mesh int iterations = 1; for (int i = 0; i < iterations; i++) { //workingMesh.vertices = SmoothFilter.laplacianFilter(workingMesh.vertices, workingMesh.triangles); workingMesh.vertices = SmoothFilter.hcFilter(sourceMesh.vertices, workingMesh.vertices, workingMesh.triangles, 0.0f, 0.5f); } return(workingMesh); }
// Use this for initialization void Start() { MeshFilter meshfilter = gameObject.GetComponentInChildren <MeshFilter>(); sourceMesh = new Mesh(); // Get the sourceMesh from the originalSkinnedMesh sourceMesh = meshfilter.mesh; // Clone the sourceMesh workingMesh = MeshUtils.CloneMesh(sourceMesh); // Reference workingMesh to see deformations meshfilter.mesh = workingMesh; workingMesh.vertices = SmoothFilter.hcFilter(sourceMesh.vertices, workingMesh.vertices, workingMesh.triangles, 0.0f, 0.5f); }
public static Mesh SmoothMesh(Mesh mesh, int power, Filter filterType) { for (int i = 0; i < power; ++i) { if (filterType == Filter.HC) { mesh.vertices = SmoothFilter.hcFilter(mesh.vertices, mesh.vertices, mesh.triangles, 0.0f, 0.5f); } if (filterType == Filter.Laplacian) { mesh.vertices = SmoothFilter.laplacianFilter(mesh.vertices, mesh.triangles); } } return(mesh); }
public void Smooth() { // Get the sourceMesh from the originalSkinnedMesh Mesh sourceMesh = meshFilter.sharedMesh; // Clone the sourceMesh Mesh workingMesh = MeshUtils.CloneMesh(sourceMesh); // Reference workingMesh to see deformations meshFilter.sharedMesh = workingMesh; // Apply Laplacian Smoothing Filter to Mesh int iterations = 1; for (int i = 0; i < iterations; i++) { //workingMesh.vertices = SmoothFilter.laplacianFilter(workingMesh.vertices, workingMesh.triangles); sourceMesh.vertices = SmoothFilter.hcFilter(workingMesh.vertices, sourceMesh.vertices, workingMesh.triangles, 0.0f, 0.5f); } UpdateMountain(); }
void Start() { MeshFilter meshfilter = gameObject.GetComponentInChildren <MeshFilter>(); // Clone the cloth mesh to work on sourceMesh = new Mesh(); // Get the sourceMesh from the originalSkinnedMesh sourceMesh = meshfilter.mesh; // Clone the sourceMesh workingMesh = CloneMesh(sourceMesh); // Reference workingMesh to see deformations meshfilter.mesh = workingMesh; // Apply Laplacian Smoothing Filter to Mesh int iterations = 1; for (int i = 0; i < iterations; i++) { //workingMesh.vertices = SmoothFilter.laplacianFilter(workingMesh.vertices, workingMesh.triangles); workingMesh.vertices = SmoothFilter.hcFilter(sourceMesh.vertices, workingMesh.vertices, workingMesh.triangles, 0.0f, 0.5f); } }