Published grammar
This page uses the same scene-first presentation as the gallery viewer while also showing the source grammar text.
//------------------------------------------------
// Progen3D corridor-based house
// Complete drop-in grammar
//
// Materials:
// floor = whiteTiles
// corridor floor = blueCeramicTile
// walls = smoothConcrete
// wall trims = mapleWood
// doors = oakPlanks
// door trims = mapleWood
// windows = stainedBlueGlass
// window trims = mapleWood
// roof = grayStone
//------------------------------------------------
Start ->
[
T(-8 0 4)
S(0.6 1.2 0.6)
House(14 16 1)
]
//------------------------------------------------
// Main house
//------------------------------------------------
House(w d cell) ->
FloorBase(w d cell)
CorridorFloor(w d cell)
// Roof(w d cell)
OuterWalls(w d cell)
CorridorSideWalls(0 d cell)
LeftRooms(cell)
RightRooms(cell)
//------------------------------------------------
// Floor and roof
//------------------------------------------------
FloorBase(w d cell) ->
[
T(((w-1)*cell)*0.5 0 ((d-1)*cell)*0.5)
S(w*cell 0.05 d*cell)
I(Cube whiteTiles 0)
]
CorridorFloor(w d cell) ->
[
T(6.5*cell 0.03 ((d-1)*cell)*0.5)
S(2*cell 0.02 d*cell)
I(Cube blueCeramicTile 0)
]
Roof(w d cell) ->
[
T(((w-1)*cell)*0.5 1.35 ((d-1)*cell)*0.5)
S(w*cell 0.08 d*cell)
I(Cube grayStone 0)
]
//------------------------------------------------
// Outer perimeter walls
//------------------------------------------------
OuterWalls(w d cell) ->
NorthWall(0 w cell)
SouthWall(0 w d cell)
WestWall(0 d cell)
EastWall(0 d w cell)
NorthWall(i w cell) ->
?(i < w) NorthWallStep(i w cell) : End
NorthWallStep(i w cell) ->
NorthWallSeg(i cell)
NorthWall(i+1 w cell)
SouthWall(i w d cell) ->
?(i < w) SouthWallStep(i w d cell) : End
SouthWallStep(i w d cell) ->
SouthWallSeg(i d cell)
SouthWall(i+1 w d cell)
WestWall(i d cell) ->
?(i < d) WestWallStep(i d cell) : End
WestWallStep(i d cell) ->
WestWallSeg(i cell)
WestWall(i+1 d cell)
EastWall(i d w cell) ->
?(i < d) EastWallStep(i d w cell) : End
EastWallStep(i d w cell) ->
EastWallSeg(i w cell)
EastWall(i+1 d w cell)
//------------------------------------------------
// North/south walls solid
//------------------------------------------------
NorthWallSeg(x cell) ->
SolidWallXNorth(x cell)
SouthWallSeg(x d cell) ->
SolidWallXSouth(x d cell)
//------------------------------------------------
// West/east walls can have windows
//------------------------------------------------
WestWallSeg(z cell) ->
R r(0 1)
WestWallChoice(z cell r)
WestWallChoice(z cell r) ->
?(r < 0.45) WindowZWest(z cell) : SolidWallZWest(z cell)
EastWallSeg(z w cell) ->
R r(0 1)
EastWallChoice(z w cell r)
EastWallChoice(z w cell r) ->
?(r < 0.45) WindowZEast(z w cell) : SolidWallZEast(z w cell)
//------------------------------------------------
// Corridor side walls
// Corridor spans x = 6..7
// Side walls lie at x = 5.5 and x = 7.5
//------------------------------------------------
CorridorSideWalls(i d cell) ->
?(i < d) CorridorSideWallsStep(i d cell) : End
CorridorSideWallsStep(i d cell) ->
LeftCorridorWallSeg(i cell)
RightCorridorWallSeg(i cell)
CorridorSideWalls(i+1 d cell)
LeftCorridorWallSeg(z cell) ->
CorridorLeftWallAt(z cell)
RightCorridorWallSeg(z cell) ->
CorridorRightWallAt(z cell)
//------------------------------------------------
// Door positions into corridor
//------------------------------------------------
CorridorLeftWallAt(z cell) ->
?(z==1) DoorZInner(5.5 z cell) : CorridorLeftWallB(z cell)
CorridorLeftWallB(z cell) ->
?(z==5) DoorZInner(5.5 z cell) : CorridorLeftWallC(z cell)
CorridorLeftWallC(z cell) ->
?(z==9) DoorZInner(5.5 z cell) : CorridorLeftWallD(z cell)
CorridorLeftWallD(z cell) ->
?(z==13) DoorZInner(5.5 z cell) : SolidWallZInner(6 z cell)
CorridorRightWallAt(z cell) ->
?(z==1) DoorZInner(7.5 z cell) : CorridorRightWallB(z cell)
CorridorRightWallB(z cell) ->
?(z==5) DoorZInner(7.5 z cell) : CorridorRightWallC(z cell)
CorridorRightWallC(z cell) ->
?(z==9) DoorZInner(7.5 z cell) : CorridorRightWallD(z cell)
CorridorRightWallD(z cell) ->
?(z==13) DoorZInner(7.5 z cell) : SolidWallZInner(8 z cell)
//------------------------------------------------
// Rooms
//------------------------------------------------
LeftRooms(cell) ->
LeftRoom1(cell)
LeftRoom2(cell)
LeftRoom3(cell)
LeftRoom4(cell)
LeftRoomPartitions(cell)
RightRooms(cell) ->
RightRoom1(cell)
RightRoom2(cell)
RightRoom3(cell)
RightRoom4(cell)
RightRoomPartitions(cell)
LeftRoom1(cell) ->
[
T(2.5*cell 0.02 1.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
LeftRoom2(cell) ->
[
T(2.5*cell 0.02 5.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
LeftRoom3(cell) ->
[
T(2.5*cell 0.02 9.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
LeftRoom4(cell) ->
[
T(2.5*cell 0.02 13.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
RightRoom1(cell) ->
[
T(10.5*cell 0.02 1.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
RightRoom2(cell) ->
[
T(10.5*cell 0.02 5.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
RightRoom3(cell) ->
[
T(10.5*cell 0.02 9.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
RightRoom4(cell) ->
[
T(10.5*cell 0.02 13.5*cell)
S(6*cell 0.02 4*cell)
I(Cube whiteTiles 0)
]
//------------------------------------------------
// Partitions between rooms
//------------------------------------------------
LeftRoomPartitions(cell) ->
WallXInnerAt(2.5 3.5 cell)
WallXInnerAt(2.5 7.5 cell)
WallXInnerAt(2.5 11.5 cell)
RightRoomPartitions(cell) ->
WallXInnerAt(10.5 3.5 cell)
WallXInnerAt(10.5 7.5 cell)
WallXInnerAt(10.5 11.5 cell)
WallXInnerAt(x z cell) ->
SolidWallXInnerAt(x z cell)
//------------------------------------------------
// SOLID WALLS WITH TOP/BOTTOM ARCHITRAVES
//------------------------------------------------
SolidWallXNorth(x cell) ->
SolidWallXNorthCore(x cell)
SolidWallXNorthBottomTrim(x cell)
SolidWallXNorthTopTrim(x cell)
SolidWallXNorthCore(x cell) ->
[
T(x*cell 0.6 -0.5*cell)
S(1.0 1.2 0.12)
I(Cube smoothConcrete 0)
]
SolidWallXNorthBottomTrim(x cell) ->
[
T(x*cell 0.08 -0.5*cell)
S(1.0 0.16 0.14)
I(Cube mapleWood 0)
]
SolidWallXNorthTopTrim(x cell) ->
[
T(x*cell 1.12 -0.5*cell)
S(1.0 0.16 0.14)
I(Cube mapleWood 0)
]
//------------------------------------------------
SolidWallXSouth(x d cell) ->
SolidWallXSouthCore(x d cell)
SolidWallXSouthBottomTrim(x d cell)
SolidWallXSouthTopTrim(x d cell)
SolidWallXSouthCore(x d cell) ->
[
T(x*cell 0.6 (d-0.5)*cell)
S(1.0 1.2 0.12)
I(Cube smoothConcrete 0)
]
SolidWallXSouthBottomTrim(x d cell) ->
[
T(x*cell 0.08 (d-0.5)*cell)
S(1.0 0.16 0.14)
I(Cube mapleWood 0)
]
SolidWallXSouthTopTrim(x d cell) ->
[
T(x*cell 1.12 (d-0.5)*cell)
S(1.0 0.16 0.14)
I(Cube mapleWood 0)
]
//------------------------------------------------
SolidWallZWest(z cell) ->
SolidWallZWestCore(z cell)
SolidWallZWestBottomTrim(z cell)
SolidWallZWestTopTrim(z cell)
SolidWallZWestCore(z cell) ->
[
T(-0.5*cell 0.6 z*cell)
S(0.12 1.2 1.0)
I(Cube smoothConcrete 0)
]
SolidWallZWestBottomTrim(z cell) ->
[
T(-0.5*cell 0.08 z*cell)
S(0.14 0.16 1.0)
I(Cube mapleWood 0)
]
SolidWallZWestTopTrim(z cell) ->
[
T(-0.5*cell 1.12 z*cell)
S(0.14 0.16 1.0)
I(Cube mapleWood 0)
]
//------------------------------------------------
SolidWallZEast(z w cell) ->
SolidWallZEastCore(z w cell)
SolidWallZEastBottomTrim(z w cell)
SolidWallZEastTopTrim(z w cell)
SolidWallZEastCore(z w cell) ->
[
T((w-0.5)*cell 0.6 z*cell)
S(0.12 1.2 1.0)
I(Cube smoothConcrete 0)
]
SolidWallZEastBottomTrim(z w cell) ->
[
T((w-0.5)*cell 0.08 z*cell)
S(0.14 0.16 1.0)
I(Cube mapleWood 0)
]
SolidWallZEastTopTrim(z w cell) ->
[
T((w-0.5)*cell 1.12 z*cell)
S(0.14 0.16 1.0)
I(Cube mapleWood 0)
]
//------------------------------------------------
// Generic inner Z wall at x = (x-0.5)*cell
//------------------------------------------------
SolidWallZInner(x z cell) ->
SolidWallZInnerCore(x z cell)
SolidWallZInnerBottomTrim(x z cell)
SolidWallZInnerTopTrim(x z cell)
SolidWallZInnerCore(x z cell) ->
[
T((x-0.5)*cell 0.6 z*cell)
S(0.12 1.2 1.0)
I(Cube smoothConcrete 0)
]
SolidWallZInnerBottomTrim(x z cell) ->
[
T((x-0.5)*cell 0.08 z*cell)
S(0.14 0.16 1.0)
I(Cube mapleWood 0)
]
SolidWallZInnerTopTrim(x z cell) ->
[
T((x-0.5)*cell 1.12 z*cell)
S(0.14 0.16 1.0)
I(Cube mapleWood 0)
]
//------------------------------------------------
// Inner X wall centered directly on x,z
//------------------------------------------------
SolidWallXInnerAt(x z cell) ->
SolidWallXInnerAtCore(x z cell)
SolidWallXInnerAtBottomTrim(x z cell)
SolidWallXInnerAtTopTrim(x z cell)
SolidWallXInnerAtCore(x z cell) ->
[
T(x*cell 0.6 z*cell)
S(6.0 1.2 0.12)
I(Cube smoothConcrete 0)
]
SolidWallXInnerAtBottomTrim(x z cell) ->
[
T(x*cell 0.08 z*cell)
S(6.0 0.16 0.14)
I(Cube mapleWood 0)
]
SolidWallXInnerAtTopTrim(x z cell) ->
[
T(x*cell 1.12 z*cell)
S(6.0 0.16 0.14)
I(Cube mapleWood 0)
]
//------------------------------------------------
// DOORS WITH ARCHITRAVES
// Door top widened to 1.0
//------------------------------------------------
DoorZInner(x z cell) ->
DoorZInnerFront(x z cell)
DoorZInnerBack(x z cell)
DoorZInnerTop(x z cell)
ArchitraveZLeft(x z cell)
ArchitraveZRight(x z cell)
ArchitraveZTop(x z cell)
DoorZInnerFront(x z cell) ->
[
T(x*cell 0.50 z*cell-0.40)
S(0.12 1.00 0.20)
I(Cube oakPlanks 0)
]
DoorZInnerBack(x z cell) ->
[
T(x*cell 0.50 z*cell+0.40)
S(0.12 1.00 0.20)
I(Cube oakPlanks 0)
]
DoorZInnerTop(x z cell) ->
[
T(x*cell 1.10 z*cell)
S(0.12 0.20 1.00)
I(Cube oakPlanks 0)
]
ArchitraveZLeft(x z cell) ->
[
T(x*cell 0.52 z*cell-0.52)
S(0.03 1.04 0.06)
I(Cube mapleWood 0)
]
ArchitraveZRight(x z cell) ->
[
T(x*cell 0.52 z*cell+0.52)
S(0.03 1.04 0.06)
I(Cube mapleWood 0)
]
ArchitraveZTop(x z cell) ->
[
T(x*cell 1.14 z*cell)
S(0.03 0.06 1.10)
I(Cube mapleWood 0)
]
//------------------------------------------------
// WINDOWS WITH MATCHING ARCHITRAVES
//------------------------------------------------
WindowZWest(z cell) ->
WindowZWestGlassBottom(z cell)
WindowZWestGlassTop(z cell)
WindowZWestGlassFront(z cell)
WindowZWestGlassBack(z cell)
WindowZWestTrimFront(z cell)
WindowZWestTrimBack(z cell)
WindowZWestTrimHead(z cell)
WindowZWestTrimSill(z cell)
WindowZWestGlassBottom(z cell) ->
[
T(-0.5*cell 0.175 z*cell)
S(0.12 0.35 1.00)
I(Cube stainedBlueGlass 0)
]
WindowZWestGlassTop(z cell) ->
[
T(-0.5*cell 1.075 z*cell)
S(0.12 0.25 1.00)
I(Cube stainedBlueGlass 0)
]
WindowZWestGlassFront(z cell) ->
[
T(-0.5*cell 0.65 z*cell-0.40)
S(0.12 0.60 0.20)
I(Cube stainedBlueGlass 0)
]
WindowZWestGlassBack(z cell) ->
[
T(-0.5*cell 0.65 z*cell+0.40)
S(0.12 0.60 0.20)
I(Cube stainedBlueGlass 0)
]
WindowZWestTrimFront(z cell) ->
[
T(-0.5*cell 0.65 z*cell-0.52)
S(0.03 0.90 0.06)
I(Cube mapleWood 0)
]
WindowZWestTrimBack(z cell) ->
[
T(-0.5*cell 0.65 z*cell+0.52)
S(0.03 0.90 0.06)
I(Cube mapleWood 0)
]
WindowZWestTrimHead(z cell) ->
[
T(-0.5*cell 1.16 z*cell)
S(0.03 0.06 1.10)
I(Cube mapleWood 0)
]
WindowZWestTrimSill(z cell) ->
[
T(-0.5*cell 0.14 z*cell)
S(0.03 0.06 1.10)
I(Cube mapleWood 0)
]
//------------------------------------------------
WindowZEast(z w cell) ->
WindowZEastGlassBottom(z w cell)
WindowZEastGlassTop(z w cell)
WindowZEastGlassFront(z w cell)
WindowZEastGlassBack(z w cell)
WindowZEastTrimFront(z w cell)
WindowZEastTrimBack(z w cell)
WindowZEastTrimHead(z w cell)
WindowZEastTrimSill(z w cell)
WindowZEastGlassBottom(z w cell) ->
[
T((w-0.5)*cell 0.175 z*cell)
S(0.12 0.35 1.00)
I(Cube stainedBlueGlass 0)
]
WindowZEastGlassTop(z w cell) ->
[
T((w-0.5)*cell 1.075 z*cell)
S(0.12 0.25 1.00)
I(Cube stainedBlueGlass 0)
]
WindowZEastGlassFront(z w cell) ->
[
T((w-0.5)*cell 0.65 z*cell-0.40)
S(0.12 0.60 0.20)
I(Cube stainedBlueGlass 0)
]
WindowZEastGlassBack(z w cell) ->
[
T((w-0.5)*cell 0.65 z*cell+0.40)
S(0.12 0.60 0.20)
I(Cube stainedBlueGlass 0)
]
WindowZEastTrimFront(z w cell) ->
[
T((w-0.5)*cell 0.65 z*cell-0.52)
S(0.03 0.90 0.06)
I(Cube mapleWood 0)
]
WindowZEastTrimBack(z w cell) ->
[
T((w-0.5)*cell 0.65 z*cell+0.52)
S(0.03 0.90 0.06)
I(Cube mapleWood 0)
]
WindowZEastTrimHead(z w cell) ->
[
T((w-0.5)*cell 1.16 z*cell)
S(0.03 0.06 1.10)
I(Cube mapleWood 0)
]
WindowZEastTrimSill(z w cell) ->
[
T((w-0.5)*cell 0.14 z*cell)
S(0.03 0.06 1.10)
I(Cube mapleWood 0)
]
End ->