programextensions/scene/demos/voxels-solid.xtl

Voxels, 3: the chunk drawn solid. The same faces as voxels-faces, each now a filled quad -- its four corners from a 6 by 4 table by direction -- one object per kind of block; scene shades each by how it faces the light and hides the farther ones behind the nearer (a depth buffer), with a little fog. All the array work is X_eTaL's; Rust only draws. Run: just demo scene voxels-solid (drag to turn it; q or close: quit)

source · imports vx: extensions/scene/demos/Voxels.xtl; sc: extensions/scene/lib/Scene.xtl

b : Int

value · line 11
b ← ᵛˣc̲hunk ᵛˣh̲ills 0.0
Used in: f

f : Int

value · line 12
f ← ᵛˣf̲aces b

w : Int

value · line 16
w ← "Voxels 3: solid -- X_eTaL" ˢᶜo̲pen! 560 560

k : Int

value · line 17
k ← w ˢᶜc̲amera! 0.7 0.5 3.4 0.35

g : Int

value · line 18
g ← w ˢᶜf̲og! 3.0 6.0

ᵘp̲ut : Int -> Int

function · line 21

each kind of block as one object of quads, in its color

ᵘp̲ut ← { t →
  sel ← (5 s̲elect₂ f) = t
  0 = '+ r̲/ sel ? t + 1
  head ← (f̲loat w c̲at t) c̲at (t + 1) s̲elect ᵛˣcolors
  x ← head ˢᶜq̲uads! ᵛˣq̲uads sel r̲eplicate f
  t + 1
}
Used in: put

put : Int

value · line 28
put ← 7 'ᵘp̲ut p̲ower 1

ᵘq̲uit : (Any a, Num b) => a -> b

function · line 30
ᵘq̲uit ← { n →
  z ← ˢᶜc̲lose! w
  0
}
Used in: ᵘf̲rame

ᵘf̲rame : Num a => a -> a

function · line 34
ᵘf̲rame ← { n →
  n = 0 ? 0
  v ← ˢᶜn̲ext! w
  ((v m̲atch "close") + v m̲atch "key q") > 0 ? ᵘq̲uit n
  n
}
Used in: last

last : Int

value · line 40
last ← 100000 'ᵘf̲rame p̲ower 1