def volume_shader_test(render_engine_name, shader_name): class result_object: def render(self): self.render_engine.render_camera_frame(self.camera, self.output, False) result = result_object result.document = k3d.open_document( k3d.filesystem.generic_path(source_path() + "/shaders/volume_shader_test.k3d")) result.camera = k3d.node.lookup_one(result.document, "Camera") result.render_engine = k3d.node.lookup_one(result.document, "RenderMan Engine") result.material = k3d.node.lookup_one(result.document, "RenderManMaterial") result.shader = k3d.node.lookup_one(result.document, "RenderManVolumeShader") result.shader.shader_path = k3d.share_path() / k3d.filesystem.generic_path( "shaders/volume/" + shader_name + ".sl") result.output = k3d.filesystem.generic_path(binary_path() + "/shaders/volume/" + shader_name + "." + render_engine_name + ".tiff") result.render_engine.render_engine = k3d.node.lookup_one( result.document, render_engine_name) result.render_engine.render_camera_frame(result.camera, result.output, False) return result
def volume_shader_test(render_engine_name, shader_name): class result_object: def render(self): self.render_engine.render_camera_frame(self.camera, self.output, False) result = result_object result.document = k3d.open_document(k3d.filesystem.generic_path(source_path() + "/shaders/volume_shader_test.k3d")) result.camera = k3d.node.lookup_one(result.document, "Camera") result.render_engine = k3d.node.lookup_one(result.document, "RenderMan Engine") result.material = k3d.node.lookup_one(result.document, "RenderManMaterial") result.shader = k3d.node.lookup_one(result.document, "RenderManVolumeShader") result.shader.shader_path = k3d.share_path() / k3d.filesystem.generic_path("shaders/volume/" + shader_name + ".sl") result.output = k3d.filesystem.generic_path(binary_path() + "/shaders/volume/" + shader_name + "." + render_engine_name + ".tiff") result.render_engine.render_engine = k3d.node.lookup_one(result.document, render_engine_name) result.render_engine.render_camera_frame(result.camera, result.output, False) return result
#python import k3d import glob import os import testing factories = [] for factory in k3d.plugin.factory.lookup(): factories.append(factory.name()) scalable_icons = [] for icon in glob.glob( str(k3d.share_path() / k3d.filesystem.generic_path("ngui/scalable/*.svg"))): scalable_icons.append(os.path.splitext(os.path.basename(icon))[0]) factories.sort() scalable_icons.sort() exceptions = [ 'BevelFaces', 'BitmapSequenceIn', 'BitmapSequenceOut', 'EXRBitmapExporter', 'ImageMagickBitmapExporter', 'Viewport', 'cant_connect_property_cursor', 'center', 'connect_property_cursor', 'connected_plug', 'convert_selection', 'element', 'keep_selection', 'knife_cursor', 'move_cursor', 'move_cursor_screen_xy', 'move_cursor_x', 'move_cursor_xy', 'move_cursor_xz', 'move_cursor_y', 'move_cursor_yz', 'move_cursor_z', 'move_tool', 'node_history_panel', 'node_list_panel', 'node_properties_panel', 'parent_cursor', 'plug_tool', 'render_animation', 'render_frame', 'render_preview', 'rotate_tool', 'scale_cursor', 'scale_cursor_x', 'scale_cursor_xy', 'scale_cursor_xyz', 'scale_cursor_xz', 'scale_cursor_y', 'scale_cursor_yz', 'scale_cursor_z', 'scale_tool',
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/simple_polyhedron.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.simple_polyhedron", 2)
#python import k3d import glob import os import testing factories = [] for factory in k3d.plugin.factory.lookup(): factories.append(factory.name()) scalable_icons = [] for icon in glob.glob(str(k3d.share_path() / k3d.filesystem.generic_path("ngui/scalable/*.svg"))): scalable_icons.append(os.path.splitext(os.path.basename(icon))[0]) factories.sort() scalable_icons.sort() exceptions = ['BevelFaces', 'BitmapSequenceIn', 'BitmapSequenceOut', 'EXRBitmapExporter', 'ImageMagickBitmapExporter', 'Viewport', 'cant_connect_property_cursor', 'center', 'connect_property_cursor', 'connected_plug', 'convert_selection', 'element', 'keep_selection', 'knife_cursor', 'move_cursor', 'move_cursor_screen_xy', 'move_cursor_x', 'move_cursor_xy', 'move_cursor_xz', 'move_cursor_y', 'move_cursor_yz', 'move_cursor_z', 'move_tool', 'node_history_panel', 'node_list_panel', 'node_properties_panel', 'parent_cursor', 'plug_tool', 'render_animation', 'render_frame', 'render_preview', 'rotate_tool', 'scale_cursor', 'scale_cursor_x', 'scale_cursor_xy', 'scale_cursor_xyz', 'scale_cursor_xz', 'scale_cursor_y', 'scale_cursor_yz', 'scale_cursor_z', 'scale_tool', 'select_add_cursor', 'select_cursor', 'select_curve', 'select_face', 'select_group', 'select_node', 'select_patch', 'select_split_edge', 'select_subtract_cursor', 'select_tool', 'select_uniform', 'select_vertex', 'soft_selection', 'undo_tree_panel', 'unparent', 'viewport_panel'] unexpected_icons = [] for icon in scalable_icons: if icon not in factories: if icon in exceptions: continue unexpected_icons.append(icon) if len(unexpected_icons): print "Unexpected icons without factories:", unexpected_icons raise Exception("Found unexpected icons without corresponding factories.")
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path( "scripts/MeshSourceScript/cylinders.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.mesh_comparison_to_reference(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.cylinders", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/disks.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.mesh_comparison_to_reference(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.disks", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/tori.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.tori", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/linear_curves.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.linear.curves", 2)
v = vec3(random() - 0.5, random() - 0.5, random() - 0.5).normalize() p1 = v * body_size p1 += vsnoise(p1) * lumpyness p4 = p1 + v * hair_length p4 += vsnoise(p4) * hair_wavyness p2 = mix(p1, p4, 0.2) p2 += vsnoise(p2) p3 = mix(p1, p4, 0.8) p3 += vsnoise(p3) control_points.append(p1) control_points.append(p2) control_points.append(p3) control_points.append(p4) widths.append(0.08) widths.append(0.01) RiSurface("k3d_hair") RiCurves(RI_CUBIC, control_point_counts, RI_NONPERIODIC, "P", control_points, "width", widths) ri._ribout.flush() context.render_state.use_shader(k3d.share_path() / k3d.filesystem.generic_path("shaders/surface/k3d_hair.sl"))
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/bicubic_patches.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.bicubic.patches", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/nurbs_curves.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.nurbs.curves", 2)
# This scenario can be adapted to many different use-cases. For example, this # script could be modified to load a series of OBJ files into the document, rendering # each in-turn. The script could also modify other properties of the document to # create animated effects. # # To run the script, do the following at the shell: # # $ k3d --ui=none --script-file=/path/to/batch_render.py --batch --exit # # The import k3d import os # Load our "template" document. We assume that the document already contains materials / lighting / render options to suit. document = k3d.open_document(k3d.share_path() / k3d.filesystem.generic_path("scripts/shell/batch_render.k3d")) # Load an external OBJ file into the document. obj_reader = k3d.node.lookup_one(document, "OBJMeshReader") obj_reader.filepath = k3d.share_path() / k3d.filesystem.generic_path("geometry/knot.obj") # Figure-out where to put the rendered results. output = k3d.filesystem.native_path(os.getcwd()) / k3d.filesystem.generic_path("batch_render.tiff") print output # Render the document to the current directory. camera = k3d.node.lookup_one(document, "Camera") render_engine = k3d.node.lookup_one(document, "RenderMan Engine") render_engine.render_camera_frame(camera, output, False)
#python import k3d import glob import os import testing factories = [] for factory in k3d.plugin.factory.lookup(): factories.append(factory.name()) scalable_icons = [] for icon in glob.glob(str(k3d.share_path() / k3d.filesystem.generic_path("ngui/scalable/*.svg"))): scalable_icons.append(os.path.splitext(os.path.basename(icon))[0]) factories.sort() scalable_icons.sort() missing_icons = [] for factory in factories: if factory not in scalable_icons: missing_icons.append(factory) if len(missing_icons): print "Factories without icons:\n" print str("\n").join(missing_icons) raise Exception("Found plugin factories without icons.")
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/paraboloids.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.paraboloids", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/paraboloids.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.mesh_comparison_to_reference(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.paraboloids", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/bezier_triangle_patches.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.bezier_triangle_patches", 2)
#python import k3d import testing script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/nurbs_patches.py") script_file = file(str(script_path), "r") setup = testing.setup_mesh_source_test("MeshSourceScript") setup.source.script = script_file.read() testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh")) testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.nurbs.patches", 2)