BoooomNing's picture
Add files using upload-large-folder tool
fb7186a verified
Raw History Blame Contribute Delete
73.9 kB
"""Walnut & Sage — a synthetic dining room designed from the text brief.
R1: An enclosed dining room, 5.8 m wide by 5.0 m deep, 2.8 m high.
R2: A 2.15 x 0.90 m bar table, centered in the room, 1.05 m high.
R3: A wall-mounted wooden shelf carrying a potted plant and a ceramic jug.
R4: A refrigerator and wine cabinet share the north wall.
R5: Four movable stools, useful serving storage and coherent material treatment.
All dimensions are assumptions using ordinary domestic furniture dimensions.
No photograph, scan, robot, controller, or robot envelope was supplied.
Metres, right-handed, Z up; origin is the center of the finished floor.
The central table leaves >0.9 m circulation on the east and west sides.
South entry is an open cased passage, not an omitted wall. All four walls and
ceiling are present. Interior review cameras are used to inspect the room.
Geometry plan: continuous slab with oak plank finish, four closed plaster walls,
one real fixed-glazed opening, cased entry, skirting and cornice. The central
walnut table has chamfered top, trestle frames, joining rails, metal foot rail,
bolts and feet. Stools have shaped seats, splayed legs and footrest rungs.
The shelf uses two supported steel brackets. The jug is hollow with a formed
spout and swept handle. The plant includes pot, soil, stems and curved leaves.
The wine cabinet contains actual shelves and bottle cradles, two lower hinged
doors, and open upper bottle storage. The refrigerator has two hinged doors,
insulated shell, shelves, seals, racks, hinge pins and handles.
Physics plan: fixed structure and furniture carcasses; passive world-attached
hinges; free stools, vessels, bottles and tableware. Gravity 9.81 m/s².
Masses are estimated, not calibrated. Composite volume-weighted inertia with
per-component assumed densities is used for mechanisms; only diagonal terms
are exported. Dry contact friction 0.45 to 0.8 is assumed per surface.
Limits are radians, positive axis signs follow the modeled hinge pins.
No powered motion, cooling, liquids, fracture or deformable upholstery.
Folded napkins are closed draped rigid solids, not cloth simulation.
Textured material colors are visible in GLB/USD; other formats use solid colors.
Validation plan: native export and body counts, every hinge push and free-body
support test, current interior overview and close capture, mesh and placement
checks. MuJoCo acceptance and PyBullet comparison run through the normal build.
Isaac Sim and Gazebo runtime outcomes remain untested. Robot task checks are
not applicable. All construction is deterministic with seed 17.
"""
import math
import numpy as np
import trimesh
from PIL import Image
from shapely.geometry import Polygon
from nova_control.modules.robotics.scene import Environment, RigidBody
ROOM_W = 5.8
ROOM_D = 5.0
ROOM_H = 2.8
WALL_T = 0.16
FLOOR_T = 0.16
PLANK_T = 0.018
NORTH = ROOM_D / 2
SOUTH = -ROOM_D / 2
EAST = ROOM_W / 2
WEST = -ROOM_W / 2
ENTRY_W = 1.10
ENTRY_H = 2.25
ENTRY_X = -1.78
TABLE_W = 2.15
TABLE_D = 0.90
TABLE_H = 1.05
TABLE_Y = -0.20
TABLE_T = 0.055
SHELF_X = -0.12
SHELF_Y = 2.295
SHELF_Z = 1.75
SHELF_W = 1.64
SHELF_D = 0.36
SHELF_T = 0.044
FRIDGE_X = -1.95
FRIDGE_Y = 2.10
FRIDGE_W = 0.78
FRIDGE_D = 0.70
FRIDGE_H = 1.98
FRIDGE_FRONT = 1.701
WINE_X = 1.77
WINE_Y = 2.17
WINE_W = 1.30
WINE_D = 0.56
WINE_H = 2.12
WINE_FRONT = 1.850
CONSOLE_X = -0.13
CONSOLE_Y = 2.20
CONSOLE_W = 1.58
CONSOLE_D = 0.52
CONSOLE_H = 0.86
SEED = 17
COLORS = {
'plaster': (0.87, 0.845, 0.78, 1),
'ceiling': (0.95, 0.935, 0.88, 1),
'sage': (0.40, 0.49, 0.41, 1),
'sage_dark': (0.27, 0.34, 0.285, 1),
'walnut': (0.35, 0.205, 0.115, 1),
'walnut_light': (0.43, 0.275, 0.155, 1),
'walnut_dark': (0.235, 0.135, 0.078, 1),
'oak': (0.66, 0.50, 0.31, 1),
'oak_light': (0.71, 0.56, 0.37, 1),
'oak_dark': (0.61, 0.45, 0.275, 1),
'brass': (0.67, 0.49, 0.235, 1),
'steel': (0.48, 0.51, 0.49, 1),
'black': (0.075, 0.085, 0.078, 1),
'ivory': (0.94, 0.90, 0.80, 1),
'terracotta': (0.64, 0.31, 0.20, 1),
'leaf': (0.20, 0.37, 0.18, 1),
'leaf_light': (0.35, 0.48, 0.22, 1),
'soil': (0.16, 0.10, 0.065, 1),
'wine_green': (0.10, 0.20, 0.135, 1),
'wine_red': (0.30, 0.075, 0.065, 1),
'label': (0.84, 0.77, 0.60, 1),
'cork': (0.53, 0.36, 0.19, 1),
'stone': (0.73, 0.73, 0.65, 1),
'linen': (0.72, 0.66, 0.52, 1),
'white': (0.965, 0.965, 0.935, 1),
'glass': (0.66, 0.80, 0.78, 0.24),
}
PALETTE = list(COLORS)
TILE = 32
ATLAS = Image.new('RGB', (TILE * len(PALETTE), TILE))
for color_index, color_name in enumerate(PALETTE):
rgb = tuple(round(c * 255) for c in COLORS[color_name][:3])
ATLAS.paste(rgb, (color_index * TILE, 0, (color_index + 1) * TILE, TILE))
def box(size, center):
mesh = trimesh.creation.box(extents=size)
mesh.metadata['hard_edges'] = True
mesh.apply_translation(center)
return mesh
def cylinder(radius, height, center, axis=(0, 0, 1), sections=32):
mesh = trimesh.creation.cylinder(radius=radius, height=height, sections=sections)
alignment = trimesh.geometry.align_vectors((0, 0, 1), axis)
mesh.apply_transform(alignment)
mesh.apply_translation(center)
return mesh
def rod(a, b, radius, sections=16):
a = np.asarray(a, dtype=float)
b = np.asarray(b, dtype=float)
return cylinder(radius, np.linalg.norm(b - a), (a + b) / 2, b - a, sections)
def rounded_rect(w, d, radius, segments=6):
points = []
corners = [
(w / 2 - radius, d / 2 - radius, 0),
(-w / 2 + radius, d / 2 - radius, math.pi / 2),
(-w / 2 + radius, -d / 2 + radius, math.pi),
(w / 2 - radius, -d / 2 + radius, 3 * math.pi / 2),
]
for cx, cy, start in corners:
for a in np.linspace(start, start + math.pi / 2, segments, endpoint=False):
points.append((cx + radius * math.cos(a), cy + radius * math.sin(a)))
return np.asarray(points)
def loft(rings):
vertices = np.vstack(rings)
n = len(rings[0])
faces = []
for level in range(len(rings) - 1):
for j in range(n):
a = level * n + j
b = level * n + (j + 1) % n
c = (level + 1) * n + (j + 1) % n
d = (level + 1) * n + j
faces.extend(((a, b, c), (a, c, d)))
vertices = np.vstack((vertices, np.mean(rings[0], axis=0), np.mean(rings[-1], axis=0)))
lower = len(vertices) - 2
upper = len(vertices) - 1
for j in range(n):
faces.append((lower, (j + 1) % n, j))
faces.append((upper, (len(rings) - 1) * n + j, (len(rings) - 1) * n + (j + 1) % n))
mesh = trimesh.Trimesh(vertices=vertices, faces=faces, process=False)
mesh.fix_normals()
assert mesh.is_volume, 'Loft must be a closed positive solid'
return mesh
def soft_board(size, center, radius=0.012, bevel=0.003):
w, d, h = size
bevel = min(bevel, h / 3)
stations = [
(-h / 2, w - 2 * bevel, d - 2 * bevel),
(-h / 2 + bevel, w, d),
(h / 2 - bevel, w, d),
(h / 2, w - 2 * bevel, d - 2 * bevel),
]
rings = []
for z, rw, rd in stations:
perimeter = rounded_rect(rw, rd, min(radius, rw / 4, rd / 4))
ring = np.column_stack((perimeter, np.full(len(perimeter), z)))
rings.append(ring + np.asarray(center))
return loft(rings)
def revolved(profile, center=(0, 0, 0), sections=48):
mesh = trimesh.creation.revolve(np.asarray(profile), sections=sections)
mesh.fix_normals()
assert mesh.is_volume, 'Revolved profile must close a positive volume'
mesh.apply_translation(center)
return mesh
def tube_path(points, radius, sections=16):
section = Polygon([
(radius * math.cos(a), radius * math.sin(a))
for a in np.linspace(0, 2 * math.pi, sections, endpoint=False)
])
mesh = trimesh.creation.sweep_polygon(section, np.asarray(points))
mesh.fix_normals()
assert mesh.is_volume, 'Swept tube must close a positive volume'
return mesh
def turn(mesh, angle, origin=(0, 0, 0)):
mesh.apply_transform(trimesh.transformations.rotation_matrix(angle, (0, 0, 1), origin))
return mesh
def vertical_board(size, center, radius=0.008):
w, d, h = size
mesh = soft_board((w, h, d), (0, 0, 0), radius, min(0.002, d / 4))
mesh.apply_transform(trimesh.transformations.rotation_matrix(math.pi / 2, (1, 0, 0)))
mesh.apply_translation(center)
return mesh
class Part:
def __init__(self, name, material='walnut', friction=0.65, roughness=0.55):
self.name = name
self.material = material
self.friction = friction
self.roughness = roughness
self.meshes = []
self.materials = []
self.densities = []
self.collision = None
def add(self, mesh, material=None, density=650):
assert np.isfinite(mesh.vertices).all(), self.name
self.meshes.append(mesh)
self.materials.append(material or self.material)
self.densities.append(density)
return mesh
def block(self, size, center, material=None, density=650):
return self.add(box(size, center), material, density)
def rod(self, a, b, radius, material=None, density=7800):
return self.add(rod(a, b, radius), material, density)
def mesh(self):
pieces = []
uvs = []
for raw, material in zip(self.meshes, self.materials):
mesh = raw.copy()
if raw.metadata.get('hard_edges', False):
mesh.unmerge_vertices()
pieces.append(mesh)
u = (PALETTE.index(material) + 0.5) / len(PALETTE)
uvs.append(np.tile((u, 0.5), (len(mesh.vertices), 1)))
result = trimesh.util.concatenate(pieces)
result.visual = trimesh.visual.TextureVisuals(
uv=np.vstack(uvs),
material=trimesh.visual.material.PBRMaterial(
name=self.material,
baseColorTexture=ATLAS,
baseColorFactor=(255, 255, 255, 255),
roughnessFactor=self.roughness,
metallicFactor=0.0,
),
)
return result
def inertia(self, mass, origin, motion='free', axis=(0, 0, 1), limits=None):
weights = np.asarray([
abs(m.volume) * d for m, d in zip(self.meshes, self.densities)
])
weights *= mass / weights.sum()
centers = np.asarray([m.center_mass for m in self.meshes])
com = np.sum(centers * weights[:, None], axis=0) / mass
inertia = np.zeros((3, 3))
for mesh, weight, center in zip(self.meshes, weights, centers):
offset = center - com
tensor = mesh.moment_inertia * weight / abs(mesh.volume)
inertia += tensor + weight * (np.dot(offset, offset) * np.eye(3) - np.outer(offset, offset))
return RigidBody(
mass=mass,
diagonal_inertia=tuple(np.diag(inertia)),
provenance='Estimated mass; component-density weighted COM and diagonal composite inertia, SI units.',
origin=tuple(origin),
center_of_mass=tuple(com - np.asarray(origin)),
motion=motion,
axis=axis,
limits=limits,
damping=0.35 if motion == 'hinge' else 0.0,
frictionloss=0.08 if motion == 'hinge' else 0.0,
)
def emit(self, world, semantic='furniture', body=None, collidable=True):
return world.add_mesh(
self.name,
self.mesh(),
color=COLORS[self.material],
roughness=self.roughness,
friction=self.friction,
restitution=0.0,
semantic_class=semantic,
body=body,
collidable=collidable,
collision_meshes=self.collision,
)
def screw(part, center, normal=(0, -1, 0), radius=0.0035):
part.add(
cylinder(radius, 0.0018, center, normal, 12),
'steel',
density=7800,
)
def vertical_pull(part, x, y, z, length=0.22, material='brass'):
path = [
(x, y, z - length / 2),
(x, y - 0.016, z - length / 2),
(x, y - 0.029, z - length / 2 + 0.010),
(x, y - 0.031, z - length / 2 + 0.024),
(x, y - 0.031, z + length / 2 - 0.024),
(x, y - 0.029, z + length / 2 - 0.010),
(x, y - 0.016, z + length / 2),
(x, y, z + length / 2),
]
part.add(tube_path(path, 0.008), material, density=7800)
for zz in (z - length / 2, z + length / 2):
part.add(
cylinder(0.012, 0.004, (x, y - 0.001, zz), (0, 1, 0)),
material,
density=7800,
)
def hinge_pair(fixed, moving, x, y, z, side=1, height=0.060):
radius = 0.006
gap = 0.003
segment = (height - 4 * gap) / 5
for i in range(5):
zz = z - height / 2 + segment / 2 + i * (segment + gap)
target = moving if i % 2 == 0 else fixed
profile = [
(0.004, -segment / 2),
(radius, -segment / 2),
(radius, segment / 2),
(0.004, segment / 2),
(0.004, -segment / 2),
]
target.add(revolved(profile, (x, y, zz), 20), 'steel', density=7800)
moving.add(
cylinder(0.0028, height + 0.004, (x, y, z), sections=16),
'steel',
density=7800,
)
moving.block(
(0.030, 0.003, height),
(x + side * 0.020, y + 0.005, z),
'steel',
density=7800,
)
fixed.block(
(0.022, 0.003, height),
(x - side * 0.017, y + 0.011, z),
'steel',
density=7800,
)
for dz in (-0.019, 0.019):
screw(moving, (x + side * 0.023, y + 0.0025, z + dz))
screw(fixed, (x - side * 0.018, y + 0.0085, z + dz))
def profile_rail(length, origin, axis='x', material='ivory'):
section = Polygon([
(0.0, 0.0),
(0.019, 0.0),
(0.019, 0.075),
(0.017, 0.082),
(0.012, 0.086),
(0.008, 0.098),
(0.0, 0.098),
])
mesh = trimesh.creation.extrude_polygon(section, length)
transform = np.eye(4)
if axis == 'x':
transform[:3, :3] = np.array([[0, 0, 1], [1, 0, 0], [0, 1, 0]])
else:
transform[:3, :3] = np.array([[1, 0, 0], [0, 0, 1], [0, 1, 0]])
mesh.apply_transform(transform)
mesh.fix_normals()
mesh.apply_translation(origin)
return mesh
def build_floor(world):
slab = Part('structural_floor_slab', 'stone', 0.8, 0.9)
slab.block(
(ROOM_W + 2 * WALL_T, ROOM_D + 2 * WALL_T, FLOOR_T),
(0, 0, -FLOOR_T / 2 - PLANK_T),
'stone',
)
slab.emit(world, 'floor')
boards = Part('oak_floorboards', 'oak', 0.7, 0.6)
count = 25
pitch = ROOM_D / count
board_gap = 0.0015
for row in range(count):
y = SOUTH + (row + 0.5) * pitch
breaks = [WEST]
shift = (row % 3) * 0.56
breaks.extend(x for x in np.arange(WEST + 1.2 + shift, EAST, 1.80))
breaks.append(EAST)
for i in range(len(breaks) - 1):
length = breaks[i + 1] - breaks[i]
shade = ('oak', 'oak_light', 'oak_dark')[(row * 7 + i * 2) % 3]
boards.add(
soft_board(
(length - board_gap, pitch - board_gap, PLANK_T),
((breaks[i] + breaks[i + 1]) / 2, y, -PLANK_T / 2),
radius=0.001,
bevel=0.0006,
),
shade,
)
boards.emit(world, 'floor')
threshold = Part('entry_threshold', 'oak_dark', 0.72, 0.62)
threshold.add(
soft_board((ENTRY_W, WALL_T + 0.06, 0.018), (ENTRY_X, SOUTH - 0.04, -0.009)),
'oak_dark',
)
threshold.emit(world, 'floor')
def build_walls(world):
back = Part('north_plaster_wall', 'plaster', 0.75, 0.9)
back.block(
(ROOM_W + 2 * WALL_T, WALL_T, ROOM_H),
(0, NORTH + WALL_T / 2, ROOM_H / 2),
)
back.emit(world, 'wall')
right = Part('east_plaster_wall', 'plaster', 0.75, 0.9)
right.block(
(WALL_T, ROOM_D, ROOM_H),
(EAST + WALL_T / 2, 0, ROOM_H / 2),
)
right.emit(world, 'wall')
front = Part('south_entry_wall', 'plaster', 0.75, 0.9)
opening_left = ENTRY_X - ENTRY_W / 2
opening_right = ENTRY_X + ENTRY_W / 2
front.block(
(opening_left - WEST, WALL_T, ROOM_H),
((WEST + opening_left) / 2, SOUTH - WALL_T / 2, ROOM_H / 2),
)
front.block(
(EAST - opening_right, WALL_T, ROOM_H),
((EAST + opening_right) / 2, SOUTH - WALL_T / 2, ROOM_H / 2),
)
front.block(
(ENTRY_W, WALL_T, ROOM_H - ENTRY_H),
(ENTRY_X, SOUTH - WALL_T / 2, (ROOM_H + ENTRY_H) / 2),
)
front.emit(world, 'wall')
left = Part('west_window_wall', 'plaster', 0.75, 0.9)
win_y = -0.02
win_w = 2.04
win_bottom = 0.92
win_top = 2.32
left.block(
(WALL_T, ROOM_D, win_bottom),
(WEST - WALL_T / 2, 0, win_bottom / 2),
)
left.block(
(WALL_T, ROOM_D, ROOM_H - win_top),
(WEST - WALL_T / 2, 0, (ROOM_H + win_top) / 2),
)
for y0, y1 in ((SOUTH, win_y - win_w / 2), (win_y + win_w / 2, NORTH)):
left.block(
(WALL_T, y1 - y0, win_top - win_bottom),
(WEST - WALL_T / 2, (y0 + y1) / 2, (win_bottom + win_top) / 2),
)
left.emit(world, 'wall')
ceiling = Part('complete_plaster_ceiling', 'ceiling', 0.7, 0.9)
ceiling.block(
(ROOM_W + 2 * WALL_T, ROOM_D + 2 * WALL_T, 0.12),
(0, 0, ROOM_H + 0.06),
)
ceiling.emit(world, 'ceiling')
def build_trim(world):
skirt = Part('room_skirting_profiles', 'ivory', 0.68, 0.65)
skirt.add(profile_rail(ROOM_W, (WEST, NORTH - 0.019, 0)))
skirt.add(profile_rail(ROOM_D, (WEST, SOUTH, 0), 'y'))
skirt.add(profile_rail(ROOM_D, (EAST - 0.019, SOUTH, 0), 'y'))
opening_left = ENTRY_X - ENTRY_W / 2 - 0.064
opening_right = ENTRY_X + ENTRY_W / 2 + 0.064
skirt.add(profile_rail(opening_left - WEST, (WEST, SOUTH, 0)))
skirt.add(profile_rail(EAST - opening_right, (opening_right, SOUTH, 0)))
skirt.emit(world, 'trim')
cornice = Part('room_cornice', 'ivory', 0.6, 0.68)
for y in (SOUTH + 0.025, NORTH - 0.025):
cornice.block(
(ROOM_W, 0.05, 0.045),
(0, y, ROOM_H - 0.0225),
)
cornice.block(
(ROOM_W, 0.025, 0.018),
(0, y, ROOM_H - 0.054),
)
for x in (WEST + 0.025, EAST - 0.025):
cornice.block(
(0.05, ROOM_D - 0.10, 0.045),
(x, 0, ROOM_H - 0.0225),
)
cornice.block(
(0.025, ROOM_D - 0.10, 0.018),
(x, 0, ROOM_H - 0.054),
)
cornice.emit(world, 'trim')
entry = Part('entry_doorway_frame', 'ivory', 0.6, 0.55)
for x in (ENTRY_X - ENTRY_W / 2, ENTRY_X + ENTRY_W / 2):
entry.block(
(0.024, WALL_T + 0.006, ENTRY_H),
(x, SOUTH - WALL_T / 2, ENTRY_H / 2),
)
entry.block(
(0.075, 0.022, ENTRY_H + 0.075),
(x, SOUTH + 0.011, (ENTRY_H + 0.075) / 2),
)
entry.block(
(0.075, 0.022, ENTRY_H + 0.075),
(x, SOUTH - WALL_T - 0.011, (ENTRY_H + 0.075) / 2),
)
entry.block(
(ENTRY_W, WALL_T, 0.024),
(ENTRY_X, SOUTH - WALL_T / 2, ENTRY_H - 0.012),
)
entry.block(
(ENTRY_W + 0.15, 0.022, 0.075),
(ENTRY_X, SOUTH + 0.011, ENTRY_H + 0.0375),
)
entry.emit(world, 'door_frame')
def build_window(world):
frame = Part('west_fixed_window_frame', 'sage_dark', 0.6, 0.52)
x = WEST - 0.072
y = -0.02
bottom = 0.92
top = 2.32
width = 2.04
for yy in (y - width / 2 + 0.036, y + width / 2 - 0.036):
frame.block(
(0.095, 0.072, top - bottom),
(x, yy, (top + bottom) / 2),
)
frame.block(
(0.11, 0.018, top - bottom),
(x, yy, (top + bottom) / 2),
'walnut_dark',
)
for zz in (bottom + 0.036, top - 0.036):
frame.block(
(0.095, width - 0.144, 0.072),
(x, y, zz),
)
frame.block(
(0.09, 0.046, top - bottom - 0.144),
(x, y, (top + bottom) / 2),
)
frame.block(
(0.055, width - 0.144, 0.034),
(x, y, 1.76),
)
frame.emit(world, 'window_frame')
sill = Part('window_oak_sill', 'oak', 0.65, 0.48)
sill.add(
soft_board((0.28, width + 0.16, 0.038), (WEST + 0.024, y, bottom - 0.019)),
'oak',
)
sill.block(
(0.018, width + 0.07, 0.064),
(WEST + 0.016, y, bottom - 0.067),
'ivory',
)
sill.emit(world, 'window_sill')
for i, yy in enumerate((y - 0.495, y + 0.495)):
pane = box((0.006, 0.926, 1.25), (x, yy, 1.62))
world.add_mesh(
f'fixed_window_glazing_{i + 1}',
pane,
color=COLORS['glass'],
roughness=0.16,
friction=0.5,
semantic_class='glazing',
)
def build_wall_panels(world):
accent = Part('north_sage_wainscot', 'sage', 0.65, 0.72)
accent.block(
(ROOM_W - 0.04, 0.018, 1.17),
(0, NORTH - 0.009, 0.64),
)
for x in np.linspace(WEST + 0.08, EAST - 0.08, 11):
accent.block(
(0.044, 0.026, 1.12),
(x, NORTH - 0.020, 0.65),
'sage_dark',
)
accent.block(
(ROOM_W - 0.04, 0.045, 0.052),
(0, NORTH - 0.0225, 1.25),
'sage_dark',
)
accent.emit(world, 'wall_finish')
side = Part('east_picture_rail', 'walnut', 0.6, 0.48)
side.block(
(0.018, 3.30, 0.038),
(EAST - 0.009, -0.38, 1.12),
)
side.emit(world, 'trim')
def build_socket(world, name, x, y, z):
socket = Part(name, 'ivory', 0.6, 0.36)
plate = vertical_board((0.086, 0.010, 0.086), (x, y, z), 0.006)
holes = []
for dx in (-0.014, 0.014):
holes.append(box((0.007, 0.025, 0.016), (x + dx, y, z + 0.005)))
holes.append(box((0.007, 0.025, 0.012), (x, y, z - 0.021)))
plate = trimesh.boolean.difference([plate, trimesh.util.concatenate(holes)], engine='manifold')
assert plate.is_volume
socket.add(plate, 'ivory')
socket.block(
(0.074, 0.003, 0.073),
(x, y + 0.007, z),
'black',
)
for dx in (-0.032, 0.032):
screw(socket, (x + dx, y - 0.006, z))
socket.emit(world, 'electrical_fixture')
def build_switch(world):
switch = Part('entry_light_switch', 'ivory', 0.6, 0.38)
x = ENTRY_X + ENTRY_W / 2 + 0.23
y = SOUTH + 0.009
z = 1.20
switch.add(
vertical_board((0.086, 0.014, 0.086), (x, y, z), 0.007),
'ivory',
)
switch.add(
vertical_board((0.032, 0.006, 0.046), (x, y + 0.010, z), 0.003),
'white',
)
for dx in (-0.032, 0.032):
screw(switch, (x + dx, y + 0.009, z), normal=(0, 1, 0))
switch.emit(world, 'electrical_fixture')
def build_bar_table(world):
top = Part('central_bar_table_top', 'walnut_light', 0.58, 0.40)
top.add(
soft_board((TABLE_W, TABLE_D, TABLE_T), (0, TABLE_Y, TABLE_H - TABLE_T / 2), 0.028, 0.006),
'walnut_light',
)
for x in (-0.66, 0.66):
top.block(
(0.042, TABLE_D - 0.12, 0.010),
(x, TABLE_Y, TABLE_H - TABLE_T - 0.004),
'walnut_dark',
)
top.emit(world, 'table')
frame = Part('central_bar_table_trestles', 'walnut', 0.65, 0.48)
for x in (-0.72, 0.72):
frame.add(
soft_board((0.14, 0.66, 0.07), (x, TABLE_Y, 0.060), 0.016, 0.006),
'walnut_dark',
)
for side in (-1, 1):
yy = TABLE_Y + side * 0.205
foot_y = TABLE_Y + side * 0.255
rings = []
for z, cy, width in ((0.095, foot_y, 0.082), (0.18, foot_y, 0.080), (0.94, yy, 0.064)):
perimeter = rounded_rect(width, 0.075, 0.008)
rings.append(np.column_stack((perimeter[:, 0] + x, perimeter[:, 1] + cy, np.full(len(perimeter), z))))
frame.add(loft(rings), 'walnut')
frame.add(
soft_board((0.10, 0.73, 0.080), (x, TABLE_Y, 0.955), 0.010, 0.004),
'walnut',
)
for yy in (TABLE_Y - 0.21, TABLE_Y + 0.21):
frame.add(
cylinder(0.010, 0.002, (x - 0.052, yy, 0.95), (1, 0, 0), 12),
'brass',
density=7800,
)
frame.block(
(1.45, 0.084, 0.09),
(0, TABLE_Y, 0.30),
'walnut_dark',
)
for y in (TABLE_Y - 0.31, TABLE_Y + 0.31):
frame.block(
(1.62, 0.035, 0.060),
(0, y, 0.955),
'walnut',
)
for x in (-0.81, 0.81):
frame.block(
(0.028, 0.11, 0.11),
(x, TABLE_Y, 0.30),
'walnut_light',
)
frame.add(
cylinder(0.013, 0.005, (x, TABLE_Y - 0.058, 0.30), (0, 1, 0), 6),
'brass',
density=7800,
)
frame.emit(world, 'table_frame')
footrail = Part('bar_table_brass_footrails', 'brass', 0.4, 0.30)
for y in (TABLE_Y - 0.34, TABLE_Y + 0.34):
footrail.rod(
(-0.84, y, 0.275),
(0.84, y, 0.275),
0.014,
'brass',
)
for x in (-0.72, 0.72):
footrail.rod(
(x, TABLE_Y + (0.23 if y > TABLE_Y else -0.23), 0.30),
(x, y, 0.275),
0.010,
'brass',
)
footrail.add(
cylinder(0.024, 0.007, (x, y, 0.275), (1, 0, 0)),
'brass',
density=7800,
)
footrail.emit(world, 'footrail')
def build_stool(world, number, x, y, yaw):
stool = Part(f'bar_stool_{number}', 'walnut', 0.7, 0.48)
seat_z = 0.744
rings = []
for z, width, depth in (
(0.710, 0.354, 0.324),
(0.718, 0.384, 0.354),
(0.742, 0.390, 0.360),
(0.755, 0.374, 0.344),
):
perimeter = rounded_rect(width, depth, 0.075, 10)
ring = np.column_stack((perimeter, np.full(len(perimeter), z)))
rings.append(ring)
stool.add(loft(rings), 'walnut_light')
for sx in (-1, 1):
for sy in (-1, 1):
lower = (sx * 0.204, sy * 0.187, 0.014)
upper = (sx * 0.139, sy * 0.125, 0.712)
stool.rod(lower, upper, 0.019, 'walnut', density=650)
stool.add(
cylinder(0.023, 0.012, (lower[0], lower[1], 0.006), sections=20),
'black',
density=1100,
)
stool.add(
cylinder(0.009, 0.004, (sx * 0.145, sy * 0.131, 0.716)),
'walnut_dark',
)
for sy in (-1, 1):
stool.rod(
(-0.177, sy * 0.161, 0.27),
(0.177, sy * 0.161, 0.27),
0.013,
'walnut_dark',
density=650,
)
stool.block(
(0.28, 0.028, 0.045),
(0, sy * 0.128, 0.68),
'walnut',
)
for sx in (-1, 1):
stool.rod(
(sx * 0.176, -0.16, 0.29),
(sx * 0.176, 0.16, 0.29),
0.012,
'walnut_dark',
density=650,
)
stool.rod(
(sx * 0.143, 0.13, 0.70),
(sx * 0.155, 0.168, 0.96),
0.015,
'walnut',
density=650,
)
back_points = []
for t in np.linspace(-1, 1, 17):
back_points.append((0.182 * t, 0.177 - 0.036 * t * t, 0.962))
stool.add(tube_path(back_points, 0.027, 20), 'walnut_light')
for mesh in stool.meshes:
turn(mesh, yaw)
mesh.apply_translation((x, y, 0))
body = stool.inertia(
mass=5.8,
origin=(x, y, seat_z / 2),
)
stool.emit(world, 'movable_prop', body)
def build_shelf(world):
shelf = Part('wall_mounted_walnut_shelf', 'walnut_light', 0.65, 0.44)
shelf.add(
soft_board((SHELF_W, SHELF_D, SHELF_T), (SHELF_X, SHELF_Y, SHELF_Z - SHELF_T / 2), 0.010, 0.003),
'walnut_light',
)
shelf.block(
(SHELF_W - 0.04, 0.017, 0.034),
(SHELF_X, NORTH - 0.027, SHELF_Z - SHELF_T - 0.017),
'walnut_dark',
)
shelf.emit(world, 'shelf')
brackets = Part('wall_shelf_brackets', 'black', 0.55, 0.36)
for x in (SHELF_X - 0.53, SHELF_X + 0.53):
brackets.block(
(0.035, 0.008, 0.235),
(x, NORTH - 0.027, SHELF_Z - 0.165),
'black',
density=7800,
)
brackets.block(
(0.035, 0.286, 0.008),
(x, NORTH - 0.166, SHELF_Z - SHELF_T - 0.004),
'black',
density=7800,
)
brackets.rod(
(x, NORTH - 0.034, SHELF_Z - 0.265),
(x, NORTH - 0.29, SHELF_Z - 0.052),
0.008,
'black',
)
for z in (SHELF_Z - 0.08, SHELF_Z - 0.25):
screw(brackets, (x, NORTH - 0.032, z), radius=0.004)
brackets.emit(world, 'shelf_bracket')
def curved_leaf(start, direction, length, width, bend):
start = np.asarray(start)
direction = np.asarray(direction, dtype=float)
direction /= np.linalg.norm(direction)
across = np.cross(direction, (0, 0, 1))
if np.linalg.norm(across) < 0.1:
across = np.array((1.0, 0, 0))
across /= np.linalg.norm(across)
normal = np.cross(across, direction)
rings = []
for t in np.linspace(0.005, 0.995, 13):
center = start + direction * length * t
center += np.array((0, 0, -bend * t * t))
half_width = width * math.sin(math.pi * t) ** 0.75 / 2
thickness = 0.0013
rings.append(np.array([
center - across * half_width,
center + normal * (0.005 * math.sin(math.pi * t) + thickness),
center + across * half_width,
center - normal * thickness,
]))
return loft(rings)
def build_plant(world):
x = SHELF_X - 0.43
y = SHELF_Y - 0.060
base = SHELF_Z
plant = Part('shelf_potted_plant', 'terracotta', 0.65, 0.72)
saucer = [
(0.0, 0.0),
(0.100, 0.0),
(0.105, 0.005),
(0.105, 0.018),
(0.098, 0.022),
(0.092, 0.017),
(0.092, 0.008),
(0.0, 0.008),
(0.0, 0.0),
]
plant.add(revolved(saucer, (x, y, base)), 'terracotta', density=1900)
pot = [
(0.0, 0.008),
(0.067, 0.008),
(0.071, 0.015),
(0.080, 0.040),
(0.097, 0.171),
(0.102, 0.178),
(0.103, 0.188),
(0.096, 0.194),
(0.087, 0.191),
(0.086, 0.177),
(0.072, 0.048),
(0.061, 0.025),
(0.0, 0.025),
(0.0, 0.008),
]
plant.add(revolved(pot, (x, y, base)), 'terracotta', density=1900)
plant.add(
cylinder(0.084, 0.016, (x, y, base + 0.172)),
'soil',
density=900,
)
stem_specs = [
(0.1, 0.38, 0.14, 0.21),
(1.1, 0.43, 0.10, 0.23),
(2.1, 0.32, 0.15, 0.24),
(3.0, 0.41, 0.09, 0.22),
(3.9, 0.30, 0.17, 0.23),
(4.8, 0.37, 0.13, 0.25),
(5.8, 0.27, 0.18, 0.22),
(0.6, 0.26, 0.08, 0.16),
(2.6, 0.29, 0.07, 0.19),
(4.4, 0.25, 0.08, 0.18),
]
for i, (angle, height, reach, leaf_length) in enumerate(stem_specs):
root = (x, y, base + 0.17)
stem_tip = (
x + reach * 0.35 * math.cos(angle),
y + reach * 0.35 * math.sin(angle),
base + height,
)
midway = (
x + reach * 0.12 * math.cos(angle),
y + reach * 0.12 * math.sin(angle),
base + (height + 0.17) / 2,
)
plant.add(tube_path([root, midway, stem_tip], 0.0028, 10), 'leaf', density=500)
direction = (math.cos(angle), math.sin(angle), 0.30 + 0.10 * (i % 3))
plant.add(
curved_leaf(stem_tip, direction, leaf_length, 0.09, 0.048),
'leaf_light' if i % 3 == 0 else 'leaf',
density=350,
)
body = plant.inertia(mass=1.65, origin=(x, y, base + 0.11))
plant.emit(world, 'movable_prop', body)
def jug_shell(center):
x, y, z = center
angles = np.linspace(0, 2 * math.pi, 64, endpoint=False)
rings = []
stations = [
(0.0, 0.0, 0.0),
(0.055, 0.0, 0.0),
(0.067, 0.010, 0.0),
(0.082, 0.050, 0.0),
(0.083, 0.115, 0.0),
(0.072, 0.175, 0.0),
(0.049, 0.218, 0.010),
(0.048, 0.254, 0.030),
(0.046, 0.262, 0.034),
(0.039, 0.262, 0.032),
(0.040, 0.252, 0.027),
(0.041, 0.217, 0.009),
(0.064, 0.172, 0.0),
(0.075, 0.112, 0.0),
(0.074, 0.052, 0.0),
(0.057, 0.018, 0.0),
(0.0, 0.018, 0.0),
]
# The outside and inside form one closed radial strip; the spout is a
# local extension of the rim, not a separate cylinder masking a closed jug.
vertices = []
for radius, height, spout in stations:
for a in angles:
flare = spout * max(0.0, -math.cos(a)) ** 12
vertices.append((x + (radius + flare) * math.cos(a), y + radius * math.sin(a), z + height))
faces = []
n = len(angles)
for level in range(len(stations) - 1):
for j in range(n):
a = level * n + j
b = level * n + (j + 1) % n
c = (level + 1) * n + (j + 1) % n
d = (level + 1) * n + j
faces.extend(((a, b, c), (a, c, d)))
mesh = trimesh.Trimesh(vertices=vertices, faces=faces, process=True)
mesh.update_faces(mesh.nondegenerate_faces())
mesh.remove_unreferenced_vertices()
mesh.fix_normals()
assert mesh.is_volume, 'Jug bowl must be watertight'
return mesh
def build_jug(world):
x = SHELF_X + 0.36
y = SHELF_Y - 0.015
z = SHELF_Z
jug = Part('shelf_ceramic_jug', 'ivory', 0.55, 0.24)
jug.add(jug_shell((x, y, z)), 'ivory', density=2200)
handle_points = [
(x + 0.049, y, z + 0.224),
(x + 0.089, y, z + 0.236),
(x + 0.126, y, z + 0.222),
(x + 0.146, y, z + 0.192),
(x + 0.150, y, z + 0.157),
(x + 0.141, y, z + 0.119),
(x + 0.119, y, z + 0.091),
(x + 0.080, y, z + 0.073),
]
jug.add(tube_path(handle_points, 0.011, 20), 'ivory', density=2200)
foot = [
(0.044, 0.001),
(0.056, 0.001),
(0.058, 0.005),
(0.056, 0.009),
(0.045, 0.009),
(0.044, 0.001),
]
jug.add(revolved(foot, (x, y, z)), 'terracotta', density=2200)
body = jug.inertia(mass=0.82, origin=(x, y, z + 0.12))
jug.emit(world, 'movable_prop', body)
def bottle_meshes(part, center, yaw=0.0, variant=0):
x, y, z = center
profile = [
(0.0, 0.008),
(0.023, 0.002),
(0.033, 0.0),
(0.037, 0.006),
(0.039, 0.018),
(0.039, 0.192),
(0.037, 0.212),
(0.031, 0.230),
(0.023, 0.246),
(0.014, 0.255),
(0.013, 0.291),
(0.016, 0.294),
(0.016, 0.306),
(0.013, 0.311),
(0.0, 0.311),
(0.0, 0.008),
]
color = 'wine_green' if variant % 2 == 0 else 'wine_red'
bottle = revolved(profile, (0, 0, 0), 40)
# Bottles lie horizontally with necks pointing towards the room.
bottle.apply_transform(trimesh.transformations.rotation_matrix(math.pi / 2, (1, 0, 0)))
turn(bottle, yaw)
bottle.apply_translation(center)
part.add(bottle, color, density=1100)
capsule = cylinder(0.0164, 0.044, (0, -0.282, 0), (0, 1, 0), 32)
turn(capsule, yaw)
capsule.apply_translation(center)
part.add(capsule, 'brass' if variant % 3 == 0 else 'black', density=1000)
label_profile = [
(0.0390, 0.070),
(0.0396, 0.070),
(0.0396, 0.145),
(0.0390, 0.145),
(0.0390, 0.070),
]
label = revolved(label_profile, (0, 0, 0), 40)
label.apply_transform(trimesh.transformations.rotation_matrix(math.pi / 2, (1, 0, 0)))
turn(label, yaw)
label.apply_translation(center)
part.add(label, 'label', density=650)
def build_wine_bottle(world, number, x, y, z, variant):
bottle = Part(f'wine_bottle_{number}', 'wine_green', 0.62, 0.25)
bottle_meshes(bottle, (x, y, z), variant=variant)
body = bottle.inertia(mass=1.16, origin=(x, y - 0.15, z))
bottle.emit(world, 'movable_prop', body)
def build_plate(world, name, x, y, z):
plate = Part(name, 'ivory', 0.6, 0.28)
profile = [
(0.0, 0.006),
(0.062, 0.006),
(0.065, 0.0),
(0.076, 0.0),
(0.080, 0.006),
(0.097, 0.011),
(0.119, 0.022),
(0.124, 0.026),
(0.124, 0.030),
(0.119, 0.031),
(0.098, 0.020),
(0.077, 0.014),
(0.0, 0.014),
(0.0, 0.006),
]
plate.add(revolved(profile, (x, y, z)), 'ivory', density=2200)
body = plate.inertia(mass=0.44, origin=(x, y, z + 0.015))
plate.emit(world, 'movable_prop', body)
def build_cup(world, name, x, y, z):
cup = Part(name, 'sage', 0.62, 0.27)
profile = [
(0.0, 0.0),
(0.028, 0.0),
(0.033, 0.008),
(0.039, 0.082),
(0.038, 0.092),
(0.033, 0.094),
(0.031, 0.086),
(0.026, 0.012),
(0.0, 0.012),
(0.0, 0.0),
]
cup.add(revolved(profile, (x, y, z)), 'sage', density=2200)
handle = []
for a in np.linspace(-math.pi / 2, math.pi / 2, 18):
handle.append((x + 0.033 + 0.034 * math.cos(a), y, z + 0.048 + 0.029 * math.sin(a)))
cup.add(tube_path(handle, 0.006, 16), 'sage', density=2200)
body = cup.inertia(mass=0.27, origin=(x, y, z + 0.04))
cup.emit(world, 'movable_prop', body)
def build_fridge(world):
x = FRIDGE_X
y = FRIDGE_Y
w = FRIDGE_W
shell = Part('refrigerator_insulated_carcass', 'sage', 0.6, 0.35)
bottom = 0.095
top = FRIDGE_H
for side in (-1, 1):
shell.add(
soft_board((0.040, FRIDGE_D, top - bottom), (x + side * (w / 2 - 0.020), y, (top + bottom) / 2), 0.016, 0.004),
'sage',
)
shell.block(
(0.012, FRIDGE_D - 0.05, top - bottom - 0.07),
(x + side * (w / 2 - 0.046), y, (top + bottom) / 2),
'ivory',
)
shell.block(
(w - 0.08, 0.045, top - bottom),
(x, y + FRIDGE_D / 2 - 0.023, (top + bottom) / 2),
'sage',
)
shell.block(
(w - 0.096, 0.012, top - bottom - 0.07),
(x, y + FRIDGE_D / 2 - 0.052, (top + bottom) / 2),
'ivory',
)
shell.block(
(w, FRIDGE_D, 0.045),
(x, y, top - 0.0225),
'sage',
)
shell.block(
(w - 0.08, FRIDGE_D, 0.045),
(x, y, bottom + 0.0225),
'ivory',
)
shell.block(
(w - 0.08, FRIDGE_D - 0.018, 0.036),
(x, y + 0.006, 0.68),
'ivory',
)
for dx in (-0.27, 0.27):
for dy in (-0.25, 0.25):
shell.add(
cylinder(0.025, 0.064, (x + dx, y + dy, 0.032)),
'black',
density=1100,
)
shell.add(
cylinder(0.014, 0.038, (x + dx, y + dy, 0.080)),
'steel',
density=7800,
)
shell.block(
(w - 0.04, 0.028, 0.07),
(x, y - FRIDGE_D / 2 + 0.020, 0.087),
'sage_dark',
)
for dx in np.linspace(-0.30, 0.30, 13):
shell.block(
(0.025, 0.004, 0.033),
(x + dx, y - FRIDGE_D / 2 + 0.003, 0.085),
'black',
)
for shelf_z in (0.98, 1.29, 1.60):
shell.block(
(w - 0.12, 0.43, 0.014),
(x, y + 0.048, shelf_z),
'ivory',
)
shell.block(
(w - 0.12, 0.018, 0.022),
(x, y - 0.172, shelf_z),
'steel',
)
for side in (-1, 1):
shell.block(
(0.020, 0.41, 0.017),
(x + side * (w / 2 - 0.060), y + 0.05, shelf_z - 0.014),
'ivory',
)
shell.block(
(w - 0.14, 0.43, 0.012),
(x, y + 0.045, 0.36),
'ivory',
)
hinge_x = x + w / 2 + 0.016
hinge_y = FRIDGE_FRONT - 0.032
doors = []
for name, lo, hi, mass in (
('refrigerator_freezer_door', 0.120, 0.649, 6.0),
('refrigerator_main_door', 0.712, 1.952, 15.0),
):
door = Part(name, 'sage', 0.55, 0.32)
center_z = (lo + hi) / 2
height = hi - lo
door.add(
vertical_board((w + 0.012, 0.062, height), (x, FRIDGE_FRONT, center_z), 0.023),
'sage',
density=240,
)
for side in (-1, 1):
door.block(
(0.012, 0.005, height - 0.058),
(x + side * (w / 2 - 0.028), FRIDGE_FRONT + 0.034, center_z),
'sage_dark',
density=1000,
)
for zz in (lo + 0.026, hi - 0.026):
door.block(
(w - 0.056, 0.005, 0.012),
(x, FRIDGE_FRONT + 0.034, zz),
'sage_dark',
density=1000,
)
vertical_pull(
door,
x - w / 2 + 0.070,
FRIDGE_FRONT - 0.034,
center_z + (0.12 if height > 1 else 0.01),
length=0.38 if height > 1 else 0.26,
material='brass',
)
rack_levels = (lo + 0.16, lo + 0.57) if height > 1 else (lo + 0.14,)
for zz in rack_levels:
door.block(
(w - 0.17, 0.071, 0.012),
(x - 0.006, FRIDGE_FRONT + 0.074, zz),
'ivory',
density=950,
)
door.block(
(w - 0.17, 0.010, 0.070),
(x - 0.006, FRIDGE_FRONT + 0.111, zz + 0.034),
'ivory',
density=950,
)
for side in (-1, 1):
door.block(
(0.010, 0.075, 0.073),
(x - 0.006 + side * (w - 0.18) / 2, FRIDGE_FRONT + 0.075, zz + 0.03),
'ivory',
density=950,
)
fridge_door_contacts(door, x, center_z, height, rack_levels)
for zz in (lo + 0.068, hi - 0.068):
hinge_pair(shell, door, hinge_x, hinge_y, zz, side=-1)
if height > 1:
door.add(
vertical_board((0.105, 0.003, 0.025), (x, FRIDGE_FRONT - 0.033, hi - 0.105), 0.007),
'brass',
density=7800,
)
for dx in (-0.025, -0.008, 0.008, 0.025):
door.block(
(0.005, 0.002, 0.010),
(x + dx, FRIDGE_FRONT - 0.036, hi - 0.105),
'ivory',
)
body = door.inertia(
mass=mass,
origin=(hinge_x, hinge_y, center_z),
motion='hinge',
axis=(0, 0, 1),
limits=(0, 1.58),
)
doors.append((door, body))
fridge_shell_contacts(shell)
shell.emit(world, 'appliance')
for door, body in doors:
door.emit(world, 'door', body)
def cabinet_leaf(name, cx, front, lo, hi, width, side, fixed):
leaf = Part(name, 'walnut', 0.6, 0.48)
center_z = (lo + hi) / 2
height = hi - lo
stile = 0.055
for dx in (-width / 2 + stile / 2, width / 2 - stile / 2):
leaf.add(
vertical_board((stile, 0.024, height), (cx + dx, front, center_z), 0.003),
'walnut',
)
for zz in (lo + stile / 2, hi - stile / 2):
leaf.add(
vertical_board((width - 2 * stile, 0.024, stile), (cx, front, zz), 0.003),
'walnut',
)
leaf.add(
vertical_board((width - 2 * stile + 0.014, 0.012, height - 2 * stile + 0.014), (cx, front + 0.004, center_z), 0.002),
'walnut_dark',
)
for dx in (-width / 2 + 0.055, width / 2 - 0.055):
leaf.block(
(0.005, 0.012, height - 0.105),
(cx + dx, front - 0.001, center_z),
'walnut_light',
)
vertical_pull(
leaf,
cx - side * (width / 2 - 0.084),
front - 0.016,
center_z + 0.028,
length=0.145,
)
hinge_x = cx + side * (width / 2 + 0.010)
hinge_y = front - 0.016
cabinet_door_contacts(leaf, cx, front, center_z, height, width, side)
for zz in (lo + 0.10, hi - 0.10):
hinge_pair(fixed, leaf, hinge_x, hinge_y, zz, side=-side)
fixed.block(
(0.021, 0.073, 0.008),
(hinge_x + side * 0.017, hinge_y + 0.043, zz),
'steel',
density=7800,
)
body = leaf.inertia(
mass=3.2,
origin=(hinge_x, hinge_y, center_z),
motion='hinge',
axis=(0, 0, side),
limits=(0, 1.58),
)
return leaf, body
def build_wine_cabinet(world):
x = WINE_X
y = WINE_Y
width = WINE_W
depth = WINE_D
carcass = Part('wine_cabinet_carcass', 'walnut', 0.65, 0.47)
for sx in (-1, 1):
for sy in (-1, 1):
carcass.add(
soft_board((0.075, 0.075, 0.15), (x + sx * 0.53, y + sy * 0.20, 0.075), 0.007, 0.003),
'walnut_dark',
)
carcass.block(
(width - 0.04, depth - 0.025, 0.075),
(x, y, 0.165),
'walnut_dark',
)
for side in (-1, 1):
carcass.block(
(0.026, depth, WINE_H - 0.15),
(x + side * (width / 2 - 0.013), y, (WINE_H + 0.15) / 2),
'walnut',
)
carcass.block(
(0.055, 0.027, WINE_H - 0.15),
(x + side * (width / 2 - 0.0275), y - depth / 2 - 0.003, (WINE_H + 0.15) / 2),
'walnut_light',
)
carcass.block(
(width - 0.052, 0.018, WINE_H - 0.16),
(x, y + depth / 2 - 0.009, (WINE_H + 0.16) / 2),
'walnut_dark',
)
carcass.add(
soft_board((width + 0.064, depth + 0.044, 0.043), (x, y, WINE_H - 0.0215), 0.009, 0.004),
'walnut_light',
)
carcass.block(
(width + 0.018, depth + 0.012, 0.032),
(x, y, WINE_H - 0.059),
'walnut',
)
carcass.block(
(width - 0.052, depth - 0.018, 0.027),
(x, y - 0.007, 0.83),
'walnut_light',
)
carcass.block(
(width - 0.052, depth - 0.05, 0.018),
(x, y + 0.007, 0.48),
'walnut',
)
carcass.block(
(0.025, depth - 0.045, 0.64),
(x, y + 0.010, 0.505),
'walnut',
)
for z in (1.20, 1.54, 1.88):
carcass.block(
(width - 0.055, depth - 0.040, 0.022),
(x, y + 0.002, z),
'walnut_light',
)
carcass.block(
(width - 0.055, 0.028, 0.037),
(x, y - depth / 2 + 0.020, z - 0.007),
'walnut',
)
for dx in (-0.51, 0.51):
for dy in (-0.15, 0.16):
carcass.add(
cylinder(0.005, 0.024, (x + dx, y + dy, z - 0.015), (1, 0, 0), 12),
'brass',
density=7800,
)
rack_parts = []
bottle_number = 0
for level, shelf_z in enumerate((1.20, 1.54, 1.88)):
rack = Part(f'wine_rack_cradles_{level + 1}', 'walnut_dark', 0.65, 0.5)
rack.collision = []
rack_parts.append(rack)
for column, dx in enumerate((-0.43, -0.215, 0.0, 0.215, 0.43)):
for sy in (0.040, 0.120):
for side in (-1, 1):
cradle = wine_cradle_half(x + dx, y + sy, shelf_z, side)
rack.add(cradle, 'walnut_dark')
rack.collision.append(cradle)
bottle_number += 1
build_wine_bottle(
world,
bottle_number,
x + dx,
y + 0.164,
shelf_z + 0.026 + math.sqrt(2) * 0.0396,
variant=column + level,
)
leaves = []
for side, name in ((-1, 'left'), (1, 'right')):
cx = x + side * 0.309
leaf, body = cabinet_leaf(
f'wine_cabinet_{name}_door',
cx,
WINE_FRONT,
0.214,
0.798,
0.604,
side,
carcass,
)
leaves.append((leaf, body))
for side in (-1, 1):
carcass.block(
(0.030, 0.09, 0.050),
(x + side * 0.48, NORTH - 0.06, 1.97),
'steel',
density=7800,
)
screw(carcass, (x + side * 0.48, NORTH - 0.108, 1.97))
wine_carcass_contacts(carcass)
carcass.emit(world, 'cabinet')
for rack in rack_parts:
rack.emit(world, 'bottle_rack')
for leaf, body in leaves:
leaf.emit(world, 'door', body)
def build_console(world):
x = CONSOLE_X
y = CONSOLE_Y
w = CONSOLE_W
d = CONSOLE_D
console = Part('serving_console_frame', 'walnut', 0.65, 0.48)
for sx in (-1, 1):
for sy in (-1, 1):
console.add(
soft_board((0.055, 0.055, CONSOLE_H - 0.04), (x + sx * (w / 2 - 0.07), y + sy * (d / 2 - 0.065), (CONSOLE_H - 0.04) / 2), 0.007, 0.003),
'walnut',
)
console.add(
cylinder(0.029, 0.026, (x + sx * (w / 2 - 0.07), y + sy * (d / 2 - 0.065), 0.014)),
'brass',
density=7800,
)
console.add(
soft_board((w, d, 0.036), (x, y, CONSOLE_H - 0.018), 0.014, 0.003),
'walnut_light',
)
console.block(
(w - 0.11, d - 0.10, 0.022),
(x, y, 0.265),
'walnut_light',
)
console.block(
(w - 0.12, 0.025, 0.087),
(x, y + d / 2 - 0.037, 0.787),
'walnut',
)
for sx in (-1, 1):
console.block(
(0.020, d - 0.10, 0.090),
(x + sx * (w / 2 - 0.065), y, 0.775),
'walnut',
)
console.block(
(0.016, d - 0.11, 0.024),
(x + sx * 0.692, y - 0.007, 0.755),
'steel',
density=7800,
)
console.block(
(0.032, 0.012, 0.067),
(x + sx * 0.57, y + d / 2 - 0.006, 0.773),
'steel',
density=7800,
)
screw(console, (x + sx * 0.57, y + d / 2 - 0.014, 0.782))
console.emit(world, 'console')
drawer = Part('serving_console_drawer', 'walnut', 0.60, 0.45)
front_y = y - d / 2 + 0.007
drawer.add(
vertical_board((w - 0.20, 0.022, 0.096), (x, front_y, 0.770), 0.004),
'walnut_light',
)
for side in (-1, 1):
drawer.block(
(0.012, 0.345, 0.069),
(x + side * 0.646, y - 0.035, 0.768),
'oak',
)
drawer.block(
(0.009, 0.326, 0.013),
(x + side * 0.658, y - 0.034, 0.757),
'steel',
density=7800,
)
drawer.block(
(1.280, 0.012, 0.069),
(x, y + 0.143, 0.768),
'oak',
)
drawer.block(
(1.295, 0.350, 0.006),
(x, y - 0.035, 0.734),
'oak_light',
)
pull_path = [
(x - 0.092, front_y - 0.016, 0.77),
(x - 0.092, front_y - 0.033, 0.77),
(x - 0.079, front_y - 0.043, 0.77),
(x + 0.079, front_y - 0.043, 0.77),
(x + 0.092, front_y - 0.033, 0.77),
(x + 0.092, front_y - 0.016, 0.77),
]
drawer.add(tube_path(pull_path, 0.0065, 16), 'brass', density=7800)
body = drawer.inertia(
mass=3.5,
origin=(x, y, 0.77),
motion='slide',
axis=(0, -1, 0),
limits=(0, 0.285),
)
body.damping = 2.0
body.frictionloss = 0.8
drawer.emit(world, 'drawer', body)
def build_pendant(world):
mount = Part('bar_pendant_ceiling_mount', 'black', 0.5, 0.34)
mount.add(
soft_board((1.12, 0.10, 0.027), (0, TABLE_Y, ROOM_H - 0.0135), 0.018, 0.003),
'black',
)
for x in (-0.43, 0.43):
mount.add(
cylinder(0.023, 0.014, (x, TABLE_Y, ROOM_H - 0.030)),
'brass',
density=7800,
)
mount.rod(
(x, TABLE_Y, ROOM_H - 0.031),
(x, TABLE_Y, 2.31),
0.004,
'black',
density=1100,
)
mount.emit(world, 'light_mount')
for i, x in enumerate((-0.43, 0.43)):
shade = Part(f'pendant_shade_{i + 1}', 'sage_dark', 0.5, 0.32)
profile = [
(0.031, 0.0),
(0.036, 0.0),
(0.061, -0.026),
(0.104, -0.074),
(0.150, -0.126),
(0.173, -0.149),
(0.175, -0.158),
(0.169, -0.162),
(0.164, -0.154),
(0.142, -0.131),
(0.096, -0.079),
(0.054, -0.031),
(0.031, -0.006),
(0.031, 0.0),
]
shade.add(revolved(profile, (x, TABLE_Y, 2.33), 64), 'sage_dark', density=2700)
shade.add(
cylinder(0.032, 0.045, (x, TABLE_Y, 2.316)),
'brass',
density=7800,
)
diffuser = [
(0.0, 0.0),
(0.056, 0.0),
(0.067, -0.014),
(0.061, -0.041),
(0.032, -0.056),
(0.0, -0.060),
(0.0, 0.0),
]
shade.add(revolved(diffuser, (x, TABLE_Y, 2.26), 48), 'ivory', density=1000)
shade.emit(world, 'light_fixture')
def build_wall_art(world):
art = Part('east_wall_botanical_print_frame', 'walnut_dark', 0.6, 0.55)
x = EAST - 0.032
y = -0.27
z = 1.77
w = 0.73
h = 0.91
art.block(
(0.014, w, h),
(x + 0.012, y, z),
'ivory',
)
for sy in (-1, 1):
art.block(
(0.031, 0.026, h + 0.045),
(x, y + sy * (w / 2 + 0.010), z),
'walnut_dark',
)
for sz in (-1, 1):
art.block(
(0.031, w + 0.045, 0.026),
(x, y, z + sz * (h / 2 + 0.010)),
'walnut_dark',
)
art.rod(
(x - 0.011, y + 0.03, z - 0.29),
(x - 0.011, y - 0.015, z + 0.28),
0.0025,
'sage_dark',
density=600,
)
for i in range(6):
side = -1 if i % 2 == 0 else 1
zz = z - 0.22 + i * 0.082
leaf = trimesh.creation.icosphere(subdivisions=2, radius=1.0)
leaf.apply_scale((0.0015, 0.082, 0.031))
leaf.apply_transform(trimesh.transformations.rotation_matrix(side * 0.5, (1, 0, 0)))
leaf.apply_translation((x - 0.014, y + side * 0.068, zz))
art.add(leaf, 'sage' if i % 3 else 'terracotta', density=600)
art.emit(world, 'wall_art')
def build_serving_tray(world):
x = CONSOLE_X + 0.28
y = CONSOLE_Y
z = CONSOLE_H
tray = Part('console_serving_tray', 'walnut_dark', 0.65, 0.5)
tray.add(
soft_board((0.39, 0.27, 0.013), (x, y, z + 0.0065), 0.027, 0.002),
'walnut_dark',
)
for sy in (-1, 1):
tray.add(
soft_board((0.36, 0.013, 0.027), (x, y + sy * 0.127, z + 0.026), 0.005, 0.002),
'walnut_light',
)
for sx in (-1, 1):
tray.add(
soft_board((0.013, 0.235, 0.027), (x + sx * 0.188, y, z + 0.026), 0.004, 0.002),
'walnut_light',
)
body = tray.inertia(mass=0.55, origin=(x, y, z + 0.02))
tray.emit(world, 'movable_prop', body)
def verify_authored_layout(world):
names = [obj.name for obj in world.objects]
assert len(names) == len(set(names)), 'Scene object identities must be unique'
required = [
'central_bar_table_top',
'wall_mounted_walnut_shelf',
'shelf_potted_plant',
'shelf_ceramic_jug',
'refrigerator_main_door',
'refrigerator_freezer_door',
'wine_cabinet_carcass',
'wine_cabinet_left_door',
'wine_cabinet_right_door',
]
assert all(name in names for name in required)
by_name = {obj.name: obj for obj in world.objects}
table = by_name['central_bar_table_top'].mesh.bounds
assert abs(table[1, 2] - TABLE_H) < 0.0001
assert np.allclose(table[:, 0], (-TABLE_W / 2, TABLE_W / 2), atol=0.004)
shelf = by_name['wall_mounted_walnut_shelf'].mesh.bounds
assert abs(shelf[1, 2] - SHELF_Z) < 0.0001
for name in ('shelf_potted_plant', 'shelf_ceramic_jug'):
bottom = by_name[name].mesh.bounds[0, 2]
assert abs(bottom - SHELF_Z) < 0.0005, name
for obj in world.objects:
assert np.isfinite(obj.mesh.vertices).all(), obj.name
if obj.body is not None:
assert obj.body.mass > 0, obj.name
assert min(obj.body.diagonal_inertia) > 0, obj.name
for name in ('refrigerator_main_door', 'refrigerator_freezer_door'):
obj = by_name[name]
assert obj.body.axis == (0, 0, 1)
assert obj.body.center_of_mass[0] < 0
assert obj.collision_meshes is not None
assert 1 <= len(obj.collision_meshes) <= 32
assert obj.body.origin[0] > FRIDGE_X + FRIDGE_W / 2
for name, sign in (('wine_cabinet_left_door', -1), ('wine_cabinet_right_door', 1)):
obj = by_name[name]
assert obj.body.axis[2] == sign
assert obj.body.center_of_mass[0] * sign < 0
assert obj.collision_meshes is not None
assert obj.mesh.bounds[0, 2] > 0.18
drawer = by_name['serving_console_drawer']
assert drawer.body.axis == (0, -1, 0)
assert drawer.body.limits[1] < CONSOLE_D
assert by_name['shelf_potted_plant'].mesh.bounds[1, 1] < NORTH - 0.02
assert by_name['bar_table_floor_contact_pads'].mesh.bounds[0, 2] == 0
assert EAST - TABLE_W / 2 > 0.9
assert TABLE_Y + TABLE_D / 2 < FRIDGE_FRONT - 0.9
assert len([o for o in world.objects if o.body and o.body.motion == 'hinge']) == 4
assert len([o for o in world.objects if o.body and o.body.motion == 'slide']) == 1
def build_wine_glass(world, name, x, y, z):
glass = Part(name, 'ivory', 0.5, 0.18)
foot_profile = [
(0.0, 0.0),
(0.035, 0.0),
(0.041, 0.002),
(0.042, 0.004),
(0.039, 0.006),
(0.029, 0.008),
(0.008, 0.012),
(0.004, 0.021),
(0.004, 0.095),
(0.009, 0.103),
(0.0, 0.104),
(0.0, 0.0),
]
glass.add(revolved(foot_profile, (x, y, z), 40), 'ivory', density=2500)
bowl_profile = [
(0.0, 0.098),
(0.012, 0.102),
(0.025, 0.112),
(0.038, 0.129),
(0.047, 0.151),
(0.049, 0.173),
(0.045, 0.194),
(0.037, 0.216),
(0.036, 0.219),
(0.0335, 0.219),
(0.0345, 0.215),
(0.0425, 0.193),
(0.0465, 0.173),
(0.0445, 0.152),
(0.0355, 0.131),
(0.023, 0.115),
(0.010, 0.108),
(0.0, 0.108),
(0.0, 0.098),
]
glass.add(revolved(bowl_profile, (x, y, z), 48), 'ivory', density=2500)
body = glass.inertia(mass=0.18, origin=(x, y, z + 0.10))
glass.emit(world, 'movable_prop', body)
def build_folded_napkin(world, name, x, y, z, yaw):
napkin = Part(name, 'linen', 0.75, 0.94)
nx = 17
ny = 21
width = 0.12
depth = 0.21
thickness = 0.004
vertices = []
for layer in (0, 1):
for j in range(ny):
yy = -depth / 2 + j * depth / (ny - 1)
for i in range(nx):
xx = -width / 2 + i * width / (nx - 1)
ripple = 0.0012 * math.sin(yy * 42) ** 2
crease = 0.002 * math.exp(-((xx - 0.02) / 0.012) ** 2)
rise = layer * (thickness + ripple + crease)
vertices.append((xx, yy, rise))
faces = []
layer_size = nx * ny
for j in range(ny - 1):
for i in range(nx - 1):
a = j * nx + i
b = a + 1
c = b + nx
d = a + nx
faces.extend(((a, c, b), (a, d, c)))
faces.extend(((a + layer_size, b + layer_size, c + layer_size), (a + layer_size, c + layer_size, d + layer_size)))
boundary = []
boundary.extend(range(nx))
boundary.extend(j * nx + nx - 1 for j in range(1, ny))
boundary.extend((ny - 1) * nx + i for i in range(nx - 2, -1, -1))
boundary.extend(j * nx for j in range(ny - 2, 0, -1))
for index, a in enumerate(boundary):
b = boundary[(index + 1) % len(boundary)]
faces.extend(((a, b, b + layer_size), (a, b + layer_size, a + layer_size)))
mesh = trimesh.Trimesh(vertices=vertices, faces=faces, process=False)
mesh.fix_normals()
assert mesh.is_volume
turn(mesh, yaw)
mesh.apply_translation((x, y, z))
napkin.add(mesh, 'linen', density=350)
body = napkin.inertia(mass=0.045, origin=(x, y, z + 0.002))
napkin.emit(world, 'movable_prop', body)
def build_table_joinery(world):
joinery = Part('bar_table_joinery_plates', 'black', 0.55, 0.44)
for x in (-0.72, 0.72):
for side in (-1, 1):
y = TABLE_Y + side * 0.237
joinery.block(
(0.045, 0.004, 0.105),
(x, y, 0.893),
'black',
density=7800,
)
for z in (0.86, 0.925):
screw(joinery, (x, y - side * 0.003, z), normal=(0, side, 0), radius=0.004)
joinery.block(
(0.124, 0.004, 0.052),
(x, TABLE_Y - 0.044, 0.30),
'black',
density=7800,
)
for dx in (-0.038, 0.038):
screw(joinery, (x + dx, TABLE_Y - 0.047, 0.30), radius=0.0045)
joinery.emit(world, 'furniture_hardware')
def build_fridge_hinge_brackets(world):
brackets = Part('refrigerator_hinge_mounting_brackets', 'steel', 0.50, 0.3)
x = FRIDGE_X + FRIDGE_W / 2 + 0.021
for z in (0.188, 0.581, 0.780, 1.884):
brackets.block(
(0.020, 0.081, 0.012),
(x, FRIDGE_FRONT + 0.014, z),
'steel',
density=7800,
)
brackets.block(
(0.004, 0.060, 0.068),
(FRIDGE_X + FRIDGE_W / 2 + 0.002, FRIDGE_FRONT + 0.064, z),
'steel',
density=7800,
)
for dz in (-0.022, 0.022):
screw(brackets, (FRIDGE_X + FRIDGE_W / 2 + 0.005, FRIDGE_FRONT + 0.068, z + dz), normal=(1, 0, 0))
brackets.emit(world, 'hinge_bracket')
def build_console_plate_storage(world):
x = CONSOLE_X - 0.38
y = CONSOLE_Y - 0.015
shelf_top = 0.276
for index in range(2):
build_plate(
world,
f'console_stored_plate_{index + 1}',
x - 0.15 + index * 0.27,
y,
shelf_top,
)
for index in range(3):
build_wine_glass(
world,
f'console_stemmed_cup_{index + 1}',
CONSOLE_X + 0.11 + index * 0.18,
CONSOLE_Y,
shelf_top,
)
def build_cabinet_mouldings(world):
trim = Part('wine_cabinet_crown_and_base_mouldings', 'walnut_light', 0.65, 0.46)
x = WINE_X
y = WINE_Y
for z, width, depth, thickness in (
(0.193, WINE_W + 0.022, WINE_D + 0.012, 0.016),
(2.071, WINE_W + 0.035, WINE_D + 0.019, 0.015),
):
trim.add(
soft_board((width, 0.030, thickness), (x, y - depth / 2, z), 0.005, 0.002),
'walnut_light',
)
for side in (-1, 1):
trim.add(
soft_board((0.030, depth, thickness), (x + side * width / 2, y, z), 0.005, 0.002),
'walnut_light',
)
for side in (-1, 1):
trim.block(
(0.008, 0.018, 1.22),
(x + side * (WINE_W / 2 - 0.036), WINE_FRONT + 0.005, 1.458),
'walnut_dark',
)
trim.emit(world, 'cabinet_trim')
def build_shelf_endgrain(world):
detail = Part('shelf_endgrain_joinery', 'walnut_dark', 0.6, 0.48)
for side in (-1, 1):
xx = SHELF_X + side * (SHELF_W / 2 - 0.001)
for yy in (SHELF_Y - 0.09, SHELF_Y + 0.09):
detail.add(
cylinder(0.004, 0.002, (xx, yy, SHELF_Z - SHELF_T / 2), (1, 0, 0), 12),
'walnut_dark',
)
detail.emit(world, 'shelf_joinery')
def build_serving_details(world):
build_folded_napkin(
world,
'bar_folded_napkin_left',
-0.30,
TABLE_Y - 0.08,
TABLE_H,
-0.04,
)
build_folded_napkin(
world,
'bar_folded_napkin_right',
0.30,
TABLE_Y + 0.08,
TABLE_H,
0.04,
)
build_table_joinery(world)
build_fridge_hinge_brackets(world)
build_console_plate_storage(world)
build_cabinet_mouldings(world)
build_shelf_endgrain(world)
def build_furniture_supports(world):
feet = Part('bar_table_floor_contact_pads', 'black', 0.8, 0.85)
for x in (-0.72, 0.72):
for sy in (-1, 1):
y = TABLE_Y + sy * 0.22
feet.add(
soft_board((0.118, 0.144, 0.026), (x, y, 0.013), 0.012, 0.002),
'black',
density=1100,
)
feet.add(
cylinder(0.010, 0.018, (x, y, 0.032)),
'steel',
density=7800,
)
feet.emit(world, 'furniture_foot')
mounts = Part('wall_art_mounting_spacers', 'black', 0.6, 0.6)
for yy in (-0.54, 0.0):
mounts.block(
(0.018, 0.042, 0.048),
(EAST - 0.009, yy, 2.13),
'black',
density=1100,
)
mounts.add(
cylinder(0.005, 0.024, (EAST - 0.013, yy, 2.13), (1, 0, 0), 12),
'steel',
density=7800,
)
mounts.emit(world, 'wall_fixing')
def handle_contact_pieces(x, y, z, length, radius=0.008):
low = z - length / 2
high = z + length / 2
return [
rod((x, y, low), (x, y - 0.027, low + 0.012), radius),
rod((x, y - 0.030, low + 0.014), (x, y - 0.030, high - 0.014), radius),
rod((x, y - 0.027, high - 0.012), (x, y, high), radius),
]
def fridge_door_contacts(door, x, center_z, height, rack_levels):
# The first report hulled the main door into a single wedge through the
# interior. Preserve the slab, gasket and every rack wall separately.
front = FRIDGE_FRONT
w = FRIDGE_W
lo = center_z - height / 2
hi = center_z + height / 2
pieces = [door.meshes[0].convex_hull]
for side in (-1, 1):
pieces.append(box(
(0.012, 0.005, height - 0.058),
(x + side * (w / 2 - 0.028), front + 0.034, center_z),
))
for zz in (lo + 0.026, hi - 0.026):
pieces.append(box(
(w - 0.056, 0.005, 0.012),
(x, front + 0.034, zz),
))
for zz in rack_levels:
pieces.append(box(
(w - 0.17, 0.071, 0.012),
(x - 0.006, front + 0.074, zz),
))
pieces.append(box(
(w - 0.17, 0.010, 0.070),
(x - 0.006, front + 0.111, zz + 0.034),
))
for side in (-1, 1):
pieces.append(box(
(0.010, 0.075, 0.073),
(x - 0.006 + side * (w - 0.18) / 2, front + 0.075, zz + 0.03),
))
pull_z = center_z + (0.12 if height > 1 else 0.01)
pull_length = 0.38 if height > 1 else 0.26
pieces.extend(handle_contact_pieces(
x - w / 2 + 0.070,
front - 0.034,
pull_z,
pull_length,
))
for zz in (pull_z - pull_length / 2, pull_z + pull_length / 2):
pieces.append(cylinder(
0.012,
0.004,
(x - w / 2 + 0.070, front - 0.035, zz),
(0, 1, 0),
20,
))
# Bearing contact is supplied by the hinge constraint; tiny interleaved
# knuckles remain visible but are not replaced by overlapping solid hulls.
assert len(pieces) <= 32
assert all(piece.is_volume for piece in pieces)
door.collision = pieces
def cabinet_door_contacts(leaf, cx, front, center_z, height, width, side):
pieces = []
for component in leaf.meshes[:7]:
pieces.append(component.convex_hull)
pull_x = cx - side * (width / 2 - 0.084)
pull_z = center_z + 0.028
pieces.extend(handle_contact_pieces(
pull_x,
front - 0.016,
pull_z,
0.145,
))
for zz in (pull_z - 0.0725, pull_z + 0.0725):
pieces.append(cylinder(
0.012,
0.004,
(pull_x, front - 0.017, zz),
(0, 1, 0),
20,
))
assert len(pieces) <= 32
assert all(piece.is_volume for piece in pieces)
leaf.collision = pieces
def fridge_shell_contacts(shell):
x = FRIDGE_X
y = FRIDGE_Y
w = FRIDGE_W
d = FRIDGE_D
lo = 0.095
hi = FRIDGE_H
pieces = []
for side in (-1, 1):
pieces.append(box(
(0.052, d, hi - lo),
(x + side * (w / 2 - 0.026), y, (lo + hi) / 2),
))
pieces.append(box((w - 0.104, 0.060, hi - lo), (x, y + d / 2 - 0.03, (hi + lo) / 2)))
pieces.append(box((w, d, 0.045), (x, y, hi - 0.0225)))
pieces.append(box((w - 0.08, d, 0.045), (x, y, lo + 0.0225)))
pieces.append(box((w - 0.08, d - 0.018, 0.036), (x, y + 0.006, 0.68)))
for shelf_z in (0.98, 1.29, 1.60):
pieces.append(box((w - 0.12, 0.43, 0.014), (x, y + 0.048, shelf_z)))
pieces.append(box((w - 0.12, 0.018, 0.022), (x, y - 0.172, shelf_z)))
pieces.append(box((w - 0.14, 0.43, 0.012), (x, y + 0.045, 0.36)))
for dx in (-0.27, 0.27):
for dy in (-0.25, 0.25):
pieces.append(cylinder(0.025, 0.10, (x + dx, y + dy, 0.05), sections=20))
pieces.append(box((w - 0.04, 0.028, 0.07), (x, y - d / 2 + 0.020, 0.087)))
assert len(pieces) <= 32
shell.collision = pieces
def wine_carcass_contacts(carcass):
x = WINE_X
y = WINE_Y
w = WINE_W
d = WINE_D
pieces = []
for side in (-1, 1):
pieces.append(box(
(0.026, d, WINE_H - 0.15),
(x + side * (w / 2 - 0.013), y, (WINE_H + 0.15) / 2),
))
pieces.append(box(
(0.055, 0.027, WINE_H - 0.15),
(x + side * (w / 2 - 0.0275), y - d / 2 - 0.003, (WINE_H + 0.15) / 2),
))
for sy in (-1, 1):
pieces.append(box((0.075, 0.075, 0.15), (x + side * 0.53, y + sy * 0.20, 0.075)))
pieces.append(box((w - 0.04, d - 0.025, 0.075), (x, y, 0.165)))
pieces.append(box((w - 0.052, 0.018, WINE_H - 0.16), (x, y + d / 2 - 0.009, (WINE_H + 0.16) / 2)))
pieces.append(box((w + 0.064, d + 0.044, 0.043), (x, y, WINE_H - 0.0215)))
pieces.append(box((w + 0.018, d + 0.012, 0.032), (x, y, WINE_H - 0.059)))
pieces.append(box((w - 0.052, d - 0.018, 0.027), (x, y - 0.007, 0.83)))
pieces.append(box((w - 0.052, d - 0.05, 0.018), (x, y + 0.007, 0.48)))
pieces.append(box((0.025, d - 0.045, 0.64), (x, y + 0.010, 0.505)))
for z in (1.20, 1.54, 1.88):
pieces.append(box((w - 0.055, d - 0.040, 0.022), (x, y + 0.002, z)))
pieces.append(box((w - 0.055, 0.028, 0.037), (x, y - d / 2 + 0.020, z - 0.007)))
assert len(pieces) <= 32
carcass.collision = pieces
def wine_cradle_half(x, y, shelf_z, side):
# Two convex hardwood cheeks form a true 90-degree cradle. Contact uses
# these same solids, eliminating the coarse hull across a curved recess.
section_points = [
(0.0, 0.011),
(0.054, 0.011),
(0.054, 0.067),
(0.041, 0.067),
(0.0, 0.026),
]
section = Polygon([(side * xx, zz) for xx, zz in section_points])
mesh = trimesh.creation.extrude_polygon(section, 0.020)
mesh.apply_transform(trimesh.transformations.rotation_matrix(math.pi / 2, (1, 0, 0)))
mesh.apply_translation((x, y + 0.010, shelf_z))
mesh.fix_normals()
assert mesh.is_volume
assert mesh.is_convex
return mesh
def build():
world = Environment(
description='Walnut & Sage dining room: central bar table, four stools, a bracket-mounted shelf with plant and jug, refrigerator and stocked wine cabinet.',
spawn_position=(ENTRY_X, -1.95, 0.5),
goal_position=(0.10, 1.28, 0.0),
gravity_m_s2=9.81,
)
build_floor(world)
build_walls(world)
build_trim(world)
build_window(world)
build_wall_panels(world)
build_bar_table(world)
build_stool(world, 1, -0.65, TABLE_Y - 0.85, math.pi)
build_stool(world, 2, 0.65, TABLE_Y - 0.85, math.pi)
build_stool(world, 3, -0.65, TABLE_Y + 0.85, 0.0)
build_stool(world, 4, 0.65, TABLE_Y + 0.85, 0.0)
build_fridge(world)
build_wine_cabinet(world)
build_console(world)
build_shelf(world)
build_plant(world)
build_jug(world)
build_pendant(world)
build_wall_art(world)
build_switch(world)
build_socket(world, 'serving_wall_socket', 0.25, NORTH - 0.040, 1.05)
build_socket(world, 'refrigerator_wall_socket', -2.53, NORTH - 0.040, 0.42)
build_serving_tray(world)
build_plate(world, 'bar_plate_left', -0.60, TABLE_Y - 0.07, TABLE_H)
build_plate(world, 'bar_plate_right', 0.60, TABLE_Y + 0.07, TABLE_H)
build_cup(world, 'bar_cup_left', -0.87, TABLE_Y + 0.21, TABLE_H)
build_cup(world, 'bar_cup_right', 0.87, TABLE_Y - 0.21, TABLE_H)
build_serving_details(world)
build_furniture_supports(world)
verify_authored_layout(world)
world.note('Synthetic dining room; all dimensions and dry-contact properties are labeled design assumptions. No robot-specific clearance or task validation.')
world.note('Complete four-wall and ceiling shell. Interior cameras inspect the room through its usable interior, not through omitted structure.')
world.note('Passive fridge and cabinet hinges plus console drawer; estimated mass and diagonal composite inertia. No cooling, liquids, latch state or deformable plant physics.')
return world