Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mklemarczyk committed Aug 16, 2018
2 parents cd8ae32 + f7c9287 commit 5885941
Show file tree
Hide file tree
Showing 9 changed files with 887 additions and 83 deletions.
23 changes: 22 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"name": "Architecture Lab",
"author": "Insma Software - Maciej Klemarczyk (mklemarczyk)",
"location": "View3D > Add > Mesh > ArchLab",
"version": (1, 0, 9),
"version": (1, 1, 0),
"blender": (2, 7, 9),
"description": "Creates rooms, doors, windows, and other architecture objects",
"wiki_url": "https://github.com/insma/ArchitectureLab/wiki",
Expand All @@ -52,6 +52,8 @@
importlib.reload(archlab_bldn_wall_tool)
importlib.reload(archlab_dcrt_glass_tool)
importlib.reload(archlab_dcrt_plate_tool)
importlib.reload(archlab_frnt_bench_tool)
importlib.reload(archlab_frnt_shelve_tool)
importlib.reload(archlab_mesh_cube_tool)
importlib.reload(archlab_mesh_cube_tool)
importlib.reload(archlab_mesh_plane_tool)
Expand All @@ -64,6 +66,8 @@
from . import archlab_bldn_wall_tool
from . import archlab_dcrt_glass_tool
from . import archlab_dcrt_plate_tool
from . import archlab_frnt_bench_tool
from . import archlab_frnt_shelve_tool
from . import archlab_mesh_circle_tool
from . import archlab_mesh_cube_tool
from . import archlab_mesh_plane_tool
Expand All @@ -82,6 +86,10 @@
archlab_dcrt_glass_tool.ArchLabGlassGeneratorPanel,
archlab_dcrt_plate_tool.ArchLabPlate,
archlab_dcrt_plate_tool.ArchLabPlateGeneratorPanel,
archlab_frnt_bench_tool.ArchLabBench,
archlab_frnt_bench_tool.ArchLabBenchGeneratorPanel,
archlab_frnt_shelve_tool.ArchLabShelve,
archlab_frnt_shelve_tool.ArchLabShelveGeneratorPanel,
archlab_mesh_circle_tool.ArchLabCircle,
archlab_mesh_circle_tool.ArchLabCircleGeneratorPanel,
archlab_mesh_cube_tool.ArchLabCube,
Expand Down Expand Up @@ -116,6 +124,17 @@
)


# ----------------------------------------------------------
# Furnitures menu
# ----------------------------------------------------------
class ArchLabMeshFurnituresAdd(Menu):
bl_idname = "INFO_MT_archlab_mesh_furnitures_add"
bl_label = "Furnitures"

def draw(self, context):
self.layout.operator("mesh.archlab_bench", text="Add Bench")
self.layout.operator("mesh.archlab_shelve", text="Add Shelve")

# ----------------------------------------------------------
# Decorations menu
# ----------------------------------------------------------
Expand Down Expand Up @@ -156,9 +175,11 @@ def draw(self, context):
self.layout.separator()
self.layout.menu("INFO_MT_archlab_mesh_primitives_add", text="Primitives", icon="GROUP")
self.layout.menu("INFO_MT_archlab_mesh_decorations_add", text="Decorations", icon="GROUP")
self.layout.menu("INFO_MT_archlab_mesh_furnitures_add", text="Furnitures", icon="GROUP")

modules.extend([
ArchLabMeshCustomMenuAdd,
ArchLabMeshFurnituresAdd,
ArchLabMeshDecorationsAdd,
ArchLabMeshPrimitivesAdd
])
Expand Down
152 changes: 113 additions & 39 deletions archlab_bldn_room_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
# ----------------------------------------------------------
import bpy
from bpy.types import Operator, PropertyGroup, Object, Panel
from bpy.props import IntProperty, FloatProperty, CollectionProperty
from bpy.props import BoolProperty, IntProperty, FloatProperty, CollectionProperty
from math import sin
from .archlab_utils import *

