- Home /
How do I guarantee a generated sphere's mesh is facing outward?
I have an algorithm that generates a sphere (which will eventually become a planet generator).
According to this post, http://answers.unity3d.com/questions/231141/why-does-my-script-made-mesh-only-look-visible-fro.html the answer says "The order which the vertices are linked determines which direction they face."
How do I order the vertices to guarantee they are facing outward?
Answer by giulio-pierucci · Feb 10, 2015 at 08:57 PM
You'd organize vertices (index or triagles) clockwise:
http://answers.unity3d.com/questions/187637/procedural-meshs-normals-are-reversed.html
and use Mesh.RecalculateNormals.
Otherwise, you can write normal vectors in mesh with (vertexPos - center).normalized
I'll have to go back and try to figure out what "clockwise" means in terms of the vertex positions the algorithm calculates.
You can set normal manually.
BTW clockwise is represented by image on link.
TRIANGLE 1 indexes: 1 2 4 TRIANGLE 2 indexes: 2 3 4
$$anonymous$$y indicies are ordered ascending as in the example, but it doesn't resolve the problem.
Set up normal manually. It had to work, i wrote a custom halo system with Dynamic $$anonymous$$esh
I fixed the problem by rewriting the way the algorithm generates the triangles.
Your answer
Follow this Question
Related Questions
Setting triangles failing 0 Answers
UV-ing a sphere procedurally 1 Answer
Why vertex positions appear (0.0, 0.0, 0.0) ? 1 Answer
Best Way to Link Vertices into Mesh 0 Answers
Grouping vertices? 1 Answer