version "2010.3" attr height = 10 attr blue = "#0066ff" attr angle = rand(35,45) Lot--> setback(10) { street.front : NIL | street.back: Backyard | remainder : Building } Building --> s(10,height,10) center(x) extrude(height) comp(f) { side : Facade | top(0): Roof } Backyard --> setback(2) { street.back: NIL | remainder : Garage } Garage --> s(5,5,5) center(x) extrude(5) comp(f) { side : Facade | top(0): Roof } Facade --> color(blue) Roof --> roofHip(angle) color(blue)Solved! Go to Solution.
version "2010.3"
######################################################
# Imported Rules
#
#import Plant_Distributor:"rules/Plant_Distributor_with_LumenRT_Models.cga"
######################################################
# Control Attributes (user accessible)
#
##Lot Attributes
@Group("Lot Attributes")
#Flip buildings to face rear of the lot.
@Group("Lot Attributes") @Order(1) @Range("true","false")
attr FlipFront = "false"
#Front and rear setbacks (unit = meters)
@Group("Lot Attributes") @Order(2) @Range(1, 20)
attr FrontSetback = 5
@Group("Lot Attributes") @Order(3) @Range(1, 20)
attr GarageSetback = 2
##House Attributes:
@Group("House Attributes")
#House Height:
@Group("House Attributes") @Order(1) @Range(5,25)
attr HouseHeight = 5
#House size (percentage of lot)
@Group("House Attributes") @Order(2) @Range(0.35,0.7)
attr HouseLength = rand(0.50,0.55)
@Group("House Attributes") @Order(3) @Range(0.5,0.95)
attr HouseWidth = rand(0.7, 0.75)
##Garage Attributes:
@Group("Garage Attributes")
@Group("Garage Attributes") @Order(1) @Range(5,10)
attr GarageHeight = 5
## Landscaping:
@Group("Landscaping")
@Group("Landscaping") @Order(1) @Range(1,5)
attr NumTrees = 1
@Group("Landscaping") @Order(2) @Range(10,20)
attr treesize = rand(15, 20)
######################################################
# Constants (Landscaping only, hidden from user)
#
const grass = "grass/grass.jpg"
const tree = ("Plants/White_Oak/White_Oak_Model_0.obj")
//make dropdown for tree species selector?
######################################################
# Begin Rule with Lot
#
# Designate a setback from the front and rear of the property.
# Assign the front setback area as the Yard, the back setback as the Backyard
# Area not within the setbacks will be where the House is generated.
@StartRule
Lot-->
case FlipFront == "false":
#Replicated grass across Lot
setupProjection(0, scope.xz, 5, 5)
projectUV(0)
texture(grass) Ground.
setback(FrontSetback) { front: Yard | back: Backyard | remainder : House}
else:
#Flip the orientation to generate the buildings facing the rear
mirrorScope(true, false, false)
setupProjection(0, scope.xz, 5, 5)
projectUV(0)
texture(grass) Ground.
setback(FrontSetback) { front: Backyard | back: Yard | remainder : House}
# Import the Plant distributor (2013 Vegegtation rule) and
# Place a tree of random size in the front yard
Yard -->
offset(-2,inside)
scatter(surface, NumTrees, gaussian) { Veg }
Veg -->
alignScopeToAxes(y) s(0,treesize,0) i(tree)
House -->
case FlipFront == "false":
s('HouseWidth,HouseHeight,'HouseLength)
center(xz)
extrude(world.y, HouseHeight) comp(f) { front: FrontFacade | side : SideFacade | top: Roof }
else:
rotateScope(180,0,180)
s('HouseWidth,HouseHeight,'HouseLength)
center(xz)
extrude(world.y, HouseHeight) comp(f) { front: FrontFacade | side : SideFacade | top: Roof }
Backyard -->
case FlipFront == "false":
setback(GarageSetback) { back: NIL | remainder : Garage }
else:
setback(GarageSetback) { front: NIL | remainder : Garage }
#Construct the garage in the back of the Lot
Garage -->
case FlipFront == "false":
s(7,GarageHeight,5)
center(xz)
extrude(world.y, GarageHeight) comp(f) { back : GFront | front : SideFacade | side: Facade | top: Roof }
else:
rotateScope(180,0,180)
s(7,GarageHeight,5)
center(xz)
extrude(world.y, GarageHeight) comp(f) { back : GFront | side: Facade | top: Roof }
######################################################
# Building Facades
#
const minWallSizeAtCorner = 0.8
FrontFacade -->
split(y) {4 : MainFloorFront | ~1 : Facade #UpperFloor?
}
HouseFront -->
split(x) { minWallSizeAtCorner : Facade | ~1 : HouseFront | minWallSizeAtCorner : Facade }
MainFloorFront -->
split(x) { 3 : SideFacade | 1.2 : FrontDoorWall | 1 : Facade | ~1 : SideFacade }
FrontDoorWall -->
split(y) { 2.2 : FrontDoor | ~1: Facade }
FrontDoor -->
extrude(-0.15)
setupProjection(0, scope.xy, scope.sx, scope.sy)
projectUV(0)
texture("textures/door.png")
// End of Front
#####################################################
# The Window mayhem
#
# ~A work in progress~
const Window_Width = 2.2
const SingleWindow = 1.2
const DoubleWindow = 3.4
SideFacade -->
split(x) { minWallSizeAtCorner: Facade | ~1 : WindowArea | minWallSizeAtCorner: Facade}
WindowArea -->
split(y) { 1 : Facade | 1.75 : WallSplitter | ~1 : Facade }
# ^above is working
#####################################################
# Split walls into segments for window placement
#
WallSplitter-->
case scope.sx > (DoubleWindow):
split(x) {3.4 : WindowFrame2 | ~1: Facade }*
case scope.sx > SingleWindow:
split(x) { 1.2 : WindowFrame | ~1: Facade }*
else:
Facade
WindowFrame -->
split(x) { ~1 : Facade | 1.2 : WindowActual | ~1: Facade }
WindowFrame2 -->
split(x) { 0.5: Facade | 1.2 : WindowActual | 1.2 : WindowActual | 0.5 : Facade }
DoubleWindowFrame -->
split(x) { 0.5: Facade | 1.2 : WindowActual | 1.2 : WindowActual | 0.5 : Facade }
# Drops in the window texture
DoubleWindowActual -->
#extrude(-0.15)
setupProjection(0, scope.xy, scope.sx, scope.sy)
projectUV(0)
texture("textures/window.png")
# Drops in the window texture
WindowActual -->
#extrude(-0.15)
setupProjection(0, scope.xy, scope.sx, scope.sy)
projectUV(0)
texture("textures/window.png")
#####################################################
# The Garage!
#
#
GFront -->
split(x) {0.67 : Facade | ~1 : GarageDoor | 0.67 : Facade}
#split(y) {0 : Facade | ~1 : GarageDoor | 0.5 : Facade }
GarageDoor -->
split(y) { ~1 : GarageDoorTx | 1 : Facade }
GarageDoorTx -->
setupProjection(0, scope.xy, scope.sx, scope.sy)
projectUV(0)
texture("textures/DoubleGarage2.png")
#texture("textures/garage.jpg")
#####################################################
# The main wall Facade
#
# Other textures to be added for Randomization
const FacadeRandTexture = "textures/wall_stones.png"
Facade -->
setupProjection(0, scope.xy, 10, 10)
projectUV(0)
texture(FacadeRandTexture)
######################################################
# Roof Texturing
# Note: 50% chance of Hipped roof, else Gable roof.
#
# Other textures to be added for Randomization
#Roof Angle (house and garage)
const roofangle = rand(33,35)
const RoofRandTexture = "textures/roof.jpg"
Roof -->
case p(0.5) :
roofHip(roofangle, 0.75)
comp(f) {all: RoofTexture}
else:
roofGable(30, 0.75)
comp(f) {top: RoofTexture | side : Facade}
RoofTexture -->
alignScopeToGeometry(yUp, any, world.lowest)
setupProjection(0, scope.xz, 6, 6)
projectUV(0)
texture(RoofRandTexture)