Exemplo n.º 1
0
def test01_create_mesh(variant_scalar_rgb):
    from mitsuba.core import Struct, float_dtype
    from mitsuba.render import Mesh

    m = Mesh("MyMesh", 3, 2)
    m.vertex_positions_buffer()[:] = [0.0, 0.0, 0.0, 1.0, 0.2, 0.0, 0.2, 1.0, 0.0]
    m.faces_buffer()[:] = [0, 1, 2, 1, 2, 0]
    m.parameters_changed()

    assert str(m) == """Mesh[
Exemplo n.º 2
0
def test01_create_mesh(variant_scalar_rgb):
    from mitsuba.render import Mesh

    m = Mesh("MyMesh", 3, 2)
    m.vertex_positions_buffer()[:] = [
        0.0, 0.0, 0.0, 1.0, 0.2, 0.0, 0.2, 1.0, 0.0
    ]
    m.faces_buffer()[:] = [0, 1, 2, 1, 2, 0]
    m.parameters_changed()
    m.surface_area()  # Ensure surface area computed

    assert str(m) == """Mesh[
Exemplo n.º 3
0
def test08_mesh_add_attribute(variant_scalar_rgb):
    from mitsuba.core import Struct, float_dtype
    from mitsuba.render import Mesh

    m = Mesh("MyMesh", 3, 2)
    m.vertex_positions_buffer()[:] = [
        0.0, 0.0, 0.0, 1.0, 0.2, 0.0, 0.2, 1.0, 0.0
    ]
    m.faces_buffer()[:] = [0, 1, 2, 1, 2, 0]
    m.parameters_changed()

    m.add_attribute("vertex_color",
                    3)[:] = [0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0]

    assert str(m) == """Mesh[
Exemplo n.º 4
0
def create_rectangle():
    from mitsuba.render import Mesh

    mesh = Mesh("rectangle", 4, 2, has_vertex_texcoords=True)
    mesh.vertex_positions_buffer()[:] = [
        0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0
    ]
    mesh.vertex_texcoords_buffer()[:] = [
        0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0
    ]
    mesh.faces_buffer()[:] = [0, 1, 2, 1, 3, 2]
    mesh.parameters_changed()

    mesh.add_attribute("vertex_mono", 1, [1.0, 2.0, 3.0, 4.0])
    mesh.add_attribute(
        "vertex_color", 3,
        [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0])

    mesh.add_attribute("face_mono", 1, [0.0, 1.0])
    mesh.add_attribute("face_color", 3, [0.0, 0.0, 0.0, 0.0, 0.0, 1.0])

    return mesh