From 1ed5de77beaae39cf6d146e3bd7be87bec8629da Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 17 Jan 2022 15:06:40 -0500 Subject: [PATCH] Add townhouses Also update the add-on to allow for configuration of potrace's alpha settings, which controls how strongly it favors straight lines. This makes things like buildings look a lot nicer. --- media/attribution.js | 7 + .../Three Story Townhouse-Angled.svg | 273 ++++++++++++++++ .../Three Story Townhouse-Back Corner.svg | 165 ++++++++++ .../Townhouses/Three Story Townhouse-Back.svg | 96 ++++++ .../Three Story Townhouse-Corner.svg | 309 ++++++++++++++++++ .../Three Story Townhouse-Front.svg | 210 ++++++++++++ .../Townhouses/Three Story Townhouse-Side.svg | 117 +++++++ .../Townhouses/Three Story Townhouse-Top.svg | 126 +++++++ presets/buildings.js | 1 + scripts/blender/addons/macrovision/ops.py | 21 +- scripts/blender/addons/macrovision/props.py | 10 + scripts/blender/addons/macrovision/ui.py | 1 + scripts/process-model.py | 12 +- 13 files changed, 1339 insertions(+), 9 deletions(-) create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Angled.svg create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Back Corner.svg create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Back.svg create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Corner.svg create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Front.svg create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Side.svg create mode 100644 media/buildings/Townhouses/Three Story Townhouse-Top.svg diff --git a/media/attribution.js b/media/attribution.js index ee25c50a..adddcbd5 100644 --- a/media/attribution.js +++ b/media/attribution.js @@ -1353,6 +1353,13 @@ const attributionData = { "https://www.timessquarenyc.org/times-square-new-years-eve/nye-history-times-square-ball" ] }, + { + prefix: "./media/buildings/Townhouses/", + all: null, + authors: [ + "chemicalcrux" + ] + }, { prefix: "./media/clothing/Boots/", files: [ diff --git a/media/buildings/Townhouses/Three Story Townhouse-Angled.svg b/media/buildings/Townhouses/Three Story Townhouse-Angled.svg new file mode 100644 index 00000000..e826f58f --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Angled.svg @@ -0,0 +1,273 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/buildings/Townhouses/Three Story Townhouse-Back Corner.svg b/media/buildings/Townhouses/Three Story Townhouse-Back Corner.svg new file mode 100644 index 00000000..a4a1328b --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Back Corner.svg @@ -0,0 +1,165 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/buildings/Townhouses/Three Story Townhouse-Back.svg b/media/buildings/Townhouses/Three Story Townhouse-Back.svg new file mode 100644 index 00000000..c7063b7d --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Back.svg @@ -0,0 +1,96 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/buildings/Townhouses/Three Story Townhouse-Corner.svg b/media/buildings/Townhouses/Three Story Townhouse-Corner.svg new file mode 100644 index 00000000..629bcafe --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Corner.svg @@ -0,0 +1,309 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/buildings/Townhouses/Three Story Townhouse-Front.svg b/media/buildings/Townhouses/Three Story Townhouse-Front.svg new file mode 100644 index 00000000..9777d6be --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Front.svg @@ -0,0 +1,210 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/buildings/Townhouses/Three Story Townhouse-Side.svg b/media/buildings/Townhouses/Three Story Townhouse-Side.svg new file mode 100644 index 00000000..35a24cc1 --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Side.svg @@ -0,0 +1,117 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/buildings/Townhouses/Three Story Townhouse-Top.svg b/media/buildings/Townhouses/Three Story Townhouse-Top.svg new file mode 100644 index 00000000..88d5d8f2 --- /dev/null +++ b/media/buildings/Townhouses/Three Story Townhouse-Top.svg @@ -0,0 +1,126 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/presets/buildings.js b/presets/buildings.js index 0a658132..c6eedce5 100644 --- a/presets/buildings.js +++ b/presets/buildings.js @@ -347,6 +347,7 @@ function makeBuildings() { /* ***Doors*** */ results.push(makeModel({"name": "Doors", "kind": "buildings", "forms": [{"name": "6 Panel Door", "views": [{"name": "Front", "height": 2.0320000648498535, "mass": 11.793399810791016}, {"name": "Angled", "height": 2.0320000648498535, "mass": 11.793399810791016}, {"name": "Side", "height": 2.0320000648498535, "mass": 11.793399810791016}, {"name": "Top", "height": 0.03492499887943268, "mass": 11.793399810791016}]}, {"name": "French Door", "views": [{"name": "Front", "height": 2.0320000648498535, "mass": 31.75149917602539}, {"name": "Angled", "height": 2.0320000648498535, "mass": 31.75149917602539}, {"name": "Side", "height": 2.0320000648498535, "mass": 31.75149917602539}, {"name": "Top", "height": 0.03492499887943268, "mass": 31.75149917602539}]}, {"name": "Fire Door", "views": [{"name": "Front", "height": 2.0320000648498535, "mass": 54.54545593261719}, {"name": "Angled", "height": 2.0320000648498535, "mass": 54.54545593261719}, {"name": "Side", "height": 2.0320000648498535, "mass": 54.54545593261719}, {"name": "Top", "height": 0.10518216341733932, "mass": 54.54545593261719}]}]})); /* ***Times Square NYE*** */ results.push(makeModel({"name": "Times Square NYE", "kind": "buildings", "forms": [{"name": "Ball", "views": [{"name": "Front", "height": 3.4989547729492188, "mass": 5397.72705078125, "extra": 1.0016937456872217, "bottom": 0.0016880275085964648}, {"name": "Angled", "height": 3.4989547729492188, "mass": 5397.72705078125, "extra": 1.0025409836065575, "bottom": 0.00252813570380047}, {"name": "Corner", "height": 3.4989547729492188, "mass": 5397.72705078125, "extra": 1.0018165582086815, "bottom": 0.00180998233215548}, {"name": "Side", "height": 3.4989547729492188, "mass": 5397.72705078125, "extra": 1.001850383633639, "bottom": 0.001843561043274757}, {"name": "Back", "height": 3.4989547729492188, "mass": 5397.72705078125, "extra": 1.0016623910180016, "bottom": 0.0016568822456753673}, {"name": "Top", "height": 3.657600164413452, "mass": 5397.72705078125, "extra": 1.001771054685155, "bottom": 0.001764803557935817}]}, {"name": "Tower", "views": [{"name": "Front", "height": 23.458213806152344, "extra": 1.0016112545018008, "bottom": 0.0016060788980911244}, {"name": "Angled", "height": 23.458213806152344, "extra": 1.0016112545018008, "bottom": 0.0016060788980911244}, {"name": "Corner", "height": 23.458213806152344, "extra": 1.0016112545018008, "bottom": 0.0016060788980911244}, {"name": "Side", "height": 23.458213806152344, "extra": 1.0016112545018008, "bottom": 0.0016060788980911244}, {"name": "Back", "height": 23.458213806152344, "extra": 1.0016112545018008, "bottom": 0.0016060788980911244}, {"name": "Top", "height": 1.5605759620666504, "extra": 1.0015567074184117, "bottom": 0.0015518757853168342}]}, {"name": "2022", "views": [{"name": "Front", "height": 2.1339330673217773, "extra": 1.003530708012506, "bottom": 0.0035059510336938327}, {"name": "Angled", "height": 2.1339330673217773, "extra": 1.0047998012242747, "bottom": 0.004754163148077668}, {"name": "Corner", "height": 2.1339330673217773, "extra": 1.0028325, "bottom": 0.002816544276672584}, {"name": "Side", "height": 2.1339330673217773, "extra": 1.001694837935174, "bottom": 0.0016891123916577266}, {"name": "Back", "height": 2.1339330673217773, "extra": 1.003530708012506, "bottom": 0.0035059510336938327}, {"name": "Top", "height": 0.4862631559371948, "extra": 1.0157526272448099, "bottom": 0.01527149491119562}]}]})); /* ***Sheds*** */ results.push(makeModel({"name": "Sheds", "kind": "buildings", "forms": [{"name": "Small Shed", "views": [{"name": "Front", "height": 3.479300022125244, "extra": 1.005440565201383, "bottom": 0.0053820029257200174}, {"name": "Angled", "height": 3.479300022125244, "extra": 1.0054253856774116, "bottom": 0.0053671479818332875}, {"name": "Corner", "height": 3.479300022125244, "extra": 1.0053985294117647, "bottom": 0.005340863791242229}, {"name": "Side", "height": 3.479300022125244, "extra": 1.0054021608643458, "bottom": 0.005344418052256532}, {"name": "Back", "height": 3.479300022125244, "extra": 1.005440565201383, "bottom": 0.0053820029257200174}, {"name": "Top", "height": 2.638400077819824, "extra": 1.0066026410564226, "bottom": 0.006516587677725118}]}, {"name": "Medium Shed", "views": [{"name": "Front", "height": 3.9618988037109375, "extra": 1.0048322228224984, "bottom": 0.004785969084423278}, {"name": "Angled", "height": 3.9618988037109375, "extra": 1.0047982893157263, "bottom": 0.004752679849837231}, {"name": "Corner", "height": 3.9618988037109375, "extra": 1.004316382460414, "bottom": 0.004279439068938889}, {"name": "Side", "height": 3.9618988037109375, "extra": 1.0048019207683074, "bottom": 0.0047562425683709865}, {"name": "Back", "height": 3.9618988037109375, "extra": 1.0048322228224984, "bottom": 0.004785969084423278}, {"name": "Top", "height": 3.0480000972747803, "extra": 1.006093637454982, "bottom": 0.006020266808357238}]}, {"name": "Large Shed", "views": [{"name": "Front", "height": 4.26669979095459, "extra": 1.0041839246053184, "bottom": 0.004149204686160603}, {"name": "Angled", "height": 4.26669979095459, "extra": 1.0043687027707808, "bottom": 0.004330862270776434}, {"name": "Corner", "height": 4.26669979095459, "extra": 1.0035310734463276, "bottom": 0.0035063113604488078}, {"name": "Side", "height": 4.26669979095459, "extra": 1.004201680672269, "bottom": 0.004166666666666667}, {"name": "Back", "height": 4.26669979095459, "extra": 1.0041839246053184, "bottom": 0.004149204686160603}, {"name": "Top", "height": 3.857600212097168, "extra": 1.0048019207683074, "bottom": 0.0047562425683709865}]}]})); + /* ***Townhouses*** */ results.push(makeModel({"name": "Townhouses", "kind": "buildings", "trace_alpha": 0.0, "forms": [{"name": "Three Story Townhouse", "views": [{"name": "Front", "height": 7.595012664794922, "volume": 697.7749681878887, "extra": 1.0033003300330032, "bottom": 0.003278688524590164}, {"name": "Angled", "height": 7.595012664794922, "volume": 697.7749681878887, "extra": 1.0035971223021583, "bottom": 0.0035714285714285713}, {"name": "Corner", "height": 7.595012664794922, "volume": 697.7749681878887, "extra": 1.0035046728971964, "bottom": 0.0034802784222737818}, {"name": "Side", "height": 7.595012664794922, "volume": 697.7749681878887, "extra": 1.0034802784222738, "bottom": 0.0034562211981566822}, {"name": "Back Corner", "height": 7.595012664794922, "volume": 697.7749681878887, "extra": 1.0035046728971964, "bottom": 0.0034802784222737818}, {"name": "Back", "height": 7.595012664794922, "volume": 697.7749681878887, "extra": 1.0033003300330032, "bottom": 0.003278688524590164}, {"name": "Top", "height": 16.01599884033203, "volume": 697.7749681878887, "extra": 1.0015126512651265, "bottom": 0.001508088840142583}]}]})); /* ***INSERT HERE*** */ results.sort((b1, b2) => { diff --git a/scripts/blender/addons/macrovision/ops.py b/scripts/blender/addons/macrovision/ops.py index a12d5399..9255dc30 100644 --- a/scripts/blender/addons/macrovision/ops.py +++ b/scripts/blender/addons/macrovision/ops.py @@ -38,7 +38,13 @@ def get_bounds(objects): return ( Vector([min(xl), min(yl), min(zl)]), - Vector([max(xl), max(yl), max(zl)]) + Vector([min(xl), min(yl), max(zl)]), + Vector([min(xl), max(yl), min(zl)]), + Vector([min(xl), max(yl), max(zl)]), + Vector([max(xl), min(yl), min(zl)]), + Vector([max(xl), min(yl), max(zl)]), + Vector([max(xl), max(yl), min(zl)]), + Vector([max(xl), max(yl), max(zl)]), ) class MVConfigCollection(bpy.types.Operator): @@ -234,6 +240,7 @@ class MVExport(bpy.types.Operator): lineart = bpy.data.objects["lineart"] lineart.grease_pencil_modifiers['Lineart'].source_type = 'COLLECTION' + #lineart.data.stroke_thickness_space = 'SCREENSPACE' c.data.type = "ORTHO" c2.data.type = "ORTHO" @@ -252,6 +259,7 @@ class MVExport(bpy.types.Operator): all_data["name"] = context.scene.mv_name all_data["kind"] = context.scene.mv_kind + all_data["trace_alpha"] = context.scene.mv_trace_mode all_data["forms"] = [] default_views = [] @@ -290,7 +298,12 @@ class MVExport(bpy.types.Operator): data["name"] = coll.name data["views"] = [] - bound_min, bound_max = get_bounds(coll.objects) + bounds = get_bounds(coll.objects) + bounds_seq = [] + for bound in bounds: + bounds_seq += [bound[0], bound[1], bound[2]] + bound_min = bounds[0] + bound_max = bounds[-1] dimensions = bound_max - bound_min size = max(dimensions) global_bbox_center = 0.5 * (bound_min + bound_max) @@ -309,9 +322,9 @@ class MVExport(bpy.types.Operator): c.location = global_bbox_center c.rotation_euler = Euler([angles[1] * pi / 2, 0, angles[0] * pi / 2]) print(list(bound_min) + list(bound_max)) - _, c.data.ortho_scale = c.camera_fit_coords(bpy.context.evaluated_depsgraph_get(), list(bound_min) + list(bound_max)) + _, c.data.ortho_scale = c.camera_fit_coords(bpy.context.evaluated_depsgraph_get(), bounds_seq) c.location = Vector([c.location[0], c.location[1], c.location[2]]) - c.data.ortho_scale *= 1.2 + c.data.ortho_scale *= 1.1 rot = c.rotation_euler.to_matrix() rot.invert() c.location += Vector([0, 0, size * 2]) @ rot diff --git a/scripts/blender/addons/macrovision/props.py b/scripts/blender/addons/macrovision/props.py index 2de9672d..212d59cd 100644 --- a/scripts/blender/addons/macrovision/props.py +++ b/scripts/blender/addons/macrovision/props.py @@ -15,6 +15,16 @@ scene_props["mv_kind"] = bpy.props.StringProperty( default = "objects" ) +scene_props["mv_trace_mode"] = bpy.props.FloatProperty( + name = "Trace Alpha", + description = "0 for polygonal; 1 for normal", + min = 0, + max = 2, + soft_min = 0, + soft_max = 1, + default = 1 +) + class MVView(bpy.types.PropertyGroup): view: bpy.props.EnumProperty( name = "View", diff --git a/scripts/blender/addons/macrovision/ui.py b/scripts/blender/addons/macrovision/ui.py index 53daf9e1..c6adc786 100644 --- a/scripts/blender/addons/macrovision/ui.py +++ b/scripts/blender/addons/macrovision/ui.py @@ -75,6 +75,7 @@ class MVScenePanel(bpy.types.Panel): box.prop(context.scene, "mv_name") box.prop(context.scene, "mv_kind") + box.prop(context.scene, "mv_trace_mode") box.template_list( "MV_UL_ViewList", "Views", diff --git a/scripts/process-model.py b/scripts/process-model.py index b1f72faa..1211f82b 100644 --- a/scripts/process-model.py +++ b/scripts/process-model.py @@ -88,11 +88,13 @@ for data in all_data["forms"]: output_noline = sourcedir.joinpath(name + "-" + view_name + "-noline.svg").__str__() procs = [] - procs.append(subprocess.Popen([POTRACE, input_base, "-b", "svg", "-o", output_base], shell=False)) - procs.append(subprocess.Popen([POTRACE, input_dark, "-b", "svg", "-C", "#1a1a1a", "-o", output_dark], shell=False)) - procs.append(subprocess.Popen([POTRACE, input_medium, "-b", "svg", "-C", "#333333", "-o", output_medium], shell=False)) - procs.append(subprocess.Popen([POTRACE, input_light, "-b", "svg", "-C", "#4d4d4d", "-o", output_light], shell=False)) - procs.append(subprocess.Popen([POTRACE, input_noline, "-b", "svg", "-C", "#333333", "-o", output_noline], shell=False)) + + alpha = str(all_data["trace_alpha"]) + procs.append(subprocess.Popen([POTRACE, input_base, "-b", "svg", "-a", alpha, "-o", output_base], shell=False)) + procs.append(subprocess.Popen([POTRACE, input_dark, "-b", "svg", "-a", alpha, "-C", "#1a1a1a", "-o", output_dark], shell=False)) + procs.append(subprocess.Popen([POTRACE, input_medium, "-b", "svg", "-a", alpha, "-C", "#333333", "-o", output_medium], shell=False)) + procs.append(subprocess.Popen([POTRACE, input_light, "-b", "svg", "-a", alpha, "-C", "#4d4d4d", "-o", output_light], shell=False)) + procs.append(subprocess.Popen([POTRACE, input_noline, "-b", "svg", "-a", alpha, "-C", "#333333", "-o", output_noline], shell=False)) [proc.wait() for proc in procs]