Esempio n. 1
0
def main():

    # tetrahedron vertices and faces:
    pt = 1 / np.sqrt(2)

    points = [[1, 0, -pt], [-1, 0, -pt], [0, 1, pt], [0, -1, pt]]

    faces = [[0, 1, 2], [0, 1, 3], [1, 2, 3], [0, 2, 3]]

    # colors assigned to vertices
    colors = [
        [0.7, 0, 0],
        [0, 0.7, 0],
        [0, 0, 0.7],
        [1, 1, 1],
    ]

    rt = TkOptiX()  # create and configure, show the window later

    rt.set_param(min_accumulation_step=2, max_accumulation_frames=100)
    rt.setup_camera("cam1",
                    cam_type="DoF",
                    eye=[1, -6, 4],
                    focal_scale=0.9,
                    fov=25)
    rt.setup_light("light1", pos=[10, -9, -8], color=[14, 13, 12], radius=4)
    rt.set_ambient([0.2, 0.3, 0.4])

    # add mesh geometry to the scene
    rt.set_mesh("m", points, faces, c=colors)

    rt.start()
    print("done")
def main():

    # a mesh from pygmsh example:
    with pygmsh.geo.Geometry() as geom:

        poly = geom.add_polygon(
            [
                [+0.0, +0.5],
                [-0.1, +0.1],
                [-0.5, +0.0],
                [-0.1, -0.1],
                [+0.0, -0.5],
                [+0.1, -0.1],
                [+0.5, +0.0],
                [+0.1, +0.1],
            ],
            mesh_size=0.05,
        )

        geom.twist(
            poly,
            translation_axis=[0, 0, 1],
            rotation_axis=[0, 0, 1],
            point_on_axis=[0, 0, 0],
            angle=np.pi / 3,
        )

        mesh = geom.generate_mesh()

    rt = TkOptiX()  # create and configure, show the window later

    rt.set_param(min_accumulation_step=2, max_accumulation_frames=100)
    rt.setup_camera("cam1",
                    cam_type="DoF",
                    eye=[0.5, -3, 2],
                    target=[0, 0, 0.5],
                    focal_scale=0.9,
                    fov=25)
    rt.setup_light("light1", pos=[15, 0, 10], color=[8, 7, 6], radius=4)
    rt.set_ambient([0.1, 0.15, 0.2])

    # add mesh geometry to the scene
    rt.set_mesh("m", mesh.points, mesh.cells_dict['triangle'])

    rt.start()
    print("done")
Esempio n. 3
0
def main():

    rt = TkOptiX() # create and configure, show the window later

    rt.set_param(max_accumulation_frames=500)  # accumulate up to 100 frames
    rt.set_uint("path_seg_range", 6, 12)       # allow some more ray segments
    rt.set_background(0)                       # black background
    rt.set_ambient([0.1, 0.12, 0.15])          # some ambient light
    #rt.set_param(light_shading="Hard")        # nice, accurate caustics, but slower convergence

    exposure = 1; gamma = 2.2
    rt.set_float("tonemap_exposure", exposure)
    rt.set_float("tonemap_gamma", gamma)
    rt.add_postproc("Gamma")                   # gamma correction

    # setup materials:
    m_diffuse["VarFloat3"] = { "base_color": [ 0.85, 0.87, 0.89 ] }
    rt.update_material("diffuse", m_diffuse)

    m_dispersive_glass["VarFloat3"]["base_color"] = [ 100, 110, 120 ]
    rt.setup_material("glass", m_dispersive_glass)

    # read the scene:
    scene = trimesh.load("data/chemistry.glb")

    # upload meshes to the ray tracer
    for name in scene.geometry:
        mesh = scene.geometry[name]
        if name in ["bottle", "cap", "testtube"]:
            rt.set_mesh(name, mesh.vertices, mesh.faces, mat="glass", make_normals=True)
        else:
            rt.set_mesh(name, mesh.vertices, mesh.faces)

    # camera and light
    rt.setup_light("light1", pos=[6,7.5,-15], color=30, radius=2)
    rt.setup_camera("cam1", eye=[-2,5,-10], target=[-0.75,1.4,5], fov=23, glock=True)

    rt.start()
    print("done")
def main():

    # a mesh from pygmsh example:
    geom = pygmsh.built_in.Geometry()

    # Draw a cross.
    poly = geom.add_polygon(
        [[0.0, 0.5, 0.0], [-0.1, 0.1, 0.0], [-0.5, 0.0, 0.0
                                             ], [-0.1, -0.1, 0.0],
         [0.0, -0.5, 0.0], [0.1, -0.1, 0.0], [0.5, 0.0, 0.0], [0.1, 0.1, 0.0]],
        lcar=0.05)

    axis = [0, 0, 1]

    geom.extrude(poly,
                 translation_axis=axis,
                 rotation_axis=axis,
                 point_on_axis=[0, 0, 0],
                 angle=2.0 / 6.0 * np.pi)

    mesh = pygmsh.generate_mesh(geom)

    rt = TkOptiX()  # create and configure, show the window later

    rt.set_param(min_accumulation_step=2, max_accumulation_frames=100)
    rt.setup_camera("cam1",
                    cam_type="DoF",
                    eye=[0.5, -3, 2],
                    target=[0, 0, 0.5],
                    focal_scale=0.9,
                    fov=25)
    rt.setup_light("light1", pos=[15, 0, 10], color=[8, 7, 6], radius=4)
    rt.set_ambient([0.1, 0.15, 0.2])

    # add mesh geometry to the scene
    rt.set_mesh("m", mesh.points, mesh.cells_dict['triangle'])

    rt.start()
    print("done")