sourcelibs/Scene/demos/solids.xtl
1⍝!/usr/bin/env xetal
2⍝ Named declarations create bindings; ordinary functions animate and trace.
3"sc:" u̲se< "Scene"
4"rt:" u̲se< "RayTrace"
5"demo" ˢᶜs̲cene2< "group moving objects crystal ball\nsphere ball center 0 0 0 radius 1 material glass\nbox crystal size 1 2 1 material glass position 2 0 0\noctahedron gem radii 1 1 1 material gray position -2 0 0\nfloor ground origin -4 -2 -3 u 0 0 6 v 8 0 0 material gray\ndielectric glass color 1 1 1 transmission 1 ior 1.5 absorption .1 .1 .1\nmaterial gray color .5 .5 .5 reflection .1\ncamera eye 0 1 6 target 0 0 0 up 0 1 0 fov .8"
6transforms ← (((demopivots ˢᶜr̲otateGroup 2) 0.35) demotransforms)
7triangles ← ((demotriangles ˢᶜa̲pplyGroups demogroupids) transforms)
8spheres ← ((demospheres ˢᶜa̲pplySphereGroups demospheregroupids) transforms)
9pixels ← r̲ange 32
10origins ← democamera ʳᵗo̲rigins 32
11directions ← ((democamera ʳᵗr̲ays 8 4) pixels)
12clip ← 0.001 100.0 1e-10 0.0001
13ids ← ((((((clip ʳᵗm̲ixedNearest triangles) spheres) demotriangleids) demosphereids) origins) directions)
14"Global primitive IDs, zero means miss:"
154 8 r̲eshape ids
16"Geometry kinds (1 triangle, 2 sphere), separate from local indices:"
174 8 r̲eshape ((demotriangleids ʳᵗh̲itKinds demosphereids) ids)
18"Local indices within each kind:"
194 8 r̲eshape ((demotriangleids ʳᵗh̲itLocals demosphereids) ids)
20"Dielectric parameters are scene data; this example traces geometry only."
ˢᶜs̲cene2< expands to
demotriangles ← 22 3 3 r̲eshape 1.5 1.0 0.5 1.5 -1.0 0.5 2.5 -1.0 0.5 2.5 -1.0 0.5 2.5 1.0 0.5 1.5 1.0 0.5 2.5 -1.0 -0.5 1.5 -1.0 -0.5 1.5 1.0 -0.5 1.5 1.0 -0.5 2.5 1.0 -0.5 2.5 -1.0 -0.5 1.5 -1.0 -0.5 2.5 -1.0 -0.5 2.5 -1.0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 0.0 0.0 0.0 0.0 0.0 democamera ← 10 r̲eshape 0.0 1.0 6.0 0.0 0.0 0.0 0.0 1.0 0.0 0.8 demolights ← 0 6 r̲eshape 0.0 demotriangleids ← 22 r̲eshape 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 demosphereids ← 1 r̲eshape 1 demotriangleobjectids ← 22 r̲eshape 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 0 0 demosphereobjectids ← 1 r̲eshape 1 demospherematerialids ← 1 r̲eshape 1 demospheregroupids ← 1 r̲eshape 2 demosceneversion ← 2 demolens ← 2 r̲eshape 0.0 1.0 demoemitters ← 0 3 3 r̲eshape 0.0 demoemitterradiance ← 0 3 r̲eshape 0.0 demospheres ← 1 4 r̲eshape 0.0 0.0 0.0 1.0 demomaterialkind ← 2 r̲eshape 1 0 demooptics ← 2 5 r̲eshape 1.0 1.5 0.1 0.1 0.1 0.0 1.0 0.0 0.0 0.0 demoemission ← 2 3 r̲eshape 0.0 0.0 0.0 0.0 0.0 0.0