Esempio n. 1
0
 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;
     }
 }
 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);
 }