Community Builder

I’ve been watching the Homemaker script develop for a while and decided to go to the next step and generate completely random houses. At the moment you can change all the settings through the UI then generate a suburban block with it.

Features
Set block size
Set yard spacing
Set min/max rooms for each house

Limitations
Rectangular blocks only
Houses all face one direction

The future of the script will depend largely on what people want out of it. I’d like to implement a street system as well as a way of allowing users to use self-created. non-random houses in the creation process. More detailed models would also be good and could still be relatively easily generated randomly, for example doors, windows, gutters and yards with gardens and fences. Parks and public places like pools, halls and shopping districts would be a nice addition.

I’m very open to suggestions for this project and would like to have some feedback on features that would be useful to the community.

.blend http://www.sutabi.tk/timmeh/data/python/community.zip
note : the script currently uses a gui wrapper to keep the UI code simple so you need to run the script in the blend file or have guiwrap in your python path. i will recitfy this in the next release.

Below is a screenshot of Community Builder in progress.
http://www.sutabi.tk/timmeh/data/img/community.jpg

And a rendered view of the output.
http://www.sutabi.tk/timmeh/data/img/neighbourhood.jpg

that looks really useful!
mabye you could talk with Ezual about implementing this script into “The Beast”!
Great work!

CGuy,
AKA Clayton S.

:open_mouth:
throws wet towel Okay, I give up!

Seriously tho, that’s bloody magnificent! And I have to admit, the houses look way more …uh… house-like than my own version.

Now, for the rotation, you could do what I did: give the houses more space (as in, more yard around them), move them slightly so that the center of the mesh goes roughly in the center of the bounding box, then rotate them on the Z axis with set.Euler.

I also thought of something, last night: how about keeping the house mesh definitions in separate files, so that the user can write a new type of building? I was thinking something along the lines of: enter a list of definition files, set a number of buildings, then the script opens these files up, does all the random resizing etc, then randomly removes houses of type A and replaces them with houses of types B, C, etc.

And on a totally different note, what’s guiwrap, where do I get it, and how do I activate it? :expressionless:

i’ve fiddled with a house-making function some weeks ago, feel free to use it if it suits your fancy. It includes a quick positioning of UV coords, so it can be extended to perform some auto-uvmapping if needed.


import Blender
from Blender import Scene, Object, NMesh

# initial location
loc = [0, 0, 0]
# build parameters
width = 4    # x
length = 6   # y
height = 2   # z
roof_c = 1   # z
roof_a = 0.2 # x
roof_b = 0.4 # y
# points
prm = [width / 2, length / 2, height]
prf = [roof_a, roof_b, roof_c]
verts = [[loc[0] - prm[0], loc[1] - prm[1], loc[2]],                                # pointA-0
			 [loc[0] - prm[0], loc[1] + prm[1], loc[2]],                            # pointB-1
			 [loc[0] + prm[0], loc[1] + prm[1], loc[2]],                            # pointC-2
			 [loc[0] + prm[0], loc[1] - prm[1], loc[2]],                            # pointD-3
			 [loc[0] - prm[0], loc[1] - prm[1], loc[2] + prm[2]],                   # pointE-4
			 [loc[0] - prm[0], loc[1] + prm[1], loc[2] + prm[2]],                   # pointF-5
			 [loc[0] + prm[0], loc[1] + prm[1], loc[2] + prm[2]],                   # pointG-6
			 [loc[0] + prm[0], loc[1] - prm[1], loc[2] + prm[2]],                   # pointH-7
			 [loc[0] - prm[0] - prf[0], loc[1] - prm[1] - prf[1], loc[2] + prm[2]], # pointI-8
			 [loc[0] - prm[0] - prf[0], loc[1] + prm[1] + prf[1], loc[2] + prm[2]], # pointJ-9
			 [loc[0] + prm[0] + prf[0], loc[1] + prm[1] + prf[1], loc[2] + prm[2]], # pointK-10
			 [loc[0] + prm[0] + prf[0], loc[1] - prm[1] - prf[1], loc[2] + prm[2]], # pointL-11
			 [loc[0], loc[1] - prm[1] - prf[1], loc[2] + prm[2] + prf[2]],          # pointM-12
			 [loc[0], loc[1] + prm[1] + prf[1], loc[2] + prm[2] + prf[2]]           # pointN-13
			]
# faces
faces = [[0, 1, 2, 3],         # faceA
			 [0, 4, 5, 1],     # faceB
			 [1, 5, 6, 2],     # faceC
			 [2, 6, 7, 3],     # faceD
			 [3, 7, 4, 0],     # faceE
			 [4, 8, 9, 5],     # faceF
			 [5, 9, 10, 6],    # faceG
			 [6, 10, 11, 7],   # faceH
			 [7, 11, 8, 4],    # faceI
			 [10, 13, 12, 11], # faceJ
			 [8, 12, 13, 9],   # faceK
			 [9, 13, 10],      # faceL
			 [11, 12, 8]       # faceM
			]
# mesh
house = NMesh.New(); house.hasFaceUV(1)
house.verts = [NMesh.Vert (vco[0], vco[1], vco[2]) for vco in verts]

for i in faces:
	f = NMesh.Face()
	f.v = [house.verts[j] for j in i]; house.faces.append(f)

	if len(f.v) == 4: f.uv = [(1.0, 0.0), (1.0, 1.0), (0.0, 1.0), (0.0, 0.0)]

	if len(f.v) == 3: f.uv = [(1.0, 0.0), (0.5, 1.0), (0.0, 0.0)]

house.update(1)
obj = Object.New ("Mesh", "House")
obj.link(house)
Scene.GetCurrent().link(obj)
Blender.Redraw()

aha and just a suggestion:

IF somebody could be arsed to integrate povray hooking into blender (cpp), city-neighbourhood-forest-whatever creation can be done via macros, thus you could have lowpoly placeholders in your viewport …

for free.

That’s really wickedly sweet! Texturing could be a bear unless the script could assist with that somehow.

function I’ve posted does sort of auto uv-ing. it’s a matter of assigning diff materials to diff mesh parts - i’ve done that in an older utility of mine, it is easy.

!Rocky: GUIWrap is tim’s User Interface wrapper for Blender Python to druastically reduce the amount of code needed to design UI elements. It’s very easy to get working, and is included in the zip file as a text file in the .blend. Just save GUIWrap as guiwrap.py in your python path, and the script should run just fine.

This script rocks. Great work, and looking forward to more features (like streets and driveways, etc.)