Пример #1
0
def test_good_files(
    obj_filename, n_vertices_and_normals, indices):
    vertices, normals, uvs, actual_indices = load_obj(
        'src/tests/samples/models/{}'.format(obj_filename))

    assert len(vertices) == len(normals) == n_vertices_and_normals * 3
    # Works with both lists and numpy.array objects
    assert np.all(actual_indices == np.array(indices, dtype=np.int32))
Пример #2
0
def load_obj_mesh(manager, fp, cwd):
    """Loader for obj meshes.

    :param manager: The resource manager
    :type manager: :class:`loaders.ResourceManager`

    :param fp: The file pointer
    :type fp: File

    :param cwd: The current working directory
    :type cwd: str

    :returns: The resulting mesh object
    :rtype: :class:`renderer.Mesh`
    """
    from renderlib.mesh import Mesh
    v, n, u, i = load_obj(as_utf8(fp.read()))
    return Mesh(v, i, n, u)
Пример #3
0
def load_obj_mesh(manager, fp, cwd):
    """Loader for obj meshes.

    :param manager: The resource manager
    :type manager: :class:`loaders.ResourceManager`

    :param fp: The file pointer
    :type fp: File

    :param cwd: The current working directory
    :type cwd: str

    :returns: The resulting mesh object
    :rtype: :class:`renderer.Mesh`
    """
    from renderlib.mesh import Mesh
    v, n, u, i = load_obj(as_utf8(fp.read()))
    return Mesh(v, i, n, u)
Пример #4
0
def test_invalid_files(
    obj_filename, exception):

    with pytest.raises(exception):
        vertices, normals, uvs, actual_indices = load_obj(
            'src/tests/samples/3dmodels/{}'.format(obj_filename))