public Face CreateFace(Vertex[] verticesToUse, CreateOption createOption = CreateOption.ReuseExisting) { if (verticesToUse.Length == 3 && (verticesToUse[0].Position == verticesToUse[1].Position || verticesToUse[1].Position == verticesToUse[2].Position || verticesToUse[2].Position == verticesToUse[0].Position)) { return(null); } if (verticesToUse.Length < 3) { throw new ArgumentException("A face cannot have less than 3 vertices."); } List <MeshEdge> edgesToUse = new List <MeshEdge>(); for (int i = 0; i < verticesToUse.Length - 1; i++) { edgesToUse.Add(CreateMeshEdge(verticesToUse[i], verticesToUse[i + 1], createOption)); } edgesToUse.Add(CreateMeshEdge(verticesToUse[verticesToUse.Length - 1], verticesToUse[0], createOption)); // make the face and set it's data Face createdFace = new Face(); CreateFaceEdges(verticesToUse, edgesToUse, createdFace); createdFace.CalculateNormal(); faces.Add(createdFace); return(createdFace); }
public void ReverseFaceEdges(Face faceToReverse) { FaceEdge temp = null; FaceEdge current = faceToReverse.firstFaceEdge; // swap next and prev for all nodes of // doubly linked list do { temp = current.prevFaceEdge; current.prevFaceEdge = current.nextFaceEdge; current.nextFaceEdge = temp; current = current.prevFaceEdge; // go to the next } while (current != faceToReverse.firstFaceEdge); faceToReverse.CalculateNormal(); }
public Face CreateFace(Vertex[] verticesToUse, CreateOption createOption = CreateOption.ReuseExisting) { if (verticesToUse.Length == 3 && (verticesToUse[0].Position == verticesToUse[1].Position || verticesToUse[1].Position == verticesToUse[2].Position || verticesToUse[2].Position == verticesToUse[0].Position)) { return null; } if (verticesToUse.Length < 3) { throw new ArgumentException("A face cannot have less than 3 vertices."); } List<MeshEdge> edgesToUse = new List<MeshEdge>(); for (int i = 0; i < verticesToUse.Length - 1; i++) { edgesToUse.Add(CreateMeshEdge(verticesToUse[i], verticesToUse[i + 1], createOption)); } edgesToUse.Add(CreateMeshEdge(verticesToUse[verticesToUse.Length - 1], verticesToUse[0], createOption)); // make the face and set it's data Face createdFace = new Face(); CreateFaceEdges(verticesToUse, edgesToUse, createdFace); createdFace.CalculateNormal(); faces.Add(createdFace); return createdFace; }
public void ReverseFaceEdges(Face faceToReverse) { FaceEdge temp = null; FaceEdge current = faceToReverse.firstFaceEdge; // swap next and prev for all nodes of // doubly linked list do { temp = current.prevFaceEdge; current.prevFaceEdge = current.nextFaceEdge; current.nextFaceEdge = temp; current = current.prevFaceEdge; // go to the next } while (current != faceToReverse.firstFaceEdge); faceToReverse.CalculateNormal(); }