- Home /
Holes in procedural mesh
So I have a text file that defines coordinates for every vertex and indices for every triangle in a mesh. I have a script that I taught to read the data file and form a vertex and triangle array from. I then told my script to generate the normals array by using the RecalculateNormals function. My shape comes out almost correct, but it appears that some of the normals are facing the wrong way. I believe that it's the normals facing the wrong way because you can't see through the object like this when it is facing the other way:
Additionally, the original file is a vtk file, and when I put it into Paraview, the file displays without problem, so I don't think that it's an issue with the vertex or triangle information.
I think that the problem is in the RecalculateNormals method, but I'm not sure how to fix it.
It's possible that your mesh algorithm is generating one-dimensional triangles in some spots. I had a similar problem with dynamic physics meshes. There was a bug in my code that would make triangles where two vertices were in the same place. If this happens, RecalculateNormals is unable to calculate a proper normal based on a clockwise winding order.
The easiest way to find out if this is the problem is to make a Gizmo that draws the mesh normals.
Do you mean that out of the three indices in a triangle, more than one of the indices are the same?
Because otherwise my script almost definitely has three dimensions for each triangle. The number of triangles is divisble by three, and I've checked the first and last couple of triangles at the beginning and end of the array, and they all contain three unique indices and match what they should be according to the original data file.
Your answer
Follow this Question
Related Questions
Problem drawing a mesh with Graphics.DrawMeshNow 1 Answer
How to make sure two meshes have the same vertex count 0 Answers
What's wrong with this simple mesh manipulation? 1 Answer
Why is my mesh peeling off when I try to deform it during runtime? 1 Answer
Why does the default Unity sphere have duplicate vertices? 1 Answer