import bpy
import math
def create_precise_canary():
# Clear scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Materials
def create_material(name, color, roughness=0.5):
mat = bpy.data.materials.new(name=name)
mat.use_nodes = True
nodes = mat.node_tree.nodes
bsdf = nodes.get("Principled BSDF")
bsdf.inputs['Base Color'].default_value = color
bsdf.inputs['Roughness'].default_value = roughness
return mat
red_mat = create_material("RedFactor", (1.0, 0.25, 0.0, 1.0))
beak_mat = create_material("Beak", (0.9, 0.7, 0.6, 1.0))
leg_mat = create_material("Leg", (0.7, 0.5, 0.4, 1.0))
eye_mat = create_material("Eye", (0.01, 0.01, 0.01, 1.0), roughness=0.1)
# 1. Body
bpy.ops.mesh.primitive_uv_sphere_add(radius=1, location=(0, 0, 0))
body = bpy.context.active_object
body.name = "Body"
body.scale = (1.2, 0.8, 0.9)
bpy.ops.object.transform_apply(scale=True)
body.data.materials.append(red_mat)
# 2. Wings
for side in [-1, 1]:
side_str = "R" if side == -1 else "L"
bpy.ops.mesh.primitive_uv_sphere_add(radius=1)
wing = bpy.context.active_object
wing.name = f"Wing_{side_str}"
wing.scale = (0.817, 0.201, 0.463)
wing.location = (-0.38222, side * 0.71835, 0.12956)
wing.rotation_euler = (math.radians(-12.0), math.radians(-14.32), math.radians(side * -4.2376))
wing.data.materials.append(red_mat)
wing.parent = body
# 3. Head
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.6, location=(0.8, 0, 0.6))
head = bpy.context.active_object
head.name = "Head"
bpy.ops.object.transform_apply(scale=True)
head.data.materials.append(red_mat)
head.parent = body
# 4. Eyes
for side in [-1, 1]:
side_str = "L" if side > 0 else "R"
bpy.ops.mesh.primitive_uv_sphere_add(segments=12, ring_count=6, radius=0.08, location=(1.1, side * 0.45, 0.8))
eye = bpy.context.active_object
eye.name = f"Eye_{side_str}"
eye.data.materials.append(eye_mat)
eye.parent = head
# 5. Beak
bpy.ops.mesh.primitive_cone_add(vertices=16, radius1=0.15, depth=0.4, location=(1.35, 0, 0.6))
beak = bpy.context.active_object
beak.name = "Beak"
beak.rotation_euler = (0, math.radians(90), 0)
beak.data.materials.append(beak_mat)
beak.parent = head
# 6. Tail
bpy.ops.mesh.primitive_cube_add(size=1, location=(-1.4, 0, -0.1))
tail = bpy.context.active_object
tail.name = "Tail"
tail.scale = (1.0, 0.4, 0.05)
bpy.ops.object.transform_apply(scale=True)
tail.data.materials.append(red_mat)
tail.parent = body
# 7. LEGS & FEET
leg_tilt_y = math.radians(-12)
for i in [-1, 1]:
side_str = "L" if i > 0 else "R"
leg_x, leg_y, leg_z = -0.35, i * 0.25, -1.0
bpy.ops.mesh.primitive_cylinder_add(radius=0.03, depth=1.0, location=(leg_x, leg_y, leg_z))
leg = bpy.context.active_object
leg.name = f"Leg_{side_str}"
leg.rotation_euler[1] = leg_tilt_y
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
leg.data.materials.append(leg_mat)
leg.parent = body
# Middle Toe
bpy.ops.mesh.primitive_cube_add(size=1)
m_toe = bpy.context.active_object
m_toe.name = f"M_Toe_{side_str}"
m_toe.scale = (0.4, 0.03, 0.02)
m_toe.location = (0.18946, 0, -0.55067)
m_toe.rotation_euler = (0, math.radians(18.879), 0)
m_toe.data.materials.append(leg_mat)
m_toe.parent = leg
# Outer Toes
for idx, z_rot_deg in enumerate([-25.798, 25.798]):
bpy.ops.mesh.primitive_cube_add(size=1)
f_toe = bpy.context.active_object
f_toe.name = f"F_Toe_{side_str}_{idx+1}"
f_toe.scale = (0.4, 0.03, 0.02)
f_toe.location = (0.17085, (z_rot_deg/25.798) * 0.08452, -0.54843)
f_toe.rotation_euler = (math.radians(3.054 * (z_rot_deg/25.798)),
math.radians(18.216),
math.radians(z_rot_deg))
f_toe.data.materials.append(leg_mat)
f_toe.parent = leg
# Back Toe
bpy.ops.mesh.primitive_cube_add(size=1)
b_toe = bpy.context.active_object
b_toe.name = f"B_Toe_{side_str}"
b_toe.scale = (0.3, 0.03, 0.02)
b_toe.location = (-0.14627, 0, -0.48244)
b_toe.data.materials.append(leg_mat)
b_toe.parent = leg
if __name__ == "__main__":
create_precise_canary()
Comments
Post a Comment