STANAANDREY

emoji all non modular

Sep 4th, 2026 (edited)
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.98 KB | None | 0 0
  1. import bpy
  2. import math
  3.  
  4. # Clean up default scene objects
  5. bpy.ops.object.select_all(action='SELECT')
  6. bpy.ops.object.delete(use_global=False)
  7.  
  8. def create_material(name, color, roughness=0.25, specular=0.5):
  9.     mat = bpy.data.materials.new(name=name)
  10.     mat.use_nodes = True
  11.     nodes = mat.node_tree.nodes
  12.     bsdf = nodes.get("Principled BSDF")
  13.     if bsdf:
  14.         bsdf.inputs['Base Color'].default_value = color
  15.         bsdf.inputs['Roughness'].default_value = roughness
  16.         if 'Specular IOR Level' in bsdf.inputs:
  17.             bsdf.inputs['Specular IOR Level'].default_value = specular
  18.     return mat
  19.  
  20. # --- Materials ---
  21. mat_face = create_material("Mat_YellowFace", (1.0, 0.72, 0.05, 1.0), roughness=0.2)
  22. mat_eyes = create_material("Mat_DarkBrown", (0.1, 0.05, 0.02, 1.0), roughness=0.3)
  23. mat_mouth_dark = create_material("Mat_MouthInterior", (0.15, 0.02, 0.02, 1.0), roughness=0.4)
  24. mat_teeth = create_material("Mat_Teeth", (0.95, 0.95, 0.95, 1.0), roughness=0.2)
  25. mat_tooth_line = create_material("Mat_Divider", (0.7, 0.65, 0.65, 1.0), roughness=0.5)
  26.  
  27. mesh_parts = []
  28.  
  29. # 1. Head
  30. bpy.ops.mesh.primitive_uv_sphere_add(
  31.     segments=64,
  32.     ring_count=32,
  33.     radius=1.0,
  34.     location=(0, 0, 0)
  35. )
  36. head = bpy.context.active_object
  37. head.data.materials.append(mat_face)
  38. mesh_parts.append(head)
  39.  
  40. # 2. Smiling / Squinting Eyes
  41. def add_squint_eye(x_pos):
  42.     bpy.ops.mesh.primitive_torus_add(
  43.         major_radius=0.18,
  44.         minor_radius=0.038,
  45.         major_segments=36,
  46.         minor_segments=16,
  47.         location=(x_pos, 0.88, 0.22),
  48.         rotation=(math.radians(55), 0, 0)
  49.     )
  50.     eye = bpy.context.active_object
  51.     eye.scale = (1.0, 0.6, 1.2)
  52.     eye.data.materials.append(mat_eyes)
  53.     return eye
  54.  
  55. mesh_parts.append(add_squint_eye(-0.36))
  56. mesh_parts.append(add_squint_eye(0.36))
  57.  
  58. # 3. Mouth Background Rim
  59. bpy.ops.mesh.primitive_cylinder_add(
  60.     vertices=64,
  61.     radius=0.58,
  62.     depth=0.25,
  63.     location=(0, 0.86, -0.26),
  64.     rotation=(math.radians(82), 0, 0)
  65. )
  66. mouth_base = bpy.context.active_object
  67. mouth_base.scale = (1.05, 0.45, 0.7)
  68. mouth_base.data.materials.append(mat_mouth_dark)
  69. mesh_parts.append(mouth_base)
  70.  
  71. # 4. Front Teeth Array
  72. bpy.ops.mesh.primitive_cylinder_add(
  73.     vertices=64,
  74.     radius=0.56,
  75.     depth=0.24,
  76.     location=(0, 0.875, -0.26),
  77.     rotation=(math.radians(82), 0, 0)
  78. )
  79. teeth = bpy.context.active_object
  80. teeth.scale = (1.02, 0.43, 0.68)
  81. teeth.data.materials.append(mat_teeth)
  82. mesh_parts.append(teeth)
  83.  
  84. # 5. Horizontal Tooth Divider
  85. bpy.ops.mesh.primitive_cube_add(
  86.     size=1.0,
  87.     location=(0, 0.96, -0.26)
  88. )
  89. horiz_line = bpy.context.active_object
  90. horiz_line.scale = (1.1, 0.08, 0.015)
  91. horiz_line.data.materials.append(mat_tooth_line)
  92. mesh_parts.append(horiz_line)
  93.  
  94. # 6. Vertical Tooth Dividers
  95. for x_coord in [-0.36, -0.18, 0.0, 0.18, 0.36]:
  96.     bpy.ops.mesh.primitive_cube_add(
  97.         size=1.0,
  98.         location=(x_coord, 0.96, -0.26)
  99.     )
  100.     vert_line = bpy.context.active_object
  101.     vert_line.scale = (0.015, 0.08, 0.36)
  102.     vert_line.data.materials.append(mat_tooth_line)
  103.     mesh_parts.append(vert_line)
  104.  
  105. # --- Join all parts into a single mesh object ---
  106. bpy.ops.object.select_all(action='DESELECT')
  107. for part in mesh_parts:
  108.     part.select_set(True)
  109.  
  110. bpy.context.view_layer.objects.active = head
  111. bpy.ops.object.join()
  112.  
  113. emoji = bpy.context.active_object
  114. emoji.name = "Emoji_Grinning_Face"
  115.  
  116. # Apply all transforms and smooth shading
  117. bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
  118. bpy.ops.object.shade_smooth()
  119.  
  120. # Camera and lighting
  121. bpy.ops.object.light_add(type='AREA', radius=2.0, location=(2.0, 3.5, 2.5))
  122. bpy.context.active_object.data.energy = 400.0
  123.  
  124. bpy.ops.object.light_add(type='POINT', radius=1.5, location=(-2.5, 2.5, 1.0))
  125. bpy.context.active_object.data.energy = 150.0
  126.  
  127. bpy.ops.object.camera_add(
  128.     location=(0.0, 3.2, 0.0),
  129.     rotation=(math.radians(90), 0, math.radians(180))
  130. )
  131. bpy.context.scene.camera = bpy.context.active_object
Advertisement
Add Comment
Please, Sign In to add comment