Last active
November 20, 2019 11:06
-
-
Save xge/ab2056c570060245914f1e9fb2a1fbe0 to your computer and use it in GitHub Desktop.
Using RNG and GridLayout to generate "terrain" in Woden.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Use woden and some RNG to generate a city in the sea." | |
| view light coarse floor fine tower rng layout | | |
rng := Random new. | |
view := RWView new. | |
view backgroundColor: (Color r: 0.1 g: 0.1 b: 0.1). | |
floor := RWCube new | |
width: 12; | |
height: [ :el | rng nextInt: 2 ]; | |
depth: 12; | |
color: Color lightBlue; | |
elementsOn: (1 to: 144). | |
view addAll: floor. | |
layout := RWXZGridLayout new. | |
layout gap: 0. | |
layout on: floor. | |
coarse := RWCube new | |
width: 4; | |
height: [ :el | #(3 4) atRandom ]; | |
depth: 4; | |
color: (Color r: 0.666 g: 0.666 b: 0.666); | |
elementsOn: (1 to: 576). | |
view addAll: coarse. | |
layout := RWXZGridLayout new. | |
layout gap: 0. | |
layout on: coarse. | |
fine := RWCube new | |
width: 2; | |
height: [ :el | (rng nextInt: 5) + 4 ]; | |
depth: 2; | |
color: Color gray; | |
elementsOn: (1 to: 331). | |
view addAll: fine. | |
layout := RWXZGridLayout new. | |
layout gap: 0. | |
layout on: fine. | |
tower := RWCube new | |
width: 2; | |
height: [ :el | (rng nextInt: 12) + 15 ]; | |
depth: 2; | |
color: Color white; | |
elementsOn: (1 to: 4). | |
view addAll: tower. | |
layout := RWXZGridLayout new. | |
layout gap: 0. | |
layout on: tower. | |
light := RWDirectionalLight new. | |
light lookDown; | |
translateByX: 4.0 y: 6.0 z: 10.0; | |
rotateByXDegrees: 45; | |
influenceRadius: 25.0; | |
castShadows: true. | |
view add: light. | |
view @ RWMouseKeyControl. | |
view withShadows. | |
view camera translateByX: 60.0 y: 1.0 z: 4.0. | |
view open. | |
"WDCEngine reset." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks good! Excellent script!
Here is the screenshot