public List<Face> SplitQuad(Face face) { _face = face; _faces = new List<Face>(); GetCorners(); var width = _vertex1 - _vertex0; var height = _vertex3 - _vertex0; var deltaWidth = width / 2; var deltaHeight = height / 2; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { var vertex0 = _vertex0 + deltaWidth * i + deltaHeight * j; var vertex1 = _vertex0 + deltaWidth * (i+1) + deltaHeight * j; var vertex2 = _vertex0 + deltaWidth * (i+1) + deltaHeight * (j+1); var vertex3 = _vertex0 + deltaWidth * i + deltaHeight * (j+1); var newFace = new Face(new List<Vector3> {vertex0, vertex1, vertex2, vertex3}); _faces.Add(newFace); } } return _faces; }
public static bool AreNeighbours(this Face f, Face face) { var ownEdges = f.Edges; var faceEdges = face.Edges; return ownEdges.Any(edge => faceEdges.Any(e => e.AreEqual(edge))); }
public IEnumerable<Face> CreateCubeMesh() { //Front var vertex0 = new Vector3(-0.5f, -0.5f, 0.5f); var vertex1 = new Vector3(-0.5f, 0.5f, 0.5f); var vertex2 = new Vector3(0.5f, 0.5f, 0.5f); var vertex3 = new Vector3(0.5f, -0.5f, 0.5f); //Rear var vertex4 = new Vector3(-0.5f, -0.5f, -0.5f); var vertex5 = new Vector3(-0.5f, 0.5f, -0.5f); var vertex6 = new Vector3(0.5f, 0.5f, -0.5f); var vertex7 = new Vector3(0.5f, -0.5f, -0.5f); var front = new Face(new List<Vector3> { vertex0, vertex1, vertex2, vertex3 }); var back = new Face(new List<Vector3> { vertex4, vertex5, vertex6, vertex7 }); var left = new Face(new List<Vector3> { vertex4, vertex5, vertex1, vertex0 }); var right = new Face(new List<Vector3> { vertex7, vertex3, vertex2, vertex6 }); var top = new Face(new List<Vector3> { vertex1, vertex5, vertex6, vertex2 }); var bottom = new Face(new List<Vector3> { vertex0, vertex4, vertex7, vertex3 }); return new List<Face> {front, back, left, right, top, bottom}; }
public void SetUp() { _vertex0 = new Vector3(-1, -1, 0); _vertex1 = new Vector3(-1, 1, 0); _vertex2 = new Vector3(1, 1, 0); _vertex3 = new Vector3(1, -1, 0); _face = new Face(new List<Vector3> {_vertex0, _vertex1, _vertex2, _vertex3}); }