# ------------------------------------------------------------------------------
Expand All @@ -46,10 +47,13 @@ def create_room(self, context):
roomobject.ArchLabRoomGenerator.add()

roomobject.ArchLabRoomGenerator[0].room_height = self.room_height
roomobject.ArchLabRoomGenerator[0].room_floor = self.room_floor
roomobject.ArchLabRoomGenerator[0].room_ceiling = self.room_ceiling
roomobject.ArchLabRoomGenerator[0].room_wall_count = self.room_wall_count
for wall in self.room_walls:
wallprop = roomobject.ArchLabRoomGenerator[0].room_walls.add()
wallprop.wall_width = wall.wall_width
wallprop.wall_depth = wall.wall_depth
wallprop.wall_angle = wall.wall_angle

# we shape the mesh.
Expand Down Expand Up @@ -77,27 +81,11 @@ def shape_room_mesh(myroom, tmp_mesh, update=False):
rp.room_walls.remove(prwc)

# Create room mesh data
update_room_mesh_data(tmp_mesh, rp.room_height, rp.room_walls)
update_room_mesh_data(tmp_mesh, rp.room_height, rp.room_walls, rp.room_floor, rp.room_ceiling)
myroom.data = tmp_mesh

remove_doubles(myroom)
set_normals(myroom)

if rp.room_wall_depth > 0.0:
if update is False or is_solidify(myroom) is False:
set_modifier_solidify(myroom, rp.room_wall_depth)
else:
for mod in myroom.modifiers:
if mod.type == 'SOLIDIFY':
mod.thickness = rp.room_wall_depth
mod.use_even_offset = True # The solidify have a problem with some wall angles
# Move to Top SOLIDIFY
movetotopsolidify(myroom)

else: # clear not used SOLIDIFY
for mod in myroom.modifiers:
if mod.type == 'SOLIDIFY':
myroom.modifiers.remove(mod)
#set_normals(myroom)

# deactivate others
for o in bpy.data.objects:
Expand All @@ -107,27 +95,87 @@ def shape_room_mesh(myroom, tmp_mesh, update=False):
# ------------------------------------------------------------------------------
# Creates room mesh data.
# ------------------------------------------------------------------------------
def update_room_mesh_data(mymesh, height, walls):
myvertices = []
def update_room_mesh_data(mymesh, height, walls, has_floor, has_ceiling):
myvertices = None
myfaces = []

