#python import k3d doc = Document doc.start_change_set() try: frozen_mesh = doc.new_node("FrozenMesh") frozen_mesh.name = "Bilinear Patch" mesh = k3d.dynamic_cast(frozen_mesh, "imesh_storage").reset_mesh() points = mesh.create_points() point_selection = mesh.create_point_selection() bilinear_patches = mesh.create_bilinear_patches() patch_selection = bilinear_patches.create_patch_selection() patch_materials = bilinear_patches.create_patch_materials() patch_points = bilinear_patches.create_patch_points() Cs = bilinear_patches.writable_varying_data().create_array( "Cs", "k3d::color") positions = [(-5, 0, 5), (5, 0, 5), (0, -5, -5), (0, 5, -5)] for position in positions: points.append(k3d.point3(position[0], position[1], position[2])) point_selection.append(0.0) patch_selection.append(0) patch_materials.append(None) patch_points.append(0) patch_points.append(1)
context.document.start_change_set() try: floor = context.document.new_node("PolyCube") floor.name = "Floor" floor.width = 10 floor.height = 10 floor.depth = 2 floor_instance = context.document.new_node("MeshInstance") floor_instance.name = "Floor Instance" floor_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter") floor_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter") k3d.property.connect(context.document, floor.get_property("output_mesh"), floor_instance.get_property("input_mesh")) k3d.dynamic_cast(floor_instance, "isnappable").add_snap_target("-x", k3d.point3(-5, 0, 0)) k3d.dynamic_cast(floor_instance, "isnappable").add_snap_target("+x", k3d.point3(5, 0, 0)) k3d.dynamic_cast(floor_instance, "isnappable").add_snap_target("-y", k3d.point3(0, -5, 0)) k3d.dynamic_cast(floor_instance, "isnappable").add_snap_target("+y", k3d.point3(0, 5, 0)) k3d.dynamic_cast(floor_instance, "isnappable").add_snap_target("-z", k3d.point3(0, 0, -1)) k3d.dynamic_cast(floor_instance, "isnappable").add_snap_target("+z", k3d.point3(0, 0, 1)) chair = context.document.new_node("PolyCube") chair.name = "Chair" chair_instance = context.document.new_node("MeshInstance") chair_instance.name = "Chair Instance" chair_instance.gl_painter = k3d.node.lookup_one(context.document, "GL Default Painter") chair_instance.ri_painter = k3d.node.lookup_one(context.document, "RenderMan Default Painter") k3d.property.connect(context.document, chair.get_property("output_mesh"), chair_instance.get_property("input_mesh"))
def reset_mesh(FrozenMesh): storage_node = k3d.dynamic_cast(FrozenMesh, "imesh_storage") storage_node.clear_mesh() pipeline_trigger = FrozenMesh.output_mesh # make sure the frozen mesh is really reset
#python import k3d doc = Document doc.start_change_set() try: frozen_mesh = doc.new_node("FrozenMesh") frozen_mesh.name = "Blobby" mesh = k3d.dynamic_cast(frozen_mesh, "imesh_storage").reset_mesh() blobbies = mesh.create_blobbies() first_primitives = blobbies.create_first_primitives() primitive_counts = blobbies.create_primitive_counts() first_operators = blobbies.create_first_operators() operator_counts = blobbies.create_operator_counts() materials = blobbies.create_materials() primitives = blobbies.create_primitives() primitive_first_floats = blobbies.create_primitive_first_floats() primitive_float_counts = blobbies.create_primitive_float_counts() floats = blobbies.create_floats() Cs = blobbies.writable_varying_data().create_array("Cs", "k3d::color") operators = blobbies.create_operators() operator_first_operands = blobbies.create_operator_first_operands() operator_operand_counts = blobbies.create_operator_operand_counts() operands = blobbies.create_operands() ellipsoids = [k3d.point3(-1, 0, 1), k3d.point3(1, 0, 1), k3d.point3(1, 0, -1), k3d.point3(-1, 0, -1)] first_primitives.append(len(primitives))