Optima Interior | PLUS ★ |
# Write bmesh to mesh bm.to_mesh(mesh) bm.free()
# Now the mesh is closed (bottom cap, outer walls, top ring, inner cap) # But to make it "solid piece" we need all faces pointing outward. BMesh handles normals but we can recalc.
# Recalculate normals outward bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
# 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 optima interior
# Smooth shading for face in mesh.polygons: face.use_smooth = True
# 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)
# Remove any double vertices bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) # Write bmesh to mesh bm
# Clear existing mesh objects bpy.ops.object.select_all(action='SELECT') bpy.ops.object.delete(use_global=False)
# Create a new mesh datablock and object mesh = bpy.data.meshes.new("OptimaInterior") obj = bpy.data.objects.new("OptimaInterior", mesh) bpy.context.collection.objects.link(obj) bpy.context.view_layer.objects.active = obj obj.select_set(True)
# 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) inner_radius = 0
# 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.
import bpy import bmesh import math from mathutils import Vector