/UnityMeshSimplifier

Mesh simplification for Unity.

Primary LanguageC#MIT LicenseMIT

UnityMeshSimplifier

Mesh simplification for Unity. The project is deeply based on the Fast Quadric Mesh Simplification algorithm, but rewritten entirely in C# and released under the MIT license.

Compatibility

These scripts have been tested and confirmed working with Unity 5.6.0f3, Unity 2017.1.0f3, Unity 2017.2.1f1 and Unity 2017.3.0f3.

Installation into Unity project

  1. Copy the contents of this repository into a folder named UnityMeshSimplifier in your Assets directory within your Unity project.
  2. Done!

How do I use this?

float quality = 0.5f;
var meshSimplifier = new UnityMeshSimplifier.MeshSimplifier();
meshSimplifier.Initialize(sourceMesh);
meshSimplifier.SimplifyMesh(quality);
var destMesh = meshSimplifier.ToMesh();

or

float quality = 0.5f;
var meshSimplifier = new UnityMeshSimplifier.MeshSimplifier();
meshSimplifier.Vertices = vertices;
meshSimplifier.AddSubMeshTriangles(indices);
meshSimplifier.SimplifyMesh(quality);
var newVertices = meshSimplifier.Vertices;
var newIndices = meshSimplifier.GetSubMeshTriangles(0);

Other projects

If you are interested in mesh simplification in .NET outside of Unity you can visit my other project MeshDecimator.