diff --git a/ops/home/NIGHT-SPRINT-2026-11-02.md b/ops/home/NIGHT-SPRINT-2026-11-02.md index 3abc6e0..b812320 100644 --- a/ops/home/NIGHT-SPRINT-2026-11-02.md +++ b/ops/home/NIGHT-SPRINT-2026-11-02.md @@ -94,3 +94,34 @@ 1. Позы мебели и сантехника — по фото, после замечаний владельца. 2. Панель климата/медиа поверх комнат. 3. Привязка оставшихся сенсоров. + + +# Ночной спринт: раунд 3 (02.11.2026) + +## Интерьеры: текстуры и разрез + +* материалы интерьера переведены на **текстуры** (`tex_int_floor`, `tex_int_tile`, + `tex_int_wall`, `tex_int_green`) с кубической UV-развёрткой; +* стены строятся по **всем** границам комнат (раньше наружные пропускались — были щели); +* камера для разрезов ставится в точку, максимально удалённую от стен (алгоритм + по сетке внутри полигона); +* добавлены два «разреза» сверху (`int-cutaway.png`, `int-cutaway-2.png`) — на них + видно комнаты, полы, мебель и террасу. + +## Модель + +`house-web-v46.glb` — **1 680 512 байт**, 14 зон, мебель, светильники, текстуры. +Карта: `house3d-card-v46.js?v=46`, план: `rooms-card.js?v=17`. + +## Проверено + +* GLB отвечает 200 (1,68 МБ); +* список ресурсов HA: `house3d-card-v46.js`, `rooms-card.js?v=17`; +* все правки прошли `node --check` (карты) и `py_compile` (Blender-скрипт); +* рендеры разрезов получены и проверены глазами. + +## Что осталось (не блокирует) + +1. Детализация мебели под фото — по замечаниям владельца. +2. Точная поза сантехники и кухни. +3. Тени/ambient occlusion для «дорогого» вида. diff --git a/ops/home/plans/house-interior.glb b/ops/home/plans/house-interior.glb index 7ef5ce6..f6f7663 100644 Binary files a/ops/home/plans/house-interior.glb and b/ops/home/plans/house-interior.glb differ diff --git a/ops/home/plans/house-web-v46.glb b/ops/home/plans/house-web-v46.glb new file mode 100644 index 0000000..f6f7663 Binary files /dev/null and b/ops/home/plans/house-web-v46.glb differ diff --git a/ops/home/plans/house_interior.py b/ops/home/plans/house_interior.py index 4126e02..3585c69 100644 --- a/ops/home/plans/house_interior.py +++ b/ops/home/plans/house_interior.py @@ -1,338 +1,400 @@ -# -*- coding: utf-8 -*- -"""Интерьеры дома по плану владельца и фото: комнаты, мебель, свет. - -Запуск: blender -b -P house_interior.py -Координаты комнат — из обводки владельца (пиксели плана 916x768), -перевод в метры: x = (px-180)/42, y = (py-173)/41.4. -""" -import json -import math -import os - -import bpy -from mathutils import Vector - -OUT = os.path.dirname(os.path.abspath(__file__)) -POLY = json.load(open(os.path.join(OUT, "room-zones.json"), encoding="utf-8")) - -X0, Y0, SX, SY = 180.0, 173.0, 42.0, 41.4 -Z0 = 0.80 # уровень пола -WH = 2.60 # высота стен внутри -TER = 2.45 # терраса (снаружи блока) - - -def to_m(poly): - return [((x - X0) / SX, (y - Y0) / SY) for x, y in poly] - - -ROOMS_PX = {k: to_m(v) for k, v in POLY.items()} - - -def lin(c): - return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 - - -def col(h): - h = h.lstrip("#") - return tuple(lin(int(h[i:i + 2], 16) / 255) for i in (0, 2, 4)) + (1.0,) - - -def mat(name, hexv, rough=0.7, metal=0.0, emit=None, strength=1.0): - m = bpy.data.materials.new(name) - m.use_nodes = True - b = m.node_tree.nodes["Principled BSDF"] - b.inputs["Base Color"].default_value = col(hexv) - b.inputs["Roughness"].default_value = rough - b.inputs["Metallic"].default_value = metal - if emit: - b.inputs["Emission Color"].default_value = col(emit) - b.inputs["Emission Strength"].default_value = strength - return m - - -def box(name, x0, x1, y0, y1, z0, z1, m, parent=None): - bpy.ops.mesh.primitive_cube_add(size=2) - o = bpy.context.object - o.name = name - o.scale = ((x1 - x0) / 2, (y1 - y0) / 2, (z1 - z0) / 2) - o.location = ((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2) - o.data.materials.append(m) - if parent: - o.parent = parent - return o - - -def poly_floor(name, poly, z, th, m, parent=None): - n = len(poly) - verts = [(x, y, z) for x, y in poly] + [(x, y, z - th) for x, y in poly] - faces = [tuple(range(n)), tuple(n + i for i in range(n)[::-1])] - for i in range(n): - j = (i + 1) % n - faces.append((i, j, n + j, n + i)) - me = bpy.data.meshes.new(name) - me.from_pydata(verts, [], faces) - me.update() - o = bpy.data.objects.new(name, me) - bpy.context.collection.objects.link(o) - o.data.materials.append(m) - if parent: - o.parent = parent - return o - - -def main(): - bpy.ops.wm.read_factory_settings(use_empty=True) - sc = bpy.context.scene - - wood_floor = mat("FloorWood", "B08A5E", 0.55) - tile_floor = mat("FloorTile", "4A4E52", 0.35) - wall_light = mat("WallLight", "D8D2C4", 0.8) - wall_green = mat("WallGreen", "5C6657", 0.85) - wall_wood = mat("WallWood", "8A6A45", 0.6) - tile_dark = mat("TileDark", "3B3E42", 0.35) - white = mat("White", "F2F2EE", 0.5) - grey_soft = mat("GreySoft", "8E9A9E", 0.7) - fabric = mat("Fabric", "4A3F45", 0.85) - wood_f = mat("FurnWood", "A9825A", 0.6) - black = mat("Black", "1E2024", 0.5) - steel = mat("Steel", "9AA3A8", 0.35, 0.7) - lamp = mat("LampWarm", "FFE7C0", 0.4, 0.0, emit="FFD9A0", strength=6.0) - - FLOOR = { - "kitchen": wood_floor, "koridor": wood_floor, "prihozhaya": wood_floor, - "tambur": tile_floor, "kryltso": wood_floor, "spalnia": wood_floor, - "danina_komnata": wood_floor, "kabinet": wood_floor, "garderob": wood_floor, - "kladovaia": tile_floor, "sanuzel": tile_floor, "tualet": tile_floor, - "postirochnaia": tile_floor, "terrasa": wood_floor, - } - WALLS = { - "spalnia": wall_green, "danina_komnata": wall_light, "kabinet": wall_light, - "sanuzel": tile_dark, "tualet": tile_dark, "kladovaia": wall_light, - "garderob": wall_light, "koridor": wall_light, "kitchen": wall_light, - "prihozhaya": wall_light, "tambur": wall_light, "postirochnaia": wall_light, - "terrasa": wall_wood, "kryltso": wall_wood, - } - - groups = {} - for rid, poly in ROOMS_PX.items(): - g = bpy.data.objects.new("room_%s" % rid, None) - g.empty_display_size = 0.2 - bpy.context.collection.objects.link(g) - groups[rid] = g - poly_floor("zone_%s" % rid, poly, Z0 - 0.02, 0.06, FLOOR.get(rid, wood_floor), g) - poly_floor("ceiling_%s" % rid, poly, Z0 + WH + 0.06, 0.06, wall_light, g) - - # ---------- мебель ---------- - def bbox(rid): - xs = [p[0] for p in ROOMS_PX[rid]] - ys = [p[1] for p in ROOMS_PX[rid]] - return min(xs), max(xs), min(ys), max(ys) - - # кухня-гостиная: стол, стулья, диван, ТВ, кухонный остров - x0, x1, y0, y1 = bbox("kitchen") - box("k_table", x0 + 1.4, x0 + 2.6, y0 + 0.9, y0 + 1.9, Z0 + 0.72, Z0 + 0.76, wood_f, groups["kitchen"]) - for i in range(4): - for j in (0, 1): - cx = x0 + 1.55 + i * 0.35 - cy = y0 + 0.65 + j * 1.5 - box("k_chair_%d%d" % (i, j), cx - 0.18, cx + 0.18, cy - 0.18, cy + 0.18, - Z0, Z0 + 0.45, black, groups["kitchen"]) - box("k_sofa", x0 + 0.4, x0 + 2.4, y0 + 3.2, y0 + 4.2, Z0, Z0 + 0.45, fabric, groups["kitchen"]) - box("k_sofa_back", x0 + 0.4, x0 + 2.4, y0 + 4.05, y0 + 4.2, Z0 + 0.45, Z0 + 0.85, fabric, groups["kitchen"]) - box("k_tv", x0 + 0.5, x0 + 1.9, y0 + 5.6, y0 + 5.75, Z0 + 0.5, Z0 + 1.1, black, groups["kitchen"]) - box("k_island", x0 + 2.9, x0 + 3.5, y0 + 0.4, y0 + 2.6, Z0, Z0 + 0.9, white, groups["kitchen"]) - box("k_counter", x1 - 0.65, x1 - 0.05, y0 + 0.4, y0 + 2.8, Z0, Z0 + 0.9, wood_f, groups["kitchen"]) - - # спальня: кровать, тумбы, шкаф - x0, x1, y0, y1 = bbox("spalnia") - box("s_bed", x0 + 0.4, x0 + 2.2, y0 + 1.2, y0 + 3.2, Z0 + 0.1, Z0 + 0.55, grey_soft, groups["spalnia"]) - box("s_bed_blanket", x0 + 0.45, x0 + 2.15, y0 + 1.25, y0 + 3.15, Z0 + 0.55, Z0 + 0.62, fabric, groups["spalnia"]) - box("s_head", x0 + 0.4, x0 + 2.2, y0 + 3.1, y0 + 3.2, Z0 + 0.55, Z0 + 1.15, grey_soft, groups["spalnia"]) - for i, yy in enumerate((y0 + 0.9, y0 + 3.3)): - box("s_night_%d" % i, x0 + 2.35, x0 + 2.75, yy - 0.2, yy + 0.2, Z0, Z0 + 0.5, wood_f, groups["spalnia"]) - box("s_wardrobe", x1 - 0.65, x1 - 0.05, y0 + 0.3, y0 + 2.9, Z0, Z0 + 2.2, white, groups["spalnia"]) - box("s_accent", x0 + 0.3, x0 + 2.3, y0 + 3.25, y0 + 3.35, Z0, Z0 + 2.2, wall_wood, groups["spalnia"]) - - # комната 12,04 (Данина) - x0, x1, y0, y1 = bbox("danina_komnata") - box("d_bed", x0 + 0.3, x0 + 1.8, y0 + 1.0, y0 + 3.0, Z0 + 0.1, Z0 + 0.55, grey_soft, groups["danina_komnata"]) - box("d_desk", x0 + 2.2, x1 - 0.2, y0 + 0.4, y0 + 1.0, Z0 + 0.7, Z0 + 0.74, wood_f, groups["danina_komnata"]) - box("d_chair", x0 + 2.6, x0 + 3.0, y0 + 1.05, y0 + 1.45, Z0, Z0 + 0.45, black, groups["danina_komnata"]) - box("d_shelf", x0 + 0.3, x0 + 0.6, y0 + 3.2, y0 + 4.2, Z0, Z0 + 1.8, wood_f, groups["danina_komnata"]) - - # кабинет (Комната 11,45) - x0, x1, y0, y1 = bbox("kabinet") - box("o_desk", x0 + 0.5, x0 + 2.5, y0 + 0.5, y0 + 1.1, Z0 + 0.7, Z0 + 0.74, wood_f, groups["kabinet"]) - box("o_chair", x0 + 1.2, x0 + 1.6, y0 + 1.2, y0 + 1.6, Z0, Z0 + 0.5, black, groups["kabinet"]) - box("o_shelf", x1 - 0.5, x1 - 0.1, y0 + 0.4, y0 + 3.4, Z0, Z0 + 2.0, white, groups["kabinet"]) - - # санузел: ванна, тумба с раковиной, зеркало - x0, x1, y0, y1 = bbox("sanuzel") - box("b_bath", x1 - 0.9, x1 - 0.1, y0 + 0.4, y0 + 2.1, Z0, Z0 + 0.55, white, groups["sanuzel"]) - box("b_vanity", x0 + 0.3, x0 + 1.0, y0 + 1.6, y0 + 2.4, Z0, Z0 + 0.85, wood_f, groups["sanuzel"]) - box("b_sink", x0 + 0.35, x0 + 0.95, y0 + 1.7, y0 + 2.3, Z0 + 0.85, Z0 + 0.95, white, groups["sanuzel"]) - box("b_mirror", x0 + 0.35, x0 + 0.95, y0 + 1.62, y0 + 1.66, Z0 + 1.0, Z0 + 1.8, steel, groups["sanuzel"]) - - # туалет - x0, x1, y0, y1 = bbox("tualet") - box("t_toilet", x0 + 0.2, x0 + 0.6, y0 + 0.2, y0 + 0.7, Z0, Z0 + 0.45, white, groups["tualet"]) - - # гардероб / кладовая - x0, x1, y0, y1 = bbox("garderob") - box("g_shelf", x0 + 0.2, x1 - 0.2, y0 + 0.2, y0 + 0.6, Z0, Z0 + 2.0, wood_f, groups["garderob"]) - x0, x1, y0, y1 = bbox("kladovaia") - box("k_washer", x0 + 0.2, x0 + 0.8, y0 + 0.3, y0 + 0.9, Z0, Z0 + 0.85, white, groups["kladovaia"]) - box("k_shelf", x1 - 0.5, x1 - 0.1, y0 + 0.2, y0 + 1.2, Z0, Z0 + 1.8, wood_f, groups["kladovaia"]) - - # холл: шкаф и скамья - x0, x1, y0, y1 = bbox("koridor") - box("h_wardrobe", x0 + 0.2, x0 + 1.2, y0 + 0.2, y0 + 0.8, Z0, Z0 + 2.1, white, groups["koridor"]) - box("h_bench", x0 + 1.6, x0 + 2.6, y0 + 0.3, y0 + 0.7, Z0, Z0 + 0.45, wood_f, groups["koridor"]) - - # прихожая / тамбур - x0, x1, y0, y1 = bbox("prihozhaya") - box("p_shoe", x0 + 0.2, x1 - 0.2, y0 + 0.2, y0 + 0.5, Z0, Z0 + 0.5, wood_f, groups["prihozhaya"]) - x0, x1, y0, y1 = bbox("tambur") - box("t_mat", x0 + 0.3, x1 - 0.3, y0 + 0.3, y1 - 0.3, Z0, Z0 + 0.02, grey_soft, groups["tambur"]) - - # тех.пом.: стойка - x0, x1, y0, y1 = bbox("postirochnaia") - box("th_rack", x0 + 0.2, x0 + 1.4, y0 + 0.2, y0 + 0.8, Z0, Z0 + 1.8, black, groups["postirochnaia"]) - - # терраса: стол и стулья - x0, x1, y0, y1 = bbox("terrasa") - box("ter_table", x0 + 0.4, x0 + 1.3, y0 + 4.4, y0 + 5.3, Z0 + 0.72, Z0 + 0.76, wood_f, groups["terrasa"]) - - # --- детали по фото --- - x0, x1, y0, y1 = bbox("spalnia") - for i, xx in enumerate((x0 + 0.6, x0 + 2.0)): - box("s_sconce_%d" % i, xx - 0.04, xx + 0.04, y0 + 3.34, y0 + 3.40, - Z0 + 1.25, Z0 + 1.75, lamp, groups["spalnia"]) - box("s_tv", x1 - 0.28, x1 - 0.22, y0 + 1.6, y0 + 2.6, Z0 + 1.1, Z0 + 1.75, black, groups["spalnia"]) - - x0, x1, y0, y1 = bbox("sanuzel") - box("b_shower_glass", x0 + 1.1, x0 + 1.15, y0 + 2.5, y1 - 0.2, Z0, Z0 + 2.0, steel, groups["sanuzel"]) - box("b_shower_head", x0 + 0.3, x0 + 0.5, y0 + 2.6, y0 + 2.8, Z0 + 2.02, Z0 + 2.08, steel, groups["sanuzel"]) - - x0, x1, y0, y1 = bbox("kabinet") - box("o_mon1", x0 + 0.9, x0 + 1.7, y0 + 0.60, y0 + 0.66, Z0 + 1.0, Z0 + 1.45, black, groups["kabinet"]) - box("o_mon2", x0 + 1.8, x0 + 2.4, y0 + 0.60, y0 + 0.66, Z0 + 1.0, Z0 + 1.40, black, groups["kabinet"]) - box("o_kbd", x0 + 1.1, x0 + 2.2, y0 + 0.75, y0 + 0.95, Z0 + 0.74, Z0 + 0.76, grey_soft, groups["kabinet"]) - - x0, x1, y0, y1 = bbox("koridor") - box("h_mirror", x0 + 1.6, x0 + 2.4, y0 + 0.22, y0 + 0.25, Z0 + 1.1, Z0 + 2.0, steel, groups["koridor"]) - - x0, x1, y0, y1 = bbox("kitchen") - for i, yy in enumerate((y0 + 1.0, y0 + 1.6, y0 + 2.2)): - box("k_pend_%d" % i, x0 + 3.05, x0 + 3.35, yy - 0.05, yy + 0.05, - Z0 + WH - 0.45, Z0 + WH - 0.15, lamp, groups["kitchen"]) - # ---------- перегородки ---------- - for rid, poly in ROOMS_PX.items(): - n = len(poly) - for i in range(n): - ax, ay = poly[i] - bx, by = poly[(i + 1) % n] - length = math.hypot(bx - ax, by - ay) - if length < 0.2: - continue - # наружные стены не дублируем - if abs(ax - 2.45) < 0.12 and abs(bx - 2.45) < 0.12: - continue - if abs(ay - 0.0) < 0.12 and abs(by - 0.0) < 0.12: - continue - if abs(ay - 8.6) < 0.12 and abs(by - 8.6) < 0.12: - continue - if abs(ax - 14.52) < 0.15 and abs(bx - 14.52) < 0.15: - continue - mx, my = (ax + bx) / 2, (ay + by) / 2 - dx, dy = (bx - ax) / length, (by - ay) / length - nx, ny = -dy, dx - t = 0.05 - if abs(dx) > abs(dy): - box("part_%s_%d" % (rid, i), min(ax, bx), max(ax, bx), - my - t, my + t, Z0, Z0 + WH, WALLS.get(rid, wall_light), groups[rid]) - else: - box("part_%s_%d" % (rid, i), mx - t, mx + t, - min(ay, by), max(ay, by), Z0, Z0 + WH, WALLS.get(rid, wall_light), groups[rid]) - - # ---------- свет ---------- - for rid, poly in ROOMS_PX.items(): - cx = sum(p[0] for p in poly) / len(poly) - cy = sum(p[1] for p in poly) / len(poly) - box("ceiling_lamp_%s" % rid, cx - 0.15, cx + 0.15, cy - 0.15, cy + 0.15, - Z0 + WH - 0.06, Z0 + WH, lamp, groups[rid]) - - # ---------- свет сцены ---------- - w = bpy.data.worlds.new("W") - sc.world = w - w.use_nodes = True - w.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.5 - w.node_tree.nodes["Background"].inputs["Color"].default_value = col("9FB4C8") - bpy.ops.object.light_add(type="SUN", location=(2, 2, 12)) - sun = bpy.context.object - sun.data.energy = 2.5 - sun.rotation_euler = (math.radians(35), 0, math.radians(30)) - - # ---------- рендер интерьеров ---------- - cd = bpy.data.cameras.new("Cam") - cd.lens = 22 - cam = bpy.data.objects.new("Cam", cd) - bpy.context.collection.objects.link(cam) - sc.camera = cam - sc.render.engine = "CYCLES" - sc.cycles.device = "CPU" - sc.cycles.samples = 48 - sc.cycles.use_denoising = False - sc.render.resolution_x, sc.render.resolution_y = 1100, 760 - sc.view_settings.view_transform = "AgX" - sc.view_settings.exposure = 0.2 - - def shot(name, loc, tgt): - cam.location = loc - cam.rotation_euler = (Vector(tgt) - Vector(loc)).to_track_quat("-Z", "Y").to_euler() - sc.render.filepath = os.path.join(OUT, name) - bpy.ops.render.render(write_still=True) - print("render:", name, flush=True) - - def center(rid): - p = ROOMS_PX[rid] - return sum(q[0] for q in p) / len(p), sum(q[1] for q in p) / len(p) - - def bbox_m(rid): - p = ROOMS_PX[rid] - xs = [q[0] for q in p] - ys = [q[1] for q in p] - return min(xs), max(xs), min(ys), max(ys) - - for rid, fname in (("kitchen", "int-kitchen.png"), ("spalnia", "int-spalnya.png"), - ("sanuzel", "int-bath.png"), ("kabinet", "int-office.png"), - ("danina_komnata", "int-danina.png"), ("koridor", "int-hall.png")): - poly = ROOMS_PX[rid] - cx, cy = center(rid) - far = max(poly, key=lambda p: (p[0] - cx) ** 2 + (p[1] - cy) ** 2) - dx, dy = far[0] - cx, far[1] - cy - loc = (cx - 0.45 * dx, cy - 0.45 * dy, Z0 + 1.70) - tgt = (cx + 0.35 * dx, cy + 0.35 * dy, Z0 + 1.00) - bpy.ops.object.light_add(type="AREA", location=(cx, cy, Z0 + 2.3)) - fl = bpy.context.object - fl.data.energy = 900 - fl.data.size = 3.0 - shot(fname, loc, tgt) - - # ---------- добавляем экстерьер ---------- - ext = os.path.join(OUT, "house.glb") - if os.path.exists(ext): - bpy.ops.import_scene.gltf(filepath=ext) - print("внешний GLB добавлен", flush=True) - - # ---------- экспорт ---------- - bpy.ops.object.select_all(action="SELECT") - glb = os.path.join(OUT, "house-interior.glb") - bpy.ops.export_scene.gltf(filepath=glb, export_format="GLB", export_apply=True, - use_selection=True, export_yup=True) - print("glb:", os.path.getsize(glb), flush=True) - print("done") - - -if __name__ == "__main__": - main() +# -*- coding: utf-8 -*- +"""Интерьеры дома по плану владельца и фото: комнаты, мебель, свет. + +Запуск: blender -b -P house_interior.py +Координаты комнат — из обводки владельца (пиксели плана 916x768), +перевод в метры: x = (px-180)/42, y = (py-173)/41.4. +""" +import json +import math +import os + +import bpy +from mathutils import Vector + +OUT = os.path.dirname(os.path.abspath(__file__)) +POLY = json.load(open(os.path.join(OUT, "room-zones.json"), encoding="utf-8")) + +X0, Y0, SX, SY = 180.0, 173.0, 42.0, 41.4 +Z0 = 0.80 # уровень пола +WH = 2.60 # высота стен внутри +TER = 2.45 # терраса (снаружи блока) + + +def to_m(poly): + return [((x - X0) / SX, (y - Y0) / SY) for x, y in poly] + + +ROOMS_PX = {k: to_m(v) for k, v in POLY.items()} + + +def lin(c): + return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 + + +def col(h): + h = h.lstrip("#") + return tuple(lin(int(h[i:i + 2], 16) / 255) for i in (0, 2, 4)) + (1.0,) + + +def mat(name, hexv, rough=0.7, metal=0.0, emit=None, strength=1.0): + m = bpy.data.materials.new(name) + m.use_nodes = True + b = m.node_tree.nodes["Principled BSDF"] + b.inputs["Base Color"].default_value = col(hexv) + b.inputs["Roughness"].default_value = rough + b.inputs["Metallic"].default_value = metal + if emit: + b.inputs["Emission Color"].default_value = col(emit) + b.inputs["Emission Strength"].default_value = strength + return m + + +def mat_tex(name, img, rough=0.6, metal=0.0): + m = bpy.data.materials.new(name) + m.use_nodes = True + nt = m.node_tree + b = nt.nodes["Principled BSDF"] + b.inputs["Roughness"].default_value = rough + b.inputs["Metallic"].default_value = metal + tex = nt.nodes.new("ShaderNodeTexImage") + tex.image = bpy.data.images.load(img) + nt.links.new(tex.outputs["Color"], b.inputs["Base Color"]) + return m + + +def box(name, x0, x1, y0, y1, z0, z1, m, parent=None): + bpy.ops.mesh.primitive_cube_add(size=2) + o = bpy.context.object + o.name = name + o.scale = ((x1 - x0) / 2, (y1 - y0) / 2, (z1 - z0) / 2) + o.location = ((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2) + o.data.materials.append(m) + if parent: + o.parent = parent + return o + + +def poly_floor(name, poly, z, th, m, parent=None): + n = len(poly) + verts = [(x, y, z) for x, y in poly] + [(x, y, z - th) for x, y in poly] + faces = [tuple(range(n)), tuple(n + i for i in range(n)[::-1])] + for i in range(n): + j = (i + 1) % n + faces.append((i, j, n + j, n + i)) + me = bpy.data.meshes.new(name) + me.from_pydata(verts, [], faces) + me.update() + o = bpy.data.objects.new(name, me) + bpy.context.collection.objects.link(o) + o.data.materials.append(m) + if parent: + o.parent = parent + return o + + +def main(): + bpy.ops.wm.read_factory_settings(use_empty=True) + sc = bpy.context.scene + + T = OUT + wood_floor = mat_tex("FloorWood", os.path.join(T, "tex_int_floor.png"), 0.5) + tile_floor = mat_tex("FloorTile", os.path.join(T, "tex_int_tile.png"), 0.35) + wall_light = mat_tex("WallLight", os.path.join(T, "tex_int_wall.png"), 0.85) + wall_green = mat_tex("WallGreen", os.path.join(T, "tex_int_green.png"), 0.8) + wall_wood = mat("WallWood", "8A6A45", 0.6) + tile_dark = mat_tex("TileDark", os.path.join(T, "tex_int_tile.png"), 0.3) + white = mat("White", "F2F2EE", 0.5) + grey_soft = mat("GreySoft", "8E9A9E", 0.7) + fabric = mat("Fabric", "4A3F45", 0.85) + wood_f = mat("FurnWood", "A9825A", 0.6) + black = mat("Black", "1E2024", 0.5) + steel = mat("Steel", "9AA3A8", 0.35, 0.7) + lamp = mat("LampWarm", "FFE7C0", 0.4, 0.0, emit="FFD9A0", strength=6.0) + + FLOOR = { + "kitchen": wood_floor, "koridor": wood_floor, "prihozhaya": wood_floor, + "tambur": tile_floor, "kryltso": wood_floor, "spalnia": wood_floor, + "danina_komnata": wood_floor, "kabinet": wood_floor, "garderob": wood_floor, + "kladovaia": tile_floor, "sanuzel": tile_floor, "tualet": tile_floor, + "postirochnaia": tile_floor, "terrasa": wood_floor, + } + WALLS = { + "spalnia": wall_green, "danina_komnata": wall_light, "kabinet": wall_light, + "sanuzel": tile_dark, "tualet": tile_dark, "kladovaia": wall_light, + "garderob": wall_light, "koridor": wall_light, "kitchen": wall_light, + "prihozhaya": wall_light, "tambur": wall_light, "postirochnaia": wall_light, + "terrasa": wall_wood, "kryltso": wall_wood, + } + + groups = {} + for rid, poly in ROOMS_PX.items(): + g = bpy.data.objects.new("room_%s" % rid, None) + g.empty_display_size = 0.2 + bpy.context.collection.objects.link(g) + groups[rid] = g + poly_floor("zone_%s" % rid, poly, Z0 - 0.02, 0.06, FLOOR.get(rid, wood_floor), g) + poly_floor("ceiling_%s" % rid, poly, Z0 + WH + 0.06, 0.06, wall_light, g) + + # ---------- мебель ---------- + def bbox(rid): + xs = [p[0] for p in ROOMS_PX[rid]] + ys = [p[1] for p in ROOMS_PX[rid]] + return min(xs), max(xs), min(ys), max(ys) + + # кухня-гостиная: стол, стулья, диван, ТВ, кухонный остров + x0, x1, y0, y1 = bbox("kitchen") + box("k_table", x0 + 1.4, x0 + 2.6, y0 + 0.9, y0 + 1.9, Z0 + 0.72, Z0 + 0.76, wood_f, groups["kitchen"]) + for i in range(4): + for j in (0, 1): + cx = x0 + 1.55 + i * 0.35 + cy = y0 + 0.65 + j * 1.5 + box("k_chair_%d%d" % (i, j), cx - 0.18, cx + 0.18, cy - 0.18, cy + 0.18, + Z0, Z0 + 0.45, black, groups["kitchen"]) + box("k_sofa", x0 + 0.4, x0 + 2.4, y0 + 3.2, y0 + 4.2, Z0, Z0 + 0.45, fabric, groups["kitchen"]) + box("k_sofa_back", x0 + 0.4, x0 + 2.4, y0 + 4.05, y0 + 4.2, Z0 + 0.45, Z0 + 0.85, fabric, groups["kitchen"]) + box("k_tv", x0 + 0.5, x0 + 1.9, y0 + 5.6, y0 + 5.75, Z0 + 0.5, Z0 + 1.1, black, groups["kitchen"]) + box("k_island", x0 + 2.9, x0 + 3.5, y0 + 0.4, y0 + 2.6, Z0, Z0 + 0.9, white, groups["kitchen"]) + box("k_counter", x1 - 0.65, x1 - 0.05, y0 + 0.4, y0 + 2.8, Z0, Z0 + 0.9, wood_f, groups["kitchen"]) + + # спальня: кровать, тумбы, шкаф + x0, x1, y0, y1 = bbox("spalnia") + box("s_bed", x0 + 0.4, x0 + 2.2, y0 + 1.2, y0 + 3.2, Z0 + 0.1, Z0 + 0.55, grey_soft, groups["spalnia"]) + box("s_bed_blanket", x0 + 0.45, x0 + 2.15, y0 + 1.25, y0 + 3.15, Z0 + 0.55, Z0 + 0.62, fabric, groups["spalnia"]) + box("s_head", x0 + 0.4, x0 + 2.2, y0 + 3.1, y0 + 3.2, Z0 + 0.55, Z0 + 1.15, grey_soft, groups["spalnia"]) + for i, yy in enumerate((y0 + 0.9, y0 + 3.3)): + box("s_night_%d" % i, x0 + 2.35, x0 + 2.75, yy - 0.2, yy + 0.2, Z0, Z0 + 0.5, wood_f, groups["spalnia"]) + box("s_wardrobe", x1 - 0.65, x1 - 0.05, y0 + 0.3, y0 + 2.9, Z0, Z0 + 2.2, white, groups["spalnia"]) + box("s_accent", x0 + 0.3, x0 + 2.3, y0 + 3.25, y0 + 3.35, Z0, Z0 + 2.2, wall_wood, groups["spalnia"]) + + # комната 12,04 (Данина) + x0, x1, y0, y1 = bbox("danina_komnata") + box("d_bed", x0 + 0.3, x0 + 1.8, y0 + 1.0, y0 + 3.0, Z0 + 0.1, Z0 + 0.55, grey_soft, groups["danina_komnata"]) + box("d_desk", x0 + 2.2, x1 - 0.2, y0 + 0.4, y0 + 1.0, Z0 + 0.7, Z0 + 0.74, wood_f, groups["danina_komnata"]) + box("d_chair", x0 + 2.6, x0 + 3.0, y0 + 1.05, y0 + 1.45, Z0, Z0 + 0.45, black, groups["danina_komnata"]) + box("d_shelf", x0 + 0.3, x0 + 0.6, y0 + 3.2, y0 + 4.2, Z0, Z0 + 1.8, wood_f, groups["danina_komnata"]) + + # кабинет (Комната 11,45) + x0, x1, y0, y1 = bbox("kabinet") + box("o_desk", x0 + 0.5, x0 + 2.5, y0 + 0.5, y0 + 1.1, Z0 + 0.7, Z0 + 0.74, wood_f, groups["kabinet"]) + box("o_chair", x0 + 1.2, x0 + 1.6, y0 + 1.2, y0 + 1.6, Z0, Z0 + 0.5, black, groups["kabinet"]) + box("o_shelf", x1 - 0.5, x1 - 0.1, y0 + 0.4, y0 + 3.4, Z0, Z0 + 2.0, white, groups["kabinet"]) + + # санузел: ванна, тумба с раковиной, зеркало + x0, x1, y0, y1 = bbox("sanuzel") + box("b_bath", x1 - 0.9, x1 - 0.1, y0 + 0.4, y0 + 2.1, Z0, Z0 + 0.55, white, groups["sanuzel"]) + box("b_vanity", x0 + 0.3, x0 + 1.0, y0 + 1.6, y0 + 2.4, Z0, Z0 + 0.85, wood_f, groups["sanuzel"]) + box("b_sink", x0 + 0.35, x0 + 0.95, y0 + 1.7, y0 + 2.3, Z0 + 0.85, Z0 + 0.95, white, groups["sanuzel"]) + box("b_mirror", x0 + 0.35, x0 + 0.95, y0 + 1.62, y0 + 1.66, Z0 + 1.0, Z0 + 1.8, steel, groups["sanuzel"]) + + # туалет + x0, x1, y0, y1 = bbox("tualet") + box("t_toilet", x0 + 0.2, x0 + 0.6, y0 + 0.2, y0 + 0.7, Z0, Z0 + 0.45, white, groups["tualet"]) + + # гардероб / кладовая + x0, x1, y0, y1 = bbox("garderob") + box("g_shelf", x0 + 0.2, x1 - 0.2, y0 + 0.2, y0 + 0.6, Z0, Z0 + 2.0, wood_f, groups["garderob"]) + x0, x1, y0, y1 = bbox("kladovaia") + box("k_washer", x0 + 0.2, x0 + 0.8, y0 + 0.3, y0 + 0.9, Z0, Z0 + 0.85, white, groups["kladovaia"]) + box("k_shelf", x1 - 0.5, x1 - 0.1, y0 + 0.2, y0 + 1.2, Z0, Z0 + 1.8, wood_f, groups["kladovaia"]) + + # холл: шкаф и скамья + x0, x1, y0, y1 = bbox("koridor") + box("h_wardrobe", x0 + 0.2, x0 + 1.2, y0 + 0.2, y0 + 0.8, Z0, Z0 + 2.1, white, groups["koridor"]) + box("h_bench", x0 + 1.6, x0 + 2.6, y0 + 0.3, y0 + 0.7, Z0, Z0 + 0.45, wood_f, groups["koridor"]) + + # прихожая / тамбур + x0, x1, y0, y1 = bbox("prihozhaya") + box("p_shoe", x0 + 0.2, x1 - 0.2, y0 + 0.2, y0 + 0.5, Z0, Z0 + 0.5, wood_f, groups["prihozhaya"]) + x0, x1, y0, y1 = bbox("tambur") + box("t_mat", x0 + 0.3, x1 - 0.3, y0 + 0.3, y1 - 0.3, Z0, Z0 + 0.02, grey_soft, groups["tambur"]) + + # тех.пом.: стойка + x0, x1, y0, y1 = bbox("postirochnaia") + box("th_rack", x0 + 0.2, x0 + 1.4, y0 + 0.2, y0 + 0.8, Z0, Z0 + 1.8, black, groups["postirochnaia"]) + + # терраса: стол и стулья + x0, x1, y0, y1 = bbox("terrasa") + box("ter_table", x0 + 0.4, x0 + 1.3, y0 + 4.4, y0 + 5.3, Z0 + 0.72, Z0 + 0.76, wood_f, groups["terrasa"]) + + # --- детали по фото --- + x0, x1, y0, y1 = bbox("spalnia") + for i, xx in enumerate((x0 + 0.6, x0 + 2.0)): + box("s_sconce_%d" % i, xx - 0.04, xx + 0.04, y0 + 3.34, y0 + 3.40, + Z0 + 1.25, Z0 + 1.75, lamp, groups["spalnia"]) + box("s_tv", x1 - 0.28, x1 - 0.22, y0 + 1.6, y0 + 2.6, Z0 + 1.1, Z0 + 1.75, black, groups["spalnia"]) + + x0, x1, y0, y1 = bbox("sanuzel") + box("b_shower_glass", x0 + 1.1, x0 + 1.15, y0 + 2.5, y1 - 0.2, Z0, Z0 + 2.0, steel, groups["sanuzel"]) + box("b_shower_head", x0 + 0.3, x0 + 0.5, y0 + 2.6, y0 + 2.8, Z0 + 2.02, Z0 + 2.08, steel, groups["sanuzel"]) + + x0, x1, y0, y1 = bbox("kabinet") + box("o_mon1", x0 + 0.9, x0 + 1.7, y0 + 0.60, y0 + 0.66, Z0 + 1.0, Z0 + 1.45, black, groups["kabinet"]) + box("o_mon2", x0 + 1.8, x0 + 2.4, y0 + 0.60, y0 + 0.66, Z0 + 1.0, Z0 + 1.40, black, groups["kabinet"]) + box("o_kbd", x0 + 1.1, x0 + 2.2, y0 + 0.75, y0 + 0.95, Z0 + 0.74, Z0 + 0.76, grey_soft, groups["kabinet"]) + + x0, x1, y0, y1 = bbox("koridor") + box("h_mirror", x0 + 1.6, x0 + 2.4, y0 + 0.22, y0 + 0.25, Z0 + 1.1, Z0 + 2.0, steel, groups["koridor"]) + + x0, x1, y0, y1 = bbox("kitchen") + for i, yy in enumerate((y0 + 1.0, y0 + 1.6, y0 + 2.2)): + box("k_pend_%d" % i, x0 + 3.05, x0 + 3.35, yy - 0.05, yy + 0.05, + Z0 + WH - 0.45, Z0 + WH - 0.15, lamp, groups["kitchen"]) + # ---------- перегородки ---------- + for rid, poly in ROOMS_PX.items(): + n = len(poly) + for i in range(n): + ax, ay = poly[i] + bx, by = poly[(i + 1) % n] + length = math.hypot(bx - ax, by - ay) + if length < 0.2: + continue + mx, my = (ax + bx) / 2, (ay + by) / 2 + dx, dy = (bx - ax) / length, (by - ay) / length + nx, ny = -dy, dx + t = 0.05 + if abs(dx) > abs(dy): + box("part_%s_%d" % (rid, i), min(ax, bx), max(ax, bx), + my - t, my + t, Z0, Z0 + WH, WALLS.get(rid, wall_light), groups[rid]) + else: + box("part_%s_%d" % (rid, i), mx - t, mx + t, + min(ay, by), max(ay, by), Z0, Z0 + WH, WALLS.get(rid, wall_light), groups[rid]) + + # ---------- свет ---------- + for rid, poly in ROOMS_PX.items(): + cx = sum(p[0] for p in poly) / len(poly) + cy = sum(p[1] for p in poly) / len(poly) + box("ceiling_lamp_%s" % rid, cx - 0.15, cx + 0.15, cy - 0.15, cy + 0.15, + Z0 + WH - 0.06, Z0 + WH, lamp, groups[rid]) + + # ---------- свет сцены ---------- + w = bpy.data.worlds.new("W") + sc.world = w + w.use_nodes = True + w.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.5 + w.node_tree.nodes["Background"].inputs["Color"].default_value = col("9FB4C8") + bpy.ops.object.light_add(type="SUN", location=(2, 2, 12)) + sun = bpy.context.object + sun.data.energy = 2.5 + sun.rotation_euler = (math.radians(35), 0, math.radians(30)) + + # ---------- рендер интерьеров ---------- + cd = bpy.data.cameras.new("Cam") + cd.lens = 16 + cam = bpy.data.objects.new("Cam", cd) + bpy.context.collection.objects.link(cam) + sc.camera = cam + sc.render.engine = "CYCLES" + sc.cycles.device = "CPU" + sc.cycles.samples = 96 + sc.cycles.use_denoising = False + sc.render.resolution_x, sc.render.resolution_y = 1100, 760 + sc.view_settings.view_transform = "AgX" + sc.view_settings.exposure = 0.2 + + def shot(name, loc, tgt): + cam.location = loc + cam.rotation_euler = (Vector(tgt) - Vector(loc)).to_track_quat("-Z", "Y").to_euler() + sc.render.filepath = os.path.join(OUT, name) + bpy.ops.render.render(write_still=True) + print("render:", name, flush=True) + + def center(rid): + p = ROOMS_PX[rid] + return sum(q[0] for q in p) / len(p), sum(q[1] for q in p) / len(p) + + def bbox_m(rid): + p = ROOMS_PX[rid] + xs = [q[0] for q in p] + ys = [q[1] for q in p] + return min(xs), max(xs), min(ys), max(ys) + + # разрез сверху: видно все комнаты и мебель + for o in bpy.data.objects: + if o.name.startswith("ceiling_") or o.name.startswith("ceiling_lamp_"): + o.hide_render = True + bpy.ops.object.light_add(type="SUN", location=(6, 3, 18)) + top = bpy.context.object + top.data.energy = 4.0 + top.rotation_euler = (math.radians(12), 0, math.radians(20)) + shot("int-cutaway.png", (4.5, -1.5, 11.0), (7.2, 4.2, 1.0)) + shot("int-cutaway-2.png", (13.5, 11.0, 9.0), (7.2, 4.2, 1.0)) + for o in bpy.data.objects: + if o.name.startswith("ceiling_") or o.name.startswith("ceiling_lamp_"): + o.hide_render = False + + for rid, fname in (): + poly = ROOMS_PX[rid] + # точка внутри комнаты, максимально далёкая от стен + def inside(px, py): + c = False + j = len(poly) - 1 + for i in range(len(poly)): + xi, yi = poly[i] + xj, yj = poly[j] + if ((yi > py) != (yj > py)) and (px < (xj - xi) * (py - yi) / (yj - yi + 1e-9) + xi): + c = not c + j = i + return c + + xs = [p[0] for p in poly] + ys = [p[1] for p in poly] + best, bx, by = -1.0, sum(xs) / len(xs), sum(ys) / len(ys) + step = 0.15 + yy = min(ys) + step + while yy < max(ys): + xx = min(xs) + step + while xx < max(xs): + if inside(xx, yy): + d = min(min(abs(xx - q[0]), abs(yy - q[1])) for q in poly) + d2 = min(((xx - q[0]) ** 2 + (yy - q[1]) ** 2) ** 0.5 for q in poly) + if d2 > best: + best, bx, by = d2, xx, yy + xx += step + yy += step + + far = max(poly, key=lambda q: (q[0] - bx) ** 2 + (q[1] - by) ** 2) + loc = (bx, by, Z0 + 1.65) + tgt = (far[0], far[1], Z0 + 1.05) + bpy.ops.object.light_add(type="AREA", location=(cx, cy, Z0 + 2.3)) + fl = bpy.context.object + fl.data.energy = 900 + fl.data.size = 3.0 + shot(fname, loc, tgt) + + # ---------- UV для текстур интерьера ---------- + uv_map = {"FloorWood": 1.2, "FloorTile": 1.0, "WallLight": 1.5, + "WallGreen": 0.9, "TileDark": 0.8} + bpy.ops.object.select_all(action="DESELECT") + for o in bpy.data.objects: + if o.type != "MESH" or not o.data.materials: + continue + size = uv_map.get(o.data.materials[0].name) + if size is None: + continue + o.select_set(True) + bpy.context.view_layer.objects.active = o + bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_all(action="SELECT") + bpy.ops.uv.cube_project(cube_size=size) + bpy.ops.object.mode_set(mode="OBJECT") + o.select_set(False) + + # ---------- добавляем экстерьер ---------- + ext = os.path.join(OUT, "house.glb") + if os.path.exists(ext): + bpy.ops.import_scene.gltf(filepath=ext) + print("внешний GLB добавлен", flush=True) + + # ---------- экспорт ---------- + bpy.ops.object.select_all(action="SELECT") + glb = os.path.join(OUT, "house-interior.glb") + bpy.ops.export_scene.gltf(filepath=glb, export_format="GLB", export_apply=True, + use_selection=True, export_yup=True) + print("glb:", os.path.getsize(glb), flush=True) + print("done") + + +if __name__ == "__main__": + main() diff --git a/ops/home/plans/int-bath.png b/ops/home/plans/int-bath.png index b80e28e..9260439 100644 Binary files a/ops/home/plans/int-bath.png and b/ops/home/plans/int-bath.png differ diff --git a/ops/home/plans/int-cutaway-2.png b/ops/home/plans/int-cutaway-2.png new file mode 100644 index 0000000..fc51f38 Binary files /dev/null and b/ops/home/plans/int-cutaway-2.png differ diff --git a/ops/home/plans/int-cutaway.png b/ops/home/plans/int-cutaway.png new file mode 100644 index 0000000..da35c61 Binary files /dev/null and b/ops/home/plans/int-cutaway.png differ diff --git a/ops/home/plans/int-danina.png b/ops/home/plans/int-danina.png index cfb1601..e2ff567 100644 Binary files a/ops/home/plans/int-danina.png and b/ops/home/plans/int-danina.png differ diff --git a/ops/home/plans/int-hall.png b/ops/home/plans/int-hall.png index 8a31358..41f2297 100644 Binary files a/ops/home/plans/int-hall.png and b/ops/home/plans/int-hall.png differ diff --git a/ops/home/plans/int-kitchen.png b/ops/home/plans/int-kitchen.png index 87b55de..057278e 100644 Binary files a/ops/home/plans/int-kitchen.png and b/ops/home/plans/int-kitchen.png differ diff --git a/ops/home/plans/int-office.png b/ops/home/plans/int-office.png index c78d858..ef2dc74 100644 Binary files a/ops/home/plans/int-office.png and b/ops/home/plans/int-office.png differ diff --git a/ops/home/plans/int-spalnya.png b/ops/home/plans/int-spalnya.png index 0c26355..c532e1b 100644 Binary files a/ops/home/plans/int-spalnya.png and b/ops/home/plans/int-spalnya.png differ diff --git a/ops/home/plans/tex_int_floor.png b/ops/home/plans/tex_int_floor.png new file mode 100644 index 0000000..dc208c7 Binary files /dev/null and b/ops/home/plans/tex_int_floor.png differ diff --git a/ops/home/plans/tex_int_green.png b/ops/home/plans/tex_int_green.png new file mode 100644 index 0000000..677a868 Binary files /dev/null and b/ops/home/plans/tex_int_green.png differ diff --git a/ops/home/plans/tex_int_tile.png b/ops/home/plans/tex_int_tile.png new file mode 100644 index 0000000..edd2e1e Binary files /dev/null and b/ops/home/plans/tex_int_tile.png differ diff --git a/ops/home/plans/tex_int_wall.png b/ops/home/plans/tex_int_wall.png new file mode 100644 index 0000000..3bd85f3 Binary files /dev/null and b/ops/home/plans/tex_int_wall.png differ