Converting a plain Mesh to smooth

It sometime happens that imported Mesh have Plain meshNature and look faceted. The following code snippet demonstrates how to convert them to a new smooth Mesh entity.

 

// Creates a new Mesh with Smooth meshNature 
Mesh smooth = new Mesh(original.Vertices.Length, original.Triangles.Length, meshNatureType.Smooth); 

// Assigns original vertices to smooth one 
smooth.Vertices = m.Vertices; 

// Converts triangles type 
for (int i = 0; i < m.Triangles.Length; i++) 
{ 
   IndexTriangle it = m.Triangles[i]; 
   smooth.Triangles[i] = new SmoothTriangle(it.V1, it.V2, it.V3); 
} 

// copies some attributes                     
smooth.Color = original.Color; 
smooth.ColorMethod = original.ColorMethod; 
smooth.LayerIndex = original.LayerIndex;
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.