"""Fountain feature assembly (`amenity=fountain`).""" import math import bpy from osmassets.mesh import link_object_to_collection def assemble(name, x, y, collection, materials): def cylinder(part_name, radius, depth, z, material, vertices=48): bpy.ops.mesh.primitive_cylinder_add( vertices=vertices, radius=radius, depth=depth, location=(x, y, z)) obj = bpy.context.object obj.name = name + "_" + part_name link_object_to_collection(obj, collection) obj.data.materials.append(material) for polygon in obj.data.polygons: polygon.use_smooth = True return obj basin = cylinder("Basin", 3.0, 0.32, 0.16, materials["fountain_stone"]) basin["osm_feature"] = "amenity=fountain" cylinder("Water", 2.52, 0.045, 0.335, materials["fountain_water"]) cylinder("Pedestal", 0.30, 0.78, 0.72, materials["fountain_stone"], vertices=32) bpy.ops.mesh.primitive_uv_sphere_add( segments=20, ring_count=10, radius=0.22, location=(x, y, 1.30)) crown = bpy.context.object crown.name = name + "_Water_Crown" link_object_to_collection(crown, collection) crown.data.materials.append(materials["fountain_spray"]) for index in range(8): angle = math.tau * index / 8.0 radius = 0.50 bpy.ops.mesh.primitive_uv_sphere_add( segments=12, ring_count=6, radius=0.075, location=(x + math.cos(angle) * radius, y + math.sin(angle) * radius, 1.02 + 0.10 * math.sin(angle * 2.0))) droplet = bpy.context.object droplet.name = name + "_Droplet_" + str(index + 1) link_object_to_collection(droplet, collection) droplet.data.materials.append(materials["fountain_spray"])