private Triangle(TVertex vertex1, TVertex vertex2, TVertex vertex3) { m_tvertices.Add(vertex1); m_tvertices.Add(vertex2); m_tvertices.Add(vertex3); //Make sure they are in clockwise for the indexes if (Vector3.Dot(Vector3.Cross(m_tvertices[1].Vertex - m_tvertices[0].Vertex, m_tvertices[2].Vertex - m_tvertices[0].Vertex), m_tvertices[0].Normal) < 0) { m_tvertices.Reverse(); } createEdges(); }
private Vector3?getIntersection(TVertex start, TVertex end, Vector3 position, Plane plane, out TVertex?leftSide, out TVertex?rightSide) { Line edge = new Line(start.Vertex, end.Vertex); Vector3?intersection = edge.PlaneIntersection(position, plane); leftSide = null; rightSide = null; if (intersection != null) { TVertex left = new TVertex(); TVertex right = new TVertex(); left.Vertex = intersection.Value; right.Vertex = intersection.Value; //Add the intersection to create the new triangles if (plane.GetSide(edge.StartPoint)) { left.UV = end.UV; left.Normal = end.Normal; right.UV = start.UV; right.Normal = start.Normal; } else { right.UV = end.UV; right.Normal = end.Normal; left.UV = start.UV; left.Normal = start.Normal; } leftSide = left; rightSide = right; } return(intersection); }
public Edge(TVertex start, TVertex end) { StartVertex = start; EndVertex = end; }