def main(): optix = TkOptiX() # create and configure, show the window later optix.set_param(max_accumulation_frames=100) # accumulate up to 100 frames optix.set_background(0) # black background optix.set_ambient(0.25) # some ambient light # original Stanford Utah teapot (try also with default value of make_normals=False): # note: this file has no named objects specified, and you have to use load_merged_mesh_obj # method #optix.load_merged_mesh_obj("https://graphics.stanford.edu/courses/cs148-10-summer/as3/code/as3/teapot.obj", # "teapot", c=0.92, make_normals=True) # another public-domain version with normals included: optix.load_mesh_obj("data/utah-teapot.obj", c=0.92) # camera and light position auto-fit the scene geometry optix.setup_camera("cam1") d = np.linalg.norm(optix.get_camera_target() - optix.get_camera_eye()) optix.setup_light("light1", color=10, radius=0.3 * d) optix.start() print("done")
def main(): # make some data first: rx = (-15, 5) rz = (-10, 10) n = 50 x = np.linspace(rx[0], rx[1], n) z = np.linspace(rz[0], rz[1], n) X, Z = np.meshgrid(x, z) Y = f(X, Z) rt = TkOptiX() # create and configure, show the window later rt.set_param(max_accumulation_frames=50) # accumulate up to 50 frames rt.set_background(0) # black background rt.set_ambient(0.25) # some ambient light # try commenting out optional arguments rt.set_data_2d("surface", Y, range_x=rx, range_z=rz, c=map_to_colors(Y, "OrRd"), floor_c=[0.05, 0.12, 0.38], floor_y=-1.75, make_normals=True) # add wireframe above the surface rt.set_data_2d("wireframe", Y + 3, range_x=rx, range_z=rz, r=0.06 * np.abs(Y), geom="Graph", c=0.92) # set camera and light position to fit the scene rt.setup_camera("cam1") eye = rt.get_camera_eye() eye[1] = 0.5 * eye[2] rt.update_camera("cam1", eye=eye) d = np.linalg.norm(rt.get_camera_target() - eye) rt.setup_light("light1", color=8, radius=0.3 * d) rt.start() print("done")
def main(): rt = TkOptiX() # create and configure, show the window later rt.set_param(max_accumulation_frames=100) # accumulate up to 100 frames rt.set_background(0.99) # white background rt.set_ambient(0.25) # some ambient light # setup materials: m_diffuse["VarFloat3"] = {"base_color": [0.15, 0.17, 0.2]} rt.update_material("diffuse", m_diffuse) m_matt_plastic["VarFloat3"]["base_color"] = [0.5, 0.1, 0.05] rt.setup_material("plastic", m_matt_plastic) rt.load_texture("wing", "data/wing.png") m_transparent_plastic["ColorTextures"] = ["wing"] rt.setup_material("transparent", m_transparent_plastic) rt.load_normal_tilt("transparent", "data/wing.png", prescale=0.002) # prepare dictionary and load meshes; note that both eyes and wings # are assigned with single material by providing only a part of # the mesh name: materials = {"eye": "plastic", "wing": "transparent"} rt.load_multiple_mesh_obj("data/fly.obj", materials, parent="head_Icosphere") # camera and light position auto-fit the scene geometry rt.setup_camera("cam1") d = np.linalg.norm(rt.get_camera_target() - rt.get_camera_eye()) rt.setup_light("light1", color=10, radius=0.3 * d) rt.start() print("done")