if len(walls) > 0:
myvertices = [(0.0, 0.0, 0.0), (0.0, 0.0, height)]
lwalls = len(walls)
lastwi = 0
lastp = [0.0, 0.0, 0.0]
lastpnorm = [1.0, 0.0, 0.0]
lastdepth = 0
lastp = (0.0, 0.0, 0.0)
lastpnorm = (1.0, 0.0, 0.0)
for wall in walls:
pnorm = rotate_point3d_rad(lastpnorm, anglez=wall.wall_angle)
p1 = [
lastp[0] + pnorm[0] * wall.wall_width,
lastp[1] + pnorm[1] * wall.wall_width,
lastp[2] + pnorm[2] * wall.wall_width
]
myvertices.extend([(p1[0], p1[1], 0.0), (p1[0], p1[1], height)])
myfaces.append((lastwi * 2 + 0, lastwi * 2 + 1, lastwi * 2 + 3, lastwi * 2 + 2))
wdepth = wall.wall_depth /2
wdp = (-pnorm[1] * wdepth, pnorm[0] * wdepth, 0.0)
if myvertices is None: # First wall
myvertices = [
(-wdp[0], -wdp[1], 0.0),
(-wdp[0], -wdp[1], height),
( wdp[0], wdp[1], 0.0),
( wdp[0], wdp[1], height)
]
myfaces.extend([
[0, 1, 3, 2]
])
myfaces.extend([
[lastwi * 4 + 0, lastwi * 4 + 2, lastwi * 4 + 6, lastwi * 4 + 4], # bottom
[lastwi * 4 + 0, lastwi * 4 + 4, lastwi * 4 + 5, lastwi * 4 + 1], # outer
[lastwi * 4 + 1, lastwi * 4 + 5, lastwi * 4 + 7, lastwi * 4 + 3], # top
[lastwi * 4 + 2, lastwi * 4 + 3, lastwi * 4 + 7, lastwi * 4 + 6] # inner
])
else: # Wall not first
sinwa = sin(wall.wall_angle)
crosswdp = (wdp[0], wdp[1], 0.0)
if not sinwa == 0: # angle = 0
h1 = -lastpnorm * wdepth
h2 = pnorm * lastdepth
crosswdp = (h1 + h2) / sinwa
myvertices.extend([
(lastp[0]-crosswdp[0], lastp[1]-crosswdp[1], 0.0),
(lastp[0]-crosswdp[0], lastp[1]-crosswdp[1], height),
(lastp[0]+crosswdp[0], lastp[1]+crosswdp[1], 0.0),
(lastp[0]+crosswdp[0], lastp[1]+crosswdp[1], height)
])
myfaces.extend([
[lastwi * 4 + 0, lastwi * 4 + 2, lastwi * 4 + 6, lastwi * 4 + 4], # bottom
[lastwi * 4 + 0, lastwi * 4 + 4, lastwi * 4 + 5, lastwi * 4 + 1], # outer
[lastwi * 4 + 1, lastwi * 4 + 5, lastwi * 4 + 7, lastwi * 4 + 3], # top
[lastwi * 4 + 2, lastwi * 4 + 3, lastwi * 4 + 7, lastwi * 4 + 6] # inner
])
if lwalls == lastwi +1: #Last wall
myvertices.extend([
(p1[0]-wdp[0], p1[1]-wdp[1], 0.0),
(p1[0]-wdp[0], p1[1]-wdp[1], height),
(p1[0]+wdp[0], p1[1]+wdp[1], 0.0),
(p1[0]+wdp[0], p1[1]+wdp[1], height)
])
myfaces.extend([
[lastwi * 4 + 5, lastwi * 4 + 4, lastwi * 4 + 6, lastwi * 4 + 7]
])
lastwi = lastwi + 1
lastp = p1
lastpnorm = pnorm
lastp = p1
lastdepth = wdepth

if has_floor and lwalls > 1:
floorverts = []
for wno in range(lwalls):
floorverts.append(wno * 4 + 2)
floorverts.append(lwalls * 4 + 2)
myfaces.append(floorverts)

if has_ceiling and lwalls > 1:
ceilingverts = []
for wno in range(lwalls, 0, -1):
ceilingverts.append(wno * 4 + 3)
ceilingverts.append(0 * 4 + 3)
myfaces.append(ceilingverts)

mymesh.from_pydata(myvertices, [], myfaces)
mymesh.update(calc_edges=True)
Expand Down Expand Up @@ -202,10 +250,18 @@ def wall_width_property(callback=None):
description='Wall width', update=callback,
)

def wall_depth_property(callback=None):
return FloatProperty(
name='Thickness',
soft_min=0.001,
default=0.025, precision=4, unit = 'LENGTH',
description='Thickness of the walls', update=callback,
)

def wall_angle_property(callback=None):
return FloatProperty(
name='Angle',
soft_min=-3.14159, soft_max=3.14159,
soft_min=-2.79232, soft_max=2.79232,
default=3.14159/2, precision=3, step=50,
description='Angle of this wall with previous', update=callback,
subtype='ANGLE',
Expand All @@ -216,6 +272,7 @@ def wall_angle_property(callback=None):
# ------------------------------------------------------------------
class ArchLabWallProperties(PropertyGroup):
wall_width = wall_width_property(callback=update_room)
wall_depth = wall_depth_property(callback=update_room)
wall_angle = wall_angle_property(callback=update_room)

# -----------------------------------------------------
Expand All @@ -237,12 +294,18 @@ def room_wall_count_property(callback=None):
description='Number of walls in the room', update=callback,
)

