def build_scene(scene: bpy.types.Scene, input_bvh_path: str) -> bpy.types.Object: loader.build_pbr_textured_nodes_from_name("Concrete07", scale=(0.25, 0.25, 0.25)) mat = utils.add_material("BlueMetal", use_nodes=True, make_node_tree_empty=True) output_node = mat.node_tree.nodes.new(type='ShaderNodeOutputMaterial') principled_node = mat.node_tree.nodes.new(type='ShaderNodeBsdfPrincipled') principled_node.inputs['Base Color'].default_value = (0.1, 0.2, 0.7, 1.0) principled_node.inputs['Metallic'].default_value = 0.9 principled_node.inputs['Roughness'].default_value = 0.1 mat.node_tree.links.new(principled_node.outputs['BSDF'], output_node.inputs['Surface']) utils.arrange_nodes(mat.node_tree) armature = create_armature_from_bvh(bvh_path=input_bvh_path) armature_mesh = utils.create_armature_mesh(scene, armature, 'Mesh') armature_mesh.data.materials.append(mat) current_object = utils.create_plane(size=16.0, name="Floor") current_object.data.materials.append(bpy.data.materials["Concrete07"]) current_object = utils.create_plane(size=16.0, name="Wall") current_object.data.materials.append(bpy.data.materials["Concrete07"]) current_object.location = (0.0, 6.0, 0.0) current_object.rotation_euler = (0.5 * math.pi, 0.0, 0.0) bpy.ops.object.empty_add(location=(0.0, 0.0, 0.8)) focus_target = bpy.context.object utils.add_copy_location_constraint(copy_to_object=focus_target, copy_from_object=armature, use_x=True, use_y=True, use_z=False, bone_name='Hips') return focus_target
def set_scene_objects(): loader.build_pbr_textured_nodes_from_name("Leather05") loader.build_pbr_textured_nodes_from_name("Metal07") loader.build_pbr_textured_nodes_from_name("Fabric02") loader.build_pbr_textured_nodes_from_name("Marble01") left_object, center_object, right_object = utils.create_three_smooth_monkeys( ) left_object.data.materials.append(bpy.data.materials["Leather05"]) center_object.data.materials.append(bpy.data.materials["Metal07"]) right_object.data.materials.append(bpy.data.materials["Fabric02"]) current_object = utils.create_plane(size=12.0, name="Floor") current_object.data.materials.append(bpy.data.materials["Marble01"]) current_object = utils.create_plane(size=12.0, location=(0.0, 4.0, 0.0), rotation=(math.pi * 90.0 / 180.0, 0.0, 0.0), name="Wall") current_object.data.materials.append(bpy.data.materials["Marble01"]) bpy.ops.object.empty_add(location=(0.0, -0.70, 1.0)) focus_target = bpy.context.object return focus_target
def set_scene_objects(): num_suzannes = 7 for index in range(num_suzannes): utils.create_smooth_monkey(location=((index - (num_suzannes - 1) / 2) * 2.8, 0.0, 1.0), name="Suzanne" + str(index)) utils.create_plane(size=20.0) return bpy.data.objects["Suzanne" + str(int((num_suzannes - 1) / 2))]
def set_scene_objects() -> bpy.types.Object: # Instantiate a floor plane utils.create_plane(size=200.0, location=(0.0, 0.0, -1.0)) # Instantiate a triangle mesh bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=3) current_object = bpy.context.object # Assign random colors for each triangle mesh = current_object.data mesh.vertex_colors.new(name='Col') random_numbers = get_random_numbers(len(mesh.vertex_colors['Col'].data)) for index, vertex_color in enumerate(mesh.vertex_colors['Col'].data): vertex_color.color = get_color(random_numbers[index // 3]) + tuple( [1.0]) # Setup a material with wireframe visualization and per-face colors mat = bpy.data.materials.new("Material_Visualization") mat.use_nodes = True utils.clean_nodes(mat.node_tree.nodes) current_object.data.materials.append(mat) output_node = mat.node_tree.nodes.new(type='ShaderNodeOutputMaterial') principled_node = mat.node_tree.nodes.new(type='ShaderNodeBsdfPrincipled') rgb_node = mat.node_tree.nodes.new(type='ShaderNodeRGB') mix_node = mat.node_tree.nodes.new(type='ShaderNodeMixShader') wire_node = mat.node_tree.nodes.new(type='ShaderNodeWireframe') wire_mat_node = mat.node_tree.nodes.new(type='ShaderNodeBsdfDiffuse') attrib_node = mat.node_tree.nodes.new(type='ShaderNodeAttribute') attrib_node.attribute_name = 'Col' rgb_node.outputs['Color'].default_value = (0.1, 0.1, 0.1, 1.0) mat.node_tree.links.new(attrib_node.outputs['Color'], principled_node.inputs['Base Color']) mat.node_tree.links.new(principled_node.outputs['BSDF'], mix_node.inputs[1]) mat.node_tree.links.new(rgb_node.outputs['Color'], wire_mat_node.inputs['Color']) mat.node_tree.links.new(wire_mat_node.outputs['BSDF'], mix_node.inputs[2]) mat.node_tree.links.new(wire_node.outputs['Fac'], mix_node.inputs['Fac']) mat.node_tree.links.new(mix_node.outputs['Shader'], output_node.inputs['Surface']) utils.arrange_nodes(mat.node_tree) bpy.ops.object.empty_add(location=(0.0, -0.8, 0.0)) focus_target = bpy.context.object return focus_target
def set_scene_objects(): mat = bpy.data.materials.new("Material") mat.use_nodes = True utils.clean_nodes(mat.node_tree.nodes) utils.build_pbr_nodes(mat.node_tree, base_color=(0.6, 0.6, 0.6, 1.0)) left_object, center_object, right_object = utils.create_three_smooth_monkeys( ) left_object.data.materials.append(mat) center_object.data.materials.append(mat) right_object.data.materials.append(mat) plane_size = 100.0 current_object = utils.create_plane(size=plane_size, name="Floor") floor_mat = bpy.data.materials.new("Material_Plane") floor_mat.use_nodes = True utils.clean_nodes(floor_mat.node_tree.nodes) utils.build_checker_board_nodes(floor_mat.node_tree, plane_size) current_object.data.materials.append(floor_mat) sun_object = utils.create_sun_light() sun_object.data.use_nodes = True sun_object.data.node_tree.nodes["Emission"].inputs[ "Strength"].default_value = 3.0 bpy.ops.object.empty_add(location=(0.0, -0.70, 1.0)) focus_target = bpy.context.object return focus_target
def set_scene_objects(): add_named_material("Metal07") add_named_material("Marble01", displacement_scale=0.02) current_object = utils.create_smooth_monkey(location=(0.0, 0.0, 1.0), rotation=(0.0, 0.0, -math.pi * 60.0 / 180.0)) current_object.data.materials.append(bpy.data.materials["Metal07"]) # Keyframes current_object.location = (0.0, 0.0, 0.2) current_object.scale = (0.0, 0.0, 0.0) current_object.rotation_euler = (0.0, 0.0, -math.pi * (360.0 * 3.0 + 60.0) / 180.0) current_object.keyframe_insert(data_path='location', frame=4) current_object.keyframe_insert(data_path='scale', frame=4) current_object.keyframe_insert(data_path='rotation_euler', frame=4) current_object.location = (0.0, 0.0, 1.0) current_object.scale = (1.0, 1.0, 1.0) current_object.rotation_euler = (0.0, 0.0, -math.pi * 60.0 / 180.0) current_object.keyframe_insert(data_path='location', frame=42) current_object.keyframe_insert(data_path='scale', frame=42) current_object.keyframe_insert(data_path='rotation_euler', frame=42) current_object = utils.create_plane(size=12.0, name="Floor") current_object.data.materials.append(bpy.data.materials["Marble01"]) bpy.ops.object.empty_add(location=(0.0, -0.70, 1.0)) focus_target = bpy.context.object return focus_target
def set_scene_objects(): loader.build_pbr_textured_nodes_from_name("Marble01") current_object = create_skinned_object() current_object.rotation_euler = (0.0, 0.0, math.pi * 60.0 / 180.0) current_object = utils.create_plane(size=12.0, name="Floor") current_object.data.materials.append(bpy.data.materials["Marble01"]) bpy.ops.object.empty_add(location=(0.0, 0.0, 1.0)) focus_target = bpy.context.object return focus_target
def set_scene_objects(): add_named_material("Marble01", displacement_scale=0.02) current_object = create_skinned_object() current_object.rotation_euler = (0.0, 0.0, math.pi * 60.0 / 180.0) current_object = utils.create_plane(size=12.0, name="Floor") current_object.data.materials.append(bpy.data.materials["Marble01"]) bpy.ops.object.empty_add(location=(0.0, 0.0, 1.0)) focus_target = bpy.context.object return focus_target
def set_scene_objects() -> bpy.types.Object: left_object, center_object, right_object = utils.create_three_smooth_monkeys( ) mat = bpy.data.materials.new("Material_Left") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links utils.clean_nodes(nodes) output_node = nodes.new(type='ShaderNodeOutputMaterial') principled_node = nodes.new(type='ShaderNodeBsdfPrincipled') set_principled_node_as_glass(principled_node) links.new(principled_node.outputs['BSDF'], output_node.inputs['Surface']) left_object.data.materials.append(mat) mat = bpy.data.materials.new("Material_Center") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links utils.clean_nodes(nodes) output_node = nodes.new(type='ShaderNodeOutputMaterial') principled_node = nodes.new(type='ShaderNodeBsdfPrincipled') set_principled_node_as_gold(principled_node) links.new(principled_node.outputs['BSDF'], output_node.inputs['Surface']) center_object.data.materials.append(mat) mat = bpy.data.materials.new("Material_Right") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links utils.clean_nodes(nodes) output_node = nodes.new(type='ShaderNodeOutputMaterial') principled_node = nodes.new(type='ShaderNodeBsdfPrincipled') set_principled_node_as_rough_blue(principled_node) links.new(principled_node.outputs['BSDF'], output_node.inputs['Surface']) right_object.data.materials.append(mat) current_object = utils.create_plane(size=20.0, name="Floor") mat = bpy.data.materials.new("Material_Plane") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links utils.clean_nodes(nodes) output_node = nodes.new(type='ShaderNodeOutputMaterial') principled_node = nodes.new(type='ShaderNodeBsdfPrincipled') set_principled_node_as_ceramic(principled_node) links.new(principled_node.outputs['BSDF'], output_node.inputs['Surface']) current_object.data.materials.append(mat) bpy.ops.object.empty_add(location=(0.0, -0.75, 1.0)) focus_target = bpy.context.object return focus_target
def __init__(self, size) -> None: self.size = size # self.base_color=(0.8, 0.8, 0.8, 1.0) self.base_color = (1.0, 1.0, 1.0, 1.0) self.subsurface = 0.1 self.subsurface_color = (0.9, 0.9, 0.9, 1.0) self.subsurface_radius = (1.0, 1.0, 1.0) self.metallic = 0.2 self.specular = 0.5 self.roughness = 0.0 self.plane = utils.create_plane(size=self.size, name="Floor") set_materials([self.plane], self.set_principled_node_floor, "Material_Floor")
def set_floor_and_lights() -> None: size = 200.0 current_object = utils.create_plane(size=size, name="Floor") floor_mat = utils.add_material("Material_Plane", use_nodes=True, make_node_tree_empty=True) utils.build_checker_board_nodes(floor_mat.node_tree, size) current_object.data.materials.append(floor_mat) utils.create_area_light(location=(6.0, 0.0, 4.0), rotation=(0.0, math.pi * 60.0 / 180.0, 0.0), size=5.0, color=(1.00, 0.70, 0.60, 1.00), strength=1500.0, name="Main Light") utils.create_area_light(location=(-6.0, 0.0, 2.0), rotation=(0.0, -math.pi * 80.0 / 180.0, 0.0), size=5.0, color=(0.30, 0.42, 1.00, 1.00), strength=1000.0, name="Sub Light")