def test_GIVEN_a_single_triangle_face_WHEN_creating_vertex_buffer_THEN_output_is_correct( ): vertices = [QVector3D(0, 0, 0), QVector3D(0, 1, 0), QVector3D(1, 1, 0)] faces = [[0, 1, 2]] vertex_buffer = create_vertex_buffer(vertices, faces) expected_output = itertools.chain.from_iterable( [v.toTuple() for v in vertices]) assert list(vertex_buffer) == list(expected_output)
def test_GIVEN_a_square_WHEN_creating_vertex_buffer_THEN_length_is_correct(): vertices = [ QVector3D(0, 0, 0), QVector3D(1, 0, 0), QVector3D(0, 1, 0), QVector3D(1, 1, 0), ] faces = [[0, 1, 2, 3]] vertex_buffer = create_vertex_buffer(vertices, faces) assert (len(list(vertex_buffer)) == TRIANGLES_IN_SQUARE * VERTICES_IN_TRIANGLE * POINTS_IN_VERTEX)
def test_GIVEN_a_set_of_triangle_faces_WHEN_creating_vertex_buffer_THEN_length_is_total_points_in_all_faces( ): vertices = [ QVector3D(0, 0, 0), QVector3D(0, 1, 0), QVector3D(1, 1, 0), QVector3D(1, 0, 1), ] faces = [[0, 1, 2], [3, 2, 0], [2, 3, 1]] vertex_buffer = create_vertex_buffer(vertices, faces) NUM_OF_TRIANGLES = len(faces) assert (len(list(vertex_buffer)) == NUM_OF_TRIANGLES * VERTICES_IN_TRIANGLE * POINTS_IN_VERTEX)