Claude 3.7 Prompts & Python code
Claude 3.7 Prompts & Python code
The Prompt:
Write a Blender Python script to create a 3D animation scene with the following features:
1. The scene should use the Eevee Next render engine and include bloom effects.
2. Clear all existing objects in the scene before starting.
3. Create a simple straight road using a plane scaled along the Y-axis, with road markings down
the center.
4. Add a simple car made from cubes for the body and cabin, and cylinders for the wheels. The
car should have materials: a red, metallic body, dark windows for the cabin, and black rubber
wheels.
5. Add trees along both sides of the road. Each tree consists of a cylinder trunk and a cone top
for leaves. The trunk should be brown, and the leaves should be green.
6. Animate the car to move along the road from one end to the other in 120 frames. Make the
animation cyclic so the car continuously loops along the road.
7. Add a sky environment with a light blue color.
8. Set up lighting for the scene with a main sunlight, a rim light for the car, and a fill light. Adjust
the colors and intensities to create a natural look.
9. Add a camera positioned to capture the car's movement along the road and set it as the
active camera.
10. Smooth the car's body and tree objects for a polished look.
# Create materials
def create_material(name, base_color, metallic=0.0, roughness=0.5, specular=0.5):
material = bpy.data.materials.new(name)
material.use_nodes = True
bsdf = material.node_tree.nodes.get('Principled BSDF')
bsdf.inputs['Base Color'].default_value = base_color
bsdf.inputs['Metallic'].default_value = metallic
bsdf.inputs['Roughness'].default_value = roughness
if 'Specular IOR Level' in bsdf.inputs:
bsdf.inputs['Specular IOR Level'].default_value = specular
elif 'Specular' in bsdf.inputs:
bsdf.inputs['Specular'].default_value = specular
return material
# Create road
bpy.ops.mesh.primitive_plane_add(size=1, enter_editmode=False, align='WORLD', location=(0,
0, 0))
road = bpy.context.active_object
road.name = "Road"
road.scale = (2, 15, 1)
road.data.materials.append(road_material)
wheels = []
for i, pos in enumerate(wheel_positions):
bpy.ops.mesh.primitive_cylinder_add(
radius=0.2,
depth=0.1,
enter_editmode=False,
align='WORLD',
location=pos
)
wheel = bpy.context.active_object
wheel.name = f"Wheel_{i+1}"
wheel.rotation_euler = (0, math.pi/2, 0)
wheel.data.materials.append(wheel_material)
wheels.append(wheel)
# Create trees
def create_tree(location):
# Create trunk
bpy.ops.mesh.primitive_cylinder_add(
radius=0.1,
depth=0.8,
enter_editmode=False,
align='WORLD',
location=(location[0], location[1], 0.4)
)
trunk = bpy.context.active_object
trunk.name = f"TreeTrunk_{location[0]}_{location[1]}"
trunk.data.materials.append(tree_trunk_material)
# Create leaves
bpy.ops.mesh.primitive_cone_add(
radius1=0.3,
radius2=0,
depth=0.8,
enter_editmode=False,
align='WORLD',
location=(location[0], location[1], 1)
)
leaves = bpy.context.active_object
leaves.name = f"TreeLeaves_{location[0]}_{location[1]}"
leaves.data.materials.append(tree_leaves_material)
trees = []
for pos in tree_positions_left + tree_positions_right:
trees.extend(create_tree(pos))
world.use_nodes = True
bg_node = world.node_tree.nodes.get('Background')
bg_node.inputs['Color'].default_value = (0.7, 0.8, 1.0, 1.0) # Light blue sky
bg_node.inputs['Strength'].default_value = 1.0
# Add camera
bpy.ops.object.camera_add(enter_editmode=False, align='VIEW', location=(3, -2, 2))
camera = bpy.context.active_object
camera.name = "MainCamera"
camera.rotation_euler = (math.radians(60), 0, math.radians(100))