Optima Interior -
import bpy import bmesh import math from mathutils import Vector
# Create a central top cap (to make solid, but we want open interior? # Actually to be "solid" we need closed mesh. Let's add a top cap with hole? No, solid piece. # We'll create a central upper surface with a pattern.
# Recalculate normals outward bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
# Generate vertices for top and bottom rings verts_top = [] verts_bottom = [] for i in range(segments): angle = 2 * math.pi * i / segments x = radius * math.cos(angle) y = radius * math.sin(angle) # Top ring with gentle undulation (z varies with angle) z_top = height * (0.5 + 0.3 * math.sin(4 * angle)) # 4 lobes v_top = bm.verts.new((x, y, z_top)) verts_top.append(v_top) # Bottom ring (flat) v_bottom = bm.verts.new((x, y, -height/2)) verts_bottom.append(v_bottom) optima interior
# Create a bmesh to build geometry bm = bmesh.new()
# Add subdivision surface for smooth organic interior look mod = obj.modifiers.new(name="Subdivision", type='SUBSURF') mod.levels = 2 mod.render_levels = 2
# Select bottom ring edges and extrude down bottom_edges = [e for e in bm.edges if any(v in verts_bottom for v in e.verts) and e.is_boundary] # Simpler: extrude the bottom face region downwards. # First, select all bottom faces (the fan we created) bottom_faces = [f for f in bm.faces if all(v.co.z < -height/2 + 0.01 for v in f.verts)] if bottom_faces: geom = bottom_faces[:] ret = bmesh.ops.extrude_discrete_faces(bm, faces=bottom_faces) extrude_verts = [v for v in ret['verts'] if v.co.z < 0] # Move extruded vertices down for v in extrude_verts: v.co.z -= 0.2 # Create side walls for extrusion (need to fill quads). But this gets messy. # Given complexity, let's simplify: just keep the original closed mesh without extrusion, # as it is already a solid closed manifold (if bottom cap and top cap are present). import bpy import bmesh import math from mathutils
# Optional: Add thickness? Actually this is a thin shell, but the prompt "solid piece" suggests a volumetric form. # Let's add thickness by extruding the entire shape downward, but that duplicates geometry. Instead, we create a true solid by adding a bottom layer. # Better: create a thicker base by extruding bottom ring down.
# Add a material with a warm interior tone mat = bpy.data.materials.new(name="InteriorMaterial") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links nodes.clear() output = nodes.new(type='ShaderNodeOutputMaterial') principled = nodes.new(type='ShaderNodeBsdfPrincipled') principled.inputs['Base Color'].default_value = (0.8, 0.6, 0.4, 1.0) # warm wood/leather principled.inputs['Roughness'].default_value = 0.3 principled.inputs['Metallic'].default_value = 0.1 links.new(principled.outputs['BSDF'], output.inputs['Surface']) obj.data.materials.append(mat)
# Add inner ring of vertices at a smaller radius to form a top surface with an inner void. inner_radius = 0.5 inner_verts = [] for i in range(segments): angle = 2 * math.pi * i / segments x = inner_radius * math.cos(angle) y = inner_radius * math.sin(angle) z = height * (0.5 + 0.3 * math.sin(4 * angle)) # same undulation v = bm.verts.new((x, y, z)) inner_verts.append(v) No, solid piece
# Remove any double vertices bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
# Write bmesh to mesh bm.to_mesh(mesh) bm.free()
# Create central disc on bottom (optional, but helps solidity) # Actually we will fill bottom with a fan bm.faces.new(verts_bottom) # Fan fill works if verts are in order