MeshSmoother

Author : MarkGX, Jan 2011

Introduction
This c# code demonstrates how to deformate a mesh at runtime using smoothing algorithms. To solve this problem in a reasonable computational time a good algorithm is needed to solve the adjacent vertex problem. Unity lacks mesh manipulation utilities and some manual effort is required to achieve this.



The figure from unity shows the Laplacian Smoother applied to a cube imported from 3DS Max.



The figure from unity shows the HC Smooth Filter applied to a cube imported from 3DS Max.

Basic Theory
Given a Mesh/SkinnedMeshRenderer Vector3[] v = mesh.vertices,  and int[] t = mesh.triangles.

For each vertex i in the mesh, find the set of neighboring vertices.

Computing the Laplacian Smooth Filter p[i] = ( 1 / number of adjacent vertices ) * summation of the adjacent vertices.

Laplacian smoothing introduces shrinkage, so the HC-Algorithm is applied as an extension to reduce this issue. (More computationally expensive though !).

General Discussion
Although the code demonstrates smoothing meshes, it provides a more generic strategy for manipulating meshes in Unity as many deformation algorithms could be applied. Have Fun!