[HOME] Модель дома v8: терраса на торце, ЖБ сваи, вход с козырьком, тех.пом.; исправлен баг размера куба
lint / hygiene (push) Successful in 21s

This commit is contained in:
root committed 2026-10-31 01:33:10 +03:00
1 parent 08284a23d5
commit 67e2150b20
15 files changed
+594

No files matched your search

+19
View File
@@ -84,3 +84,22 @@
Что осталось отполировать: фактура металла «шумит» (bump слишком резкий),
крыльцо и ограждение террасы — черновые, окна без рам.
## v8 — модель пересобрана по фотографиям (31.10.2026)
Владелец прислал 9 фото фасадов; выяснилось, что в первых версиях было неверно:
| Было | Стало (по фото) |
|---|---|
| терраса вдоль длинной стороны | **терраса на западном торце**, под продолжением ската |
| бетонные сваи-цилиндры крупные | **ЖБ сваи** 150×150 (34 шт), цоколь не зашит |
| вход на торце | **вход с козырьком и ступенями на южной стороне** |
| пристройка сбоку | **тех.пом. с восточного торца**, своя кровля |
| фасад «шумный» серый | тёмный графит с вертикальной полосой (RAL 7024) |
**Главная ловушка**: `primitive_cube_add(size=1)` + `scale = полуразмер` даёт
куб ВДВОЕ меньше — из-за этого вся модель «разваливалась» на плиты.
Правильно: `size=2` (тогда `scale` — полуразмер).
Файлы: `house_scene6.py`, `house.glb` (244 КБ), карта `/local/house3d/house3d-card.js?v=8`.
Фото фасадов: `ops/home/plans/photos/facade-*.jpg`.
Binary file not shown.
+296
View File
@@ -0,0 +1,296 @@
# -*- coding: utf-8 -*-
"""Дом «Барнева» по фотографиям владельца — Blender v5.
Что исправлено против v4:
• терраса — на ТОРЦЕ (запад), под продолжением скатной кровли,
во всю ширину 8,5 м, с двумя деревянными стойками и ступенями по центру;
• дом стоит на ДЕРЕВЯННЫХ сваях (тонкие столбы по всему периметру);
• вход с козырьком и ступенями — на длинной (южной) стороне;
• пристройка (тех.пом.) — с восточного торца, со своей кровлей;
• окна: на торце 3 нижних (2 окна + дверь) и 3 верхних трапециевидных
в фронтоне; на длинной стороне — 4 окна.
Запуск: blender -b -P house_scene5.py
"""
import math
import os
import bpy
from mathutils import Vector
OUT = os.path.dirname(os.path.abspath(__file__))
# ось X — длинная (12,1), ось Y — ширина (8,5), Z — вверх
L, W = 12.10, 8.50
TER_D = 2.40
Z0, WALL_H = 0.80, 2.75
Z1 = Z0 + WALL_H
ROOF_H = 1.80
ZR = Z1 + ROOF_H
T = 0.18
OVER = 0.40
Y_MID = W / 2
def lin(c):
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
def col(h, a=1.0):
h = h.lstrip("#")
r, g, b = (int(h[i:i + 2], 16) / 255 for i in (0, 2, 4))
return (lin(r), lin(g), lin(b), a)
def new_mat(name, hexv, rough=0.6, metal=0.0, glass=False, bump_axis=None, bump_scale=1.0, bump_str=0.25):
m = bpy.data.materials.new(name)
m.use_nodes = True
nt = m.node_tree
b = nt.nodes["Principled BSDF"]
b.inputs["Base Color"].default_value = col(hexv)
b.inputs["Roughness"].default_value = rough
b.inputs["Metallic"].default_value = metal
if glass:
b.inputs["Transmission Weight"].default_value = 0.95
b.inputs["Roughness"].default_value = 0.03
b.inputs["IOR"].default_value = 1.45
b.inputs["Base Color"].default_value = col("0B1418")
if bump_axis:
tex = nt.nodes.new("ShaderNodeTexWave")
tex.wave_type = "BANDS"
tex.bands_direction = bump_axis
tex.inputs["Scale"].default_value = bump_scale
tex.inputs["Distortion"].default_value = 0.4
bmp = nt.nodes.new("ShaderNodeBump")
bmp.inputs["Strength"].default_value = bump_str
nt.links.new(tex.outputs["Color"], bmp.inputs["Height"])
nt.links.new(bmp.outputs["Normal"], b.inputs["Normal"])
return m
def box(name, x0, x1, y0, y1, z0, z1, mat):
bpy.ops.mesh.primitive_cube_add(size=1)
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(mat)
return o
def cut(obj, args):
x0, x1, y0, y1, z0, z1 = args
c = box("cutter", x0, x1, y0, y1, z0, z1, obj.data.materials[0])
m = obj.modifiers.new("b", "BOOLEAN")
m.operation = "DIFFERENCE"
m.object = c
m.solver = "EXACT"
bpy.context.view_layer.objects.active = obj
bpy.ops.object.modifier_apply(modifier=m.name)
bpy.data.objects.remove(c, do_unlink=True)
def gable(name, x, y0, y1, zb, zt, th, mat):
v = [(x, y0, zb), (x, y1, zb), (x, (y0 + y1) / 2, zt),
(x + th, y0, zb), (x + th, y1, zb), (x + th, (y0 + y1) / 2, zt)]
f = [(0, 1, 2), (5, 4, 3), (0, 3, 4, 1), (1, 4, 5, 2), (2, 5, 3, 0)]
me = bpy.data.meshes.new(name)
me.from_pydata(v, [], f)
me.update()
o = bpy.data.objects.new(name, me)
bpy.context.collection.objects.link(o)
o.data.materials.append(mat)
return o
def slab(name, pts, mat, thick=0.12):
me = bpy.data.meshes.new(name)
me.from_pydata(pts, [], [(0, 1, 2, 3)])
me.update()
o = bpy.data.objects.new(name, me)
bpy.context.collection.objects.link(o)
o.data.materials.append(mat)
s = o.modifiers.new("sol", "SOLIDIFY")
s.thickness = thick
return o
def main():
bpy.ops.wm.read_factory_settings(use_empty=True)
sc = bpy.context.scene
metal = new_mat("RAL7024", "3A3E42", 0.42, 0.35, bump_axis="Z", bump_scale=30, bump_str=0.5)
wood = new_mat("Olenenok", "C6A275", 0.62, 0.0, bump_axis="Z", bump_scale=26, bump_str=0.45)
deck = new_mat("DeckWood", "A9895F", 0.7, 0.0, bump_axis="X", bump_scale=22, bump_str=0.4)
rail = new_mat("RailWood", "B08D60", 0.68, 0.0, bump_axis="X", bump_scale=18, bump_str=0.35)
roofm = new_mat("Roof", "24272B", 0.5, 0.15, bump_axis="Y", bump_scale=14, bump_str=0.3)
glass = new_mat("Glass", "0B1418", glass=True)
trim = new_mat("Trim", "26292D", 0.55, 0.15)
pile = new_mat("PileConcrete", "B7B2A6", 0.88)
ground = new_mat("Ground", "6E6656", 0.95, bump_axis="Z", bump_scale=80, bump_str=0.2)
# ---------- деревянные сваи ----------
# ЖБ сваи 150x150 (по плану фундамента — 34 шт)
coords = []
x = 0.5
while x <= L - 0.4:
coords += [(x, 0.4), (x, W - 0.4)]
x += 1.5
for y in (2.5, 4.25, 6.0):
coords += [(0.45, y), (L - 0.45, y)]
for (px, py) in coords:
bpy.ops.mesh.primitive_cylinder_add(radius=0.075, depth=Z0, location=(px, py, Z0 / 2))
bpy.context.object.name = "pile_%d_%d" % (int(px * 100), int(py * 100))
bpy.context.object.data.materials.append(pile)
# ---------- пол ----------
box("floor", -0.05, L + 0.05, -0.05, W + 0.05, Z0 - 0.22, Z0, trim)
# ---------- стены ----------
south = box("wall_south", 0, L, 0, T, Z0, Z1, metal)
for (a, b) in [(2.0, 3.2), (5.0, 6.4), (8.2, 9.4)]:
cut(south, (a, b, -0.1, T + 0.1, Z0 + 1.0, Z0 + 2.2))
north = box("wall_north", 0, L, W - T, W, Z0, Z1, metal)
for (a, b) in [(1.6, 2.9), (4.6, 6.0), (7.8, 9.2)]:
cut(north, (a, b, W - T - 0.1, W + 0.1, Z0 + 1.0, Z0 + 2.2))
# западный торец — открытая терраса (стены нет, только фронтон)
east = box("wall_east", L - T, L, T, W - T, Z0, Z1, wood)
# фронтон западный (над террасой) и восточный
gw = gable("gable_west", 0.0, 0.0, W, Z1, ZR, T, wood)
cut(gw, (-0.1, T + 0.1, 2.9, 5.6, Z1 + 0.15, Z1 + 0.95))
ge = gable("gable_east", L - T, 0.0, W, Z1, ZR, T, wood)
# ---------- окна ----------
for (a, b) in [(2.0, 3.2), (5.0, 6.4), (8.2, 9.4)]:
box("sg_%d" % int(a * 100), a + 0.03, b - 0.03, T * 0.35, T * 0.65, Z0 + 1.03, Z0 + 2.17, glass)
for (a, b) in [(1.6, 2.9), (4.6, 6.0), (7.8, 9.2)]:
box("ng_%d" % int(a * 100), a + 0.03, b - 0.03, W - T * 0.65, W - T * 0.35, Z0 + 1.03, Z0 + 2.17, glass)
box("gw_glass", T * 0.35, T * 0.65, 2.93, 5.57, Z1 + 0.18, Z1 + 0.92, glass)
# торцевые окна/двери террасы (в стене под фронтоном)
terr = box("wall_west_lower", 0.0, T, 0.0, W, Z0, Z1, wood)
for (a, b) in [(1.2, 3.3), (4.9, 7.3)]:
cut(terr, (-0.1, T + 0.1, a, b, Z0 + 0.05, Z0 + 2.25))
cut(terr, (-0.1, T + 0.1, 3.55, 4.65, Z0 + 0.02, Z0 + 2.3)) # дверь по центру
box("tw_g1", T * 0.35, T * 0.65, 1.23, 3.27, Z0 + 0.08, Z0 + 2.22, glass)
box("tw_g2", T * 0.35, T * 0.65, 4.93, 7.27, Z0 + 0.08, Z0 + 2.22, glass)
box("door_mid", T * 0.3, T * 0.7, 3.58, 4.62, Z0 + 0.04, Z0 + 2.26, trim)
# верхние трапециевидные окна фронтона (3 шт) — плоскостями
for (a, b) in [(1.0, 3.1), (3.7, 4.9), (5.5, 7.5)]:
box("gw_top_%d" % int(a * 100), -0.02, 0.03, a, b, Z1 + 0.2, Z1 + 0.62, glass)
# ---------- кровля: двускатная + продолжение над террасой ----------
# скаты идут от конька (y=Y_MID) к югу и северу, по X от -TER_D до L+OVER
slab("roof_south", [(-TER_D - OVER, -OVER, Z1), (L + OVER, -OVER, Z1),
(L + OVER, Y_MID, ZR), (-TER_D - OVER, Y_MID, ZR)], roofm, 0.14)
slab("roof_north", [(-TER_D - OVER, W + OVER, Z1), (L + OVER, W + OVER, Z1),
(L + OVER, Y_MID, ZR), (-TER_D - OVER, Y_MID, ZR)], roofm, 0.14)
# лобовые доски
box("fascia_w", -TER_D - OVER - 0.02, -TER_D - OVER + 0.08, -OVER, W + OVER, Z1 - 0.2, Z1 + 0.02, trim)
box("fascia_e", L + OVER - 0.08, L + OVER + 0.02, -OVER, W + OVER, Z1 - 0.2, Z1 + 0.02, trim)
box("ridge", -TER_D - OVER, L + OVER, Y_MID - 0.09, Y_MID + 0.09, ZR - 0.05, ZR + 0.05, trim)
# стойки террасы (2 шт) и балка
for y in (0.55, W - 0.55):
box("terr_post_%d" % int(y * 10), -TER_D + 0.25, -TER_D + 0.45, y - 0.1, y + 0.1, Z0 - 0.05, Z1, rail)
box("terr_beam", -TER_D + 0.2, -TER_D + 0.5, 0.4, W - 0.4, Z1 - 0.16, Z1 - 0.02, rail)
# ---------- терраса: настил, ограждение, ступени ----------
box("deck", -TER_D, 0.0, 0.0, W, Z0 - 0.28, Z0 - 0.02, deck)
n = 26
for i in range(n):
y0 = i * (W / n)
box("plank_%02d" % i, -TER_D + 0.02, -0.03, y0 + 0.012, y0 + (W / n) - 0.024,
Z0 - 0.02, Z0 + 0.03, deck)
# ограждение по западному краю и по бокам (в две перекладины, как на фото)
for zh in (Z0 + 0.55, Z0 + 0.95):
box("rail_front_%d" % int(zh * 100), -TER_D + 0.08, -TER_D + 0.16, 0.08, 3.4, zh, zh + 0.09, rail)
box("rail_front2_%d" % int(zh * 100), -TER_D + 0.08, -TER_D + 0.16, 5.1, W - 0.08, zh, zh + 0.09, rail)
for y in (0.08, W - 0.08):
for zh in (Z0 + 0.55, Z0 + 0.95):
box("rail_side_%d_%d" % (int(y * 100), int(zh * 100)), -TER_D + 0.08, -0.05, y - 0.04, y + 0.04, zh, zh + 0.09, rail)
for x in (-TER_D + 0.1, -1.2):
for y in (0.08, W - 0.08):
box("rpost_%d_%d" % (int(-x * 10), int(y * 10)), x - 0.05, x + 0.05, y - 0.05, y + 0.05, Z0, Z1 - 0.3, rail)
# ступени по центру
for i in range(4):
y = W / 2 - 1.0 + 0.0
box("step_%d" % i, -TER_D - 0.34 * (i + 1), -TER_D - 0.34 * i + 0.02,
2.6, W / 2 + 1.4, 0.02, Z0 - 0.16 * i, deck)
# ---------- вход с козырьком (длинная сторона) ----------
box("entry_door", 3.6, 4.6, -0.02, T + 0.02, Z0 + 0.02, Z0 + 2.15, trim)
box("canopy", 3.3, 4.9, -1.15, 0.05, Z1 - 0.35, Z1 - 0.22, roofm)
box("canopy_post_l", 3.35, 3.45, -1.10, -1.0, Z0 - 0.05, Z1 - 0.35, rail)
box("canopy_post_r", 4.75, 4.85, -1.10, -1.0, Z0 - 0.05, Z1 - 0.35, rail)
for i in range(3):
box("entry_step_%d" % i, 3.6, 4.6, -0.36 * (i + 1) - 0.9, -0.36 * i - 0.9, 0.02, Z0 - 0.18 * i, deck)
# ---------- пристройка (тех.пом.) с востока ----------
box("tech", L, L + 2.10, 0.0, 2.30, Z0, Z1 - 0.45, metal)
slab("tech_roof", [(L - 0.05, -0.12, Z1 - 0.45), (L + 2.2, -0.12, Z1 - 0.45),
(L + 2.2, 2.42, Z1 - 0.18), (L - 0.05, 2.42, Z1 - 0.18)], roofm, 0.1)
box("tech_door", L + 0.9, L + 1.7, -0.03, 0.02, Z0 + 0.02, Z0 + 2.0, trim)
box("tech_deck", L + 0.2, L + 2.0, -1.2, 0.0, Z0 - 0.28, Z0 - 0.03, deck)
# ---------- земля ----------
bpy.ops.mesh.primitive_plane_add(size=180, location=(L / 2, W / 2, -0.02))
bpy.context.object.data.materials.append(ground)
# ---------- небо и свет ----------
w = bpy.data.worlds.new("World")
sc.world = w
w.use_nodes = True
nt = w.node_tree
sky = nt.nodes.new("ShaderNodeTexSky")
sky.sky_type = "NISHITA"
sky.sun_elevation = math.radians(30)
sky.sun_rotation = math.radians(200)
bg = nt.nodes["Background"]
nt.links.new(sky.outputs["Color"], bg.inputs["Color"])
bg.inputs["Strength"].default_value = 0.32
bpy.ops.object.light_add(type="SUN", location=(-16, -20, 26))
sun = bpy.context.object
sun.data.energy = 3.4
sun.data.angle = math.radians(1.5)
sun.rotation_euler = (math.radians(56), 0, math.radians(34))
# ---------- камера и рендер ----------
cd = bpy.data.cameras.new("Cam")
cd.lens = 40
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 = 64
sc.cycles.use_denoising = False
sc.cycles.max_bounces = 5
sc.render.resolution_x, sc.render.resolution_y = 1000, 620
sc.view_settings.view_transform = "AgX"
sc.view_settings.exposure = -1.05
def shot(name, loc, target):
cam.location = loc
cam.rotation_euler = (Vector(target) - 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)
shot("render-front.png", (-9.0, -11.0, 5.2), (L / 2, W / 2, 1.8))
shot("render-side.png", (L + 10.0, -9.0, 5.0), (L / 2 + 1.0, W / 2 - 0.5, 1.8))
bpy.ops.object.select_all(action="SELECT")
glb = os.path.join(OUT, "house.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()
+279
View File
@@ -0,0 +1,279 @@
# -*- coding: utf-8 -*-
"""Дом «Барнева» — Blender v6: чистая сборка по фотографиям.
Ключевое: терраса на западном торце под продолжением кровли, ЖБ сваи,
вход с козырьком на южной стороне, пристройка с востока. Все проёмы
застеклены, чтобы объём читался цельным.
blender -b -P house_scene6.py
"""
import math
import os
import bpy
from mathutils import Vector
OUT = os.path.dirname(os.path.abspath(__file__))
L, W = 12.10, 8.50
TER_D = 2.40
Z0 = 0.80
WALL_H = 2.75
Z1 = Z0 + WALL_H
ROOF_H = 1.80
ZR = Z1 + ROOF_H
T = 0.20
OVER = 0.35
YM = W / 2
def lin(c):
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
def col(h, a=1.0):
h = h.lstrip("#")
r, g, b = (int(h[i:i + 2], 16) / 255 for i in (0, 2, 4))
return (lin(r), lin(g), lin(b), a)
def mat(name, hexv, rough=0.6, metal=0.0, glass=False, stripes=None, scale=25.0, strength=0.35):
m = bpy.data.materials.new(name)
m.use_nodes = True
nt = m.node_tree
b = nt.nodes["Principled BSDF"]
b.inputs["Base Color"].default_value = col(hexv)
b.inputs["Roughness"].default_value = rough
b.inputs["Metallic"].default_value = metal
if glass:
b.inputs["Transmission Weight"].default_value = 0.9
b.inputs["Roughness"].default_value = 0.05
b.inputs["IOR"].default_value = 1.45
b.inputs["Base Color"].default_value = col("0D171C")
if stripes:
tex = nt.nodes.new("ShaderNodeTexWave")
tex.wave_type = "BANDS"
tex.bands_direction = stripes
tex.inputs["Scale"].default_value = scale
tex.inputs["Distortion"].default_value = 0.0
bmp = nt.nodes.new("ShaderNodeBump")
bmp.inputs["Strength"].default_value = strength
nt.links.new(tex.outputs["Color"], bmp.inputs["Height"])
nt.links.new(bmp.outputs["Normal"], b.inputs["Normal"])
return m
def box(name, x0, x1, y0, y1, z0, z1, m):
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)
return o
def cut(obj, args):
x0, x1, y0, y1, z0, z1 = args
c = box("cut", x0, x1, y0, y1, z0, z1, obj.data.materials[0])
mod = obj.modifiers.new("b", "BOOLEAN")
mod.operation = "DIFFERENCE"
mod.object = c
mod.solver = "EXACT"
bpy.context.view_layer.objects.active = obj
bpy.ops.object.modifier_apply(modifier=mod.name)
bpy.data.objects.remove(c, do_unlink=True)
def gable(name, x, y0, y1, zb, zt, th, m):
v = [(x, y0, zb), (x, y1, zb), (x, (y0 + y1) / 2, zt),
(x + th, y0, zb), (x + th, y1, zb), (x + th, (y0 + y1) / 2, zt)]
f = [(0, 1, 2), (5, 4, 3), (0, 3, 4, 1), (1, 4, 5, 2), (2, 5, 3, 0)]
me = bpy.data.meshes.new(name)
me.from_pydata(v, [], f)
me.update()
o = bpy.data.objects.new(name, me)
bpy.context.collection.objects.link(o)
o.data.materials.append(m)
return o
def slab(name, pts, m, th=0.14):
me = bpy.data.meshes.new(name)
me.from_pydata(pts, [], [(0, 1, 2, 3)])
me.update()
o = bpy.data.objects.new(name, me)
bpy.context.collection.objects.link(o)
o.data.materials.append(m)
s = o.modifiers.new("s", "SOLIDIFY")
s.thickness = th
return o
def main():
bpy.ops.wm.read_factory_settings(use_empty=True)
sc = bpy.context.scene
metal = mat("RAL7024", "2B2F33", 0.5, 0.25, stripes="X", scale=14, strength=0.35)
wood = mat("Olenenok", "C7A47A", 0.65, 0.0, stripes="X", scale=16, strength=0.3)
deckm = mat("Deck", "B08C5E", 0.7, 0.0, stripes="X", scale=20, strength=0.4)
railm = mat("Rail", "C09A6B", 0.7, 0.0)
roofm = mat("Roof", "23262A", 0.5, 0.15, stripes="Y", scale=12, strength=0.25)
glass = mat("Glass", "0D171C", glass=True)
trim = mat("Trim", "26292D", 0.55, 0.2)
pilem = mat("Concrete", "B7B2A6", 0.9)
ground = mat("Ground", "6F6757", 0.95, stripes="Z", scale=70, strength=0.2)
# сваи ЖБ 150×150
xs = [0.5 + i * 1.45 for i in range(int((L - 1.0) / 1.45) + 1)]
for x in xs:
for y in (0.4, W - 0.4):
bpy.ops.mesh.primitive_cylinder_add(radius=0.075, depth=Z0, location=(x, y, Z0 / 2))
bpy.context.object.data.materials.append(pilem)
for y in (2.6, 4.25, 5.9):
for x in (0.45, L - 0.45):
bpy.ops.mesh.primitive_cylinder_add(radius=0.075, depth=Z0, location=(x, y, Z0 / 2))
bpy.context.object.data.materials.append(pilem)
box("floor", -0.03, L + 0.03, -0.03, W + 0.03, Z0 - 0.20, Z0, trim)
box("ceiling", -0.02, L + 0.02, -0.02, W + 0.02, Z1 - 0.03, Z1, trim)
# стены
south = box("w_south", 0, L, 0, T, Z0, Z1, metal)
for (a, b) in [(1.4, 2.6), (5.2, 6.4), (8.6, 9.8)]:
cut(south, (a, b, -0.1, T + 0.1, Z0 + 1.0, Z0 + 2.2))
cut(south, (3.60, 4.60, -0.1, T + 0.1, Z0, Z0 + 2.15)) # вход
north = box("w_north", 0, L, W - T, W, Z0, Z1, metal)
for (a, b) in [(1.8, 3.0), (4.8, 6.0), (7.8, 9.0)]:
cut(north, (a, b, W - T - 0.1, W + 0.1, Z0 + 1.0, Z0 + 2.2))
east = box("w_east", L - T, L, T, W - T, Z0, Z1, wood)
for (a, b) in [(2.4, 4.0), (5.0, 6.6)]:
cut(east, (L - T - 0.1, L + 0.1, a, b, Z0 + 1.0, Z0 + 2.2))
# западный торец: стена с панорамным остеклением и дверью
west = box("w_west", 0, T, 0, W, Z0, Z1, wood)
cut(west, (-0.1, T + 0.1, 0.9, 3.3, Z0 + 0.1, Z0 + 2.25))
cut(west, (-0.1, T + 0.1, 4.75, 7.5, Z0 + 0.1, Z0 + 2.25))
cut(west, (-0.1, T + 0.1, 3.55, 4.55, Z0, Z0 + 2.30))
# фронтоны
gw = gable("g_west", 0.0, 0.0, W, Z1, ZR, T, wood)
cut(gw, (-0.1, T + 0.1, 0.8, 7.6, Z1 + 0.12, Z1 + 0.85))
ge = gable("g_east", L - T, 0.0, W, Z1, ZR, T, wood)
# стекло в проёмах
for (a, b) in [(1.4, 2.6), (5.2, 6.4), (8.6, 9.8)]:
box("gs_%d" % int(a * 100), a + 0.02, b - 0.02, T * 0.3, T * 0.7, Z0 + 1.02, Z0 + 2.18, glass)
for (a, b) in [(1.8, 3.0), (4.8, 6.0), (7.8, 9.0)]:
box("gn_%d" % int(a * 100), a + 0.02, b - 0.02, W - T * 0.7, W - T * 0.3, Z0 + 1.02, Z0 + 2.18, glass)
for (a, b) in [(2.4, 4.0), (5.0, 6.6)]:
box("ge_%d" % int(a * 100), L - T * 0.7, L - T * 0.3, a + 0.02, b - 0.02, Z0 + 1.02, Z0 + 2.18, glass)
box("gw_glass", T * 0.3, T * 0.7, 0.95, 3.25, Z0 + 0.12, Z0 + 2.23, glass)
box("gw_glass2", T * 0.3, T * 0.7, 4.80, 7.45, Z0 + 0.12, Z0 + 2.23, glass)
box("gw_top", T * 0.3, T * 0.7, 0.85, 7.55, Z1 + 0.15, Z1 + 0.82, glass)
box("door_w", T * 0.25, T * 0.75, 3.58, 4.52, Z0 + 0.02, Z0 + 2.26, trim)
# дверь входа + козырёк + ступени
box("door_s", 3.62, 4.58, -0.04, T * 0.8, Z0 + 0.02, Z0 + 2.13, trim)
box("canopy", 3.3, 4.9, -1.05, 0.02, Z1 - 0.36, Z1 - 0.24, roofm)
for x in (3.35, 4.8):
box("cpost_%d" % int(x * 10), x, x + 0.1, -1.0, -0.9, Z0 - 0.05, Z1 - 0.36, railm)
for i in range(3):
box("sstep_%d" % i, 3.62, 4.58, -1.12 - 0.34 * (i + 1), -1.12 - 0.34 * i, 0.02, Z0 - 0.2 * i, deckm)
# кровля: скаты от конька к югу/северу, продолжение над террасой
slab("r_south", [(-TER_D - OVER, -OVER, Z1), (L + OVER, -OVER, Z1),
(L + OVER, YM, ZR), (-TER_D - OVER, YM, ZR)], roofm)
slab("r_north", [(-TER_D - OVER, W + OVER, Z1), (L + OVER, W + OVER, Z1),
(L + OVER, YM, ZR), (-TER_D - OVER, YM, ZR)], roofm)
box("ridge", -TER_D - OVER, L + OVER, YM - 0.08, YM + 0.08, ZR - 0.05, ZR + 0.05, trim)
box("fascia_w", -TER_D - OVER - 0.02, -TER_D - OVER + 0.08, -OVER, W + OVER, Z1 - 0.18, Z1 + 0.02, trim)
box("fascia_e", L + OVER - 0.08, L + OVER + 0.02, -OVER, W + OVER, Z1 - 0.18, Z1 + 0.02, trim)
# терраса: настил, стойки, ограждение
box("deck", -TER_D, 0.0, 0.0, W, Z0 - 0.26, Z0 - 0.02, deckm)
for y in (0.55, W - 0.55):
box("tpost_%d" % int(y * 10), -TER_D + 0.3, -TER_D + 0.5, y - 0.1, y + 0.1, Z0 - 0.02, Z1 - 0.02, railm)
box("tbeam", -TER_D + 0.28, -TER_D + 0.52, 0.4, W - 0.4, Z1 - 0.18, Z1 - 0.04, railm)
for zh in (Z0 + 0.52, Z0 + 0.92):
box("rail_w_%d" % int(zh * 100), -TER_D + 0.06, -TER_D + 0.16, 0.06, 3.35, zh, zh + 0.10, railm)
box("rail_w2_%d" % int(zh * 100), -TER_D + 0.06, -TER_D + 0.16, 5.15, W - 0.06, zh, zh + 0.10, railm)
for y in (0.06, W - 0.06):
box("rail_s_%d_%d" % (int(y * 100), int(zh * 100)), -TER_D + 0.06, -0.02, y - 0.05, y + 0.05, zh, zh + 0.10, railm)
for i in range(4):
box("tstep_%d" % i, -TER_D - 0.32 * (i + 1), -TER_D - 0.32 * i, 2.7, 5.8, 0.02, Z0 - 0.18 * i, deckm)
# пристройка (тех.пом.) с востока
box("tech", L, L + 2.05, 0.0, 2.30, Z0, Z1 - 0.5, metal)
slab("tech_roof", [(L - 0.05, -0.10, Z1 - 0.5), (L + 2.15, -0.10, Z1 - 0.5),
(L + 2.15, 2.40, Z1 - 0.22), (L - 0.05, 2.40, Z1 - 0.22)], roofm, 0.1)
box("tech_door", L + 0.85, L + 1.65, -0.03, 0.03, Z0 + 0.02, Z0 + 2.0, trim)
# земля
bpy.ops.mesh.primitive_plane_add(size=200, location=(L / 2, W / 2, -0.02))
bpy.context.object.data.materials.append(ground)
# небо
w = bpy.data.worlds.new("World")
sc.world = w
w.use_nodes = True
nt = w.node_tree
sky = nt.nodes.new("ShaderNodeTexSky")
sky.sky_type = "NISHITA"
sky.sun_elevation = math.radians(32)
sky.sun_rotation = math.radians(195)
bg = nt.nodes["Background"]
nt.links.new(sky.outputs["Color"], bg.inputs["Color"])
bg.inputs["Strength"].default_value = 0.30
bpy.ops.object.light_add(type="SUN", location=(-22, -30, 26))
sun = bpy.context.object
sun.data.energy = 3.6
sun.data.angle = math.radians(3.0)
d = Vector((L / 2, W / 2, 0)) - sun.location
sun.rotation_euler = d.to_track_quat("-Z", "Y").to_euler()
# заполняющий свет с юго-запада, чтобы фасады не проваливались в чёрное
bpy.ops.object.light_add(type="AREA", location=(-8, -14, 8))
fill = bpy.context.object
fill.data.energy = 320
fill.data.size = 12
d2 = Vector((L / 2, W / 2, 2)) - fill.location
fill.rotation_euler = d2.to_track_quat("-Z", "Y").to_euler()
cd = bpy.data.cameras.new("Cam")
cd.lens = 45
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.cycles.max_bounces = 5
sc.render.resolution_x, sc.render.resolution_y = 900, 560
sc.view_settings.view_transform = "AgX"
sc.view_settings.exposure = -0.85
def shot(name, loc, target):
cam.location = loc
cam.rotation_euler = (Vector(target) - 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)
shot("render-front.png", (-10.5, -9.5, 4.6), (5.6, 4.2, 1.9))
shot("render-side.png", (L + 9.5, -9.0, 4.6), (6.2, 4.2, 1.9))
bpy.ops.object.select_all(action="SELECT")
glb = os.path.join(OUT, "house.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()
Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 683 KiB

After

Width:  |  Height:  |  Size: 912 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 KiB