sourceextensions/scene/demos/voxels-solid.xtl

1⍝# Voxels, 3: the chunk drawn solid. The same faces as voxels-faces, each 2⍝# now a filled quad -- its four corners from a 6 by 4 table by direction 3⍝# -- one object per kind of block; scene shades each by how it faces the 4⍝# light and hides the farther ones behind the nearer (a depth buffer), 5⍝# with a little fog. All the array work is X_eTaL's; Rust only draws. 6⍝# Run: just demo scene voxels-solid (drag to turn it; q or close: quit) 7 8ᵛˣ⁼u̲se< "Voxels" 9ˢᶜ⁼u̲se< "Scene" 10 11b ← ᵛˣc̲hunk ᵛˣh̲ills 0.0 12f ← ᵛˣf̲aces b 13"faces drawn, and the points sent for them (4 corners, 3 numbers each):" 14(t̲ally f) c̲at 12 × t̲ally f 15 16w ← "Voxels 3: solid -- X_eTaL" ˢᶜo̲pen! 560 560 17k ← w ˢᶜc̲amera! 0.7 0.5 3.4 0.35 18g ← w ˢᶜf̲og! 3.0 6.0 19 20⍝# each kind of block as one object of quads, in its color 21ᵘp̲ut ← { t → 22 sel ← (5 s̲elect₂ f) = t 23 0 = '+ r̲/ sel ? t + 1 24 head ← (f̲loat w c̲at t) c̲at (t + 1) s̲elect ᵛˣcolors 25 x ← head ˢᶜq̲uads! ᵛˣq̲uads sel r̲eplicate f 26 t + 1 27} 28put ← 7 'ᵘp̲ut p̲ower 1 29 30ᵘq̲uit ← { n → 31 z ← ˢᶜc̲lose! w 32 0 33} 34ᵘf̲rame ← { n → 35 n = 0 ? 0 36 v ← ˢᶜn̲ext! w 37 ((v m̲atch "close") + v m̲atch "key q") > 0 ? ᵘq̲uit n 38 n 39} 40last ← 100000 'ᵘf̲rame p̲ower 1 41"bye"