Published grammar
This page uses the same scene-first presentation as the gallery viewer while also showing the source grammar text.
//------------------------------------------------
// Progen3D grammar: stochastic path traversal
// Using shinymetal material
//------------------------------------------------
Start ->
[
T(0 0 0)
Path(0 0 0 22)
]
//------------------------------------------------
// Path traversal
//------------------------------------------------
Path(x z dir steps) ->
?(steps > 0)
StepTile(x z)
FeatureAt(x z)
NextPath(x z dir steps)
:
EndCap(x z)
//------------------------------------------------
// Random direction control
//------------------------------------------------
NextPath(x z dir steps) ->
R r(0 1)
?(r < 0.2)
TurnLeft(x z dir steps)
:
?(r < 0.4)
TurnRight(x z dir steps)
:
GoStraight(x z dir steps)
//------------------------------------------------
// Movement rules
//------------------------------------------------
GoStraight(x z dir steps) ->
?(dir==0) Path(x+1 z 0 steps-1) :
?(dir==1) Path(x z+1 1 steps-1) :
?(dir==2) Path(x-1 z 2 steps-1) :
Path(x z-1 3 steps-1)
TurnRight(x z dir steps) ->
?(dir==0) Path(x z+1 1 steps-1) :
?(dir==1) Path(x-1 z 2 steps-1) :
?(dir==2) Path(x z-1 3 steps-1) :
Path(x+1 z 0 steps-1)
TurnLeft(x z dir steps) ->
?(dir==0) Path(x z-1 3 steps-1) :
?(dir==1) Path(x+1 z 0 steps-1) :
?(dir==2) Path(x z+1 1 steps-1) :
Path(x-1 z 2 steps-1)
//------------------------------------------------
// Main path tile (metal surface)
//------------------------------------------------
StepTile(x z) ->
[
T(x 0 z)
S(0.9 0.08 0.9)
I(Cube shinymetal 0)
]
//------------------------------------------------
// Random feature placement (metal variations)
//------------------------------------------------
FeatureAt(x z) ->
R f(0 1)
?(f < 0.15)
Marker(x z)
:
?(f < 0.25)
Pillar(x z)
:
?(f < 0.30)
WideTile(x z)
:
Empty
//------------------------------------------------
// Feature definitions
//------------------------------------------------
Marker(x z) ->
[
T(x 0.2 z)
S(0.3 0.25 0.3)
I(Cube shinymetal 0)
]
Pillar(x z) ->
[
T(x 0.5 z)
S(0.2 1.0 0.2)
I(Cube shinymetal 0)
]
// Wider reflective plate
WideTile(x z) ->
[
T(x 0 z)
S(1.2 0.08 1.2)
I(Cube shinymetal 0)
]
//------------------------------------------------
// End cap
//------------------------------------------------
EndCap(x z) ->
[
T(x 0.12 z)
S(1.1 0.2 1.1)
I(Cube shinymetal 0)
]
Empty ->
End ->