Hi all, I’ve tried searching for the answer and this is as close as I can get to the answer but can’t figure this one out. Please see the screenshot below:
The debug lines are the vertex normals in the direction the normal points. Where there are more than one line coming out of a single point, this is where more than one of the triangle vertices share a Vector3 position. So in the example screenshot, there are 6 triangles that share the central vertex position but each have different normals, and I need to figure out how to calculate a single normal direction.
This is so you can calculate an extruded position for the vector for further information.
I am using https://docs.unity3d.com/Manual/ComputingNormalPerpendicularVector.html as my starting point, here is some code in brief:
var side1 = SelectedTriangles[j].P1 - SelectedTriangles[j].P0;
var side2 = SelectedTriangles[j].P2 - SelectedTriangles[j].P0;
var perp = Vector3.Cross(side1, side2);
Debug.DrawLine(SelectedTriangles[j].P0, SelectedTriangles[j].P0 + (perp * 50), Color.yellow, 10, false);
var side3 = SelectedTriangles[j].P0 - SelectedTriangles[j].P1;
var side4 = SelectedTriangles[j].P2 - SelectedTriangles[j].P1;
var perp2 = Vector3.Cross(side3, side4);
Debug.DrawLine(SelectedTriangles[j].P1, SelectedTriangles[j].P1 + (perp2 * 50), Color.yellow, 10, false);
var side5 = SelectedTriangles[j].P0 - SelectedTriangles[j].P2;
var side6 = SelectedTriangles[j].P1 - SelectedTriangles[j].P2;
var perp3 = Vector3.Cross(side5, side6);
Debug.DrawLine(SelectedTriangles[j].P2, SelectedTriangles[j].P2 + (perp3 * 50), Color.yellow, 10, false);
The P0 / P1 / P2 refer to position for each vertex that makes up a triangle. Any ideas please?