sourceextensions/scene/demos/voxels-chunk.xtl

1⍝# Voxels, 1: a chunk is an array. 16 by 16 by 16 block numbers built 2⍝# from a height field in a few array expressions -- grass, dirt, stone, 3⍝# water below a level, sand at its shore, one tree -- then counted, 4⍝# cut and seen from above. (docs/voxels.md; the next demos draw it.) 5⍝# Run: just demo scene voxels-chunk (pictures go to work/draw/) 6 7ᵛˣ⁼u̲se< "Voxels" 8 9h ← ᵛˣh̲ills 0.0 10"the height field (x across, z down), 3 to 12:" 11h 12b ← ᵛˣc̲hunk h 13s̲hape b 14"blocks of each kind:" 15ᵛˣnames 16ᵛˣc̲ounts b 17 18"the slice at x = 8, looking east (up is up):" 198 ᵛˣs̲ide b 20"the slice at x = 4, through the tree:" 214 ᵛˣs̲ide b 22 23"seen from above (the top block of each column):" 24t ← ᵛˣt̲op b 25t 26p ← ⎕S̲HOW ⎕G̲RID t 27p ← ⎕S̲HOW ⎕G̲RID r̲ev (1 + 8 s̲elect b) 28"drawn: the view from above, the slice at x = 8"