def room_wall_depth_property(callback=None):
return FloatProperty(
name='Thickness',
soft_min=0.001,
default=0.025, precision=4, unit = 'LENGTH',
description='Thickness of the walls', update=callback,
def room_floor_property(callback=None):
return BoolProperty(
name='Floor',
default=True,
description='Generates floor for the room', update=callback,
)

def room_ceiling_property(callback=None):
return BoolProperty(
name='Ceiling',
default=False,
description='Generates ceiling for the room', update=callback,
)

def room_walls_property(callback=None):
Expand All @@ -253,8 +316,10 @@ def room_walls_property(callback=None):
# ------------------------------------------------------------------
class ArchLabRoomProperties(PropertyGroup):
room_height = room_height_property(callback=update_room)
room_floor = room_floor_property(callback=update_room)
room_ceiling = room_ceiling_property(callback=update_room)
room_wall_count = room_wall_count_property(callback=update_room)
room_wall_count = room_wall_count_property(callback=update_room)
room_wall_depth = room_wall_depth_property(callback=update_room)
room_walls = room_walls_property(callback=update_room)

bpy.utils.register_class(ArchLabWallProperties)
Expand Down Expand Up @@ -307,7 +372,9 @@ def draw(self, context):
row = layout.row()
row.prop(room, 'room_height')
row = layout.row()
row.prop(room, 'room_wall_depth')
row.prop(room, 'room_floor')
row = layout.row()
row.prop(room, 'room_ceiling')
row = layout.row()
row.prop(room, 'room_wall_count')
for wt in range(len(room.room_walls)):
Expand All @@ -316,6 +383,8 @@ def draw(self, context):
row = box.row()
row.prop(room.room_walls[wt], 'wall_width')
row = box.row()
row.prop(room.room_walls[wt], 'wall_depth')
row = box.row()
row.prop(room.room_walls[wt], 'wall_angle')

# ------------------------------------------------------------------
Expand All @@ -330,8 +399,9 @@ class ArchLabRoom(Operator):

# preset
room_height = room_height_property()
room_floor = room_floor_property(callback=update_room)
room_ceiling = room_ceiling_property(callback=update_room)
room_wall_count = room_wall_count_property()
room_wall_depth = room_wall_depth_property()
room_walls = CollectionProperty(type=ArchLabWallProperties)

# -----------------------------------------------------
Expand All @@ -344,7 +414,9 @@ def draw(self, context):
row = layout.row()
row.prop(self, 'room_height')
row = layout.row()
row.prop(self, 'room_wall_depth')
row.prop(self, 'room_floor')
row = layout.row()
row.prop(self, 'room_ceiling')
row = layout.row()
row.prop(self, 'room_wall_count')
for wt in range(len(self.room_walls)):
Expand All @@ -353,6 +425,8 @@ def draw(self, context):
row = box.row()
row.prop(self.room_walls[wt], 'wall_width')
row = box.row()
row.prop(self.room_walls[wt], 'wall_depth')
row = box.row()
row.prop(self.room_walls[wt], 'wall_angle')
else:
row = layout.row()
Expand Down
4 changes: 2 additions & 2 deletions archlab_bldn_wall_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ def draw(self, context):
layout = self.layout
space = bpy.context.space_data
if not space.local_view:
row = layout.row()
row.prop(self, 'wall_height')
row = layout.row()
row.prop(self, 'wall_width')
row = layout.row()
row.prop(self, 'wall_height')
row = layout.row()
row.prop(self, 'wall_depth')
else:
row = layout.row()
Expand Down
Loading

0 comments on commit 5885941

Please sign in to comment.