libraryextensions/scene/lib/Scene.xtl

Scene.xtl -- the facade of the scene extension: retained 3D line and point scenes in a native window, patched by id, the mouse orbiting. Import: "sc:" u_se< "Scene" Run with xetal-x, which links scene and serves its windows on the main thread (xetal-x --ext DIR puts this directory on XETAL_PATH). Each signature line is written out by the binding macro (lib/Ffi.xtlm).

source · imports ffi: lib/Ffi.xtlm

ˡo̲pen! : Num a => Char -> a -> Int

function · line 11

title sc:o_pen! width height: a scene window that size (points); its id.

"o_pen! : text float -> int"         ᶠᶠⁱb̲ind< "scene/open"
ᶠᶠⁱb̲ind< expands to
ˡo̲pen! ← { a b →
  pa ← a ⎕N̲PUT "ext:scene/open?text"
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/open?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/open"
}
Used in: w, w, w, w, w, w, w, w, w

ˡp̲olyline! : (Num a, Num b) => a -> b -> Int

function · line 15

(scene c_at object c_at red green blue) sc:p_olyline! points: put object (an id of your choice) as points joined in order; points are an n by 3 matrix (x y z), colors 0 to 1. Putting an id again replaces it.

"p_olyline! : float float -> int"    ᶠᶠⁱb̲ind< "scene/polyline"
ᶠᶠⁱb̲ind< expands to
ˡp̲olyline! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/polyline?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/polyline?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/polyline"
}
Used in: ring

ˡs̲egments! : (Num a, Num b) => a -> b -> Int

function · line 17

header sc:s_egments! points: the points taken in pairs, each a segment.

"s_egments! : float float -> int"    ᶠᶠⁱb̲ind< "scene/segments"
ᶠᶠⁱb̲ind< expands to
ˡs̲egments! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/segments?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/segments?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/segments"
}
Used in: ᵘd̲raw, x, ᵘp̲ut

ˡd̲ots! : (Num a, Num b) => a -> b -> Int

function · line 19

header sc:d_ots! points: each point a dot.

"d_ots! : float float -> int"        ᶠᶠⁱb̲ind< "scene/dots"
ᶠᶠⁱb̲ind< expands to
ˡd̲ots! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/dots?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/dots?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/dots"
}
Used in: y

ˡq̲uads! : (Num a, Num b) => a -> b -> Int

function · line 23

header sc:q_uads! points: the points taken in fours, each the corners of a filled quad in order round it (4n by 3); shaded by how it faces the light, nearer quads hiding farther ones; lines and dots draw over.

"q_uads! : float float -> int"       ᶠᶠⁱb̲ind< "scene/quads"
ᶠᶠⁱb̲ind< expands to
ˡq̲uads! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/quads?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/quads?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/quads"
}

ˡf̲og! : (Num a, Num b) => a -> b -> Int

function · line 26

scene sc:f_og! near far: quads fade into the background between those depths (scene units from the camera); far <= near: no fog.

"f_og! : float float -> int"         ᶠᶠⁱb̲ind< "scene/fog"
ᶠᶠⁱb̲ind< expands to
ˡf̲og! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/fog?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/fog?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/fog"
}
Used in: g, g, g, g, g

ˡe̲ye! : (Num a, Num b) => a -> b -> Int

function · line 30

scene sc:e_ye! x y z yaw pitch: a first-person camera at the eye, looking along yaw (0 toward -z, turning right toward +x) and pitch (up positive), radians; sc:c_amera! goes back to orbiting.

"e_ye! : float float -> int"         ᶠᶠⁱb̲ind< "scene/eye"
ᶠᶠⁱb̲ind< expands to
ˡe̲ye! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/eye?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/eye?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/eye"
}
Used in: ˡm̲ove, ᵘs̲tep, e

ˡc̲urve! : (Num a, Num b) => a -> b -> Int

function · line 34

scene sc:c_urve! radius: a curved horizon for the first-person camera -- the world lowered by d^2 / 2R at a distance d along the ground from the eye, as on a small planet; 0 turns it off.

"c_urve! : float float -> int"       ᶠᶠⁱb̲ind< "scene/curve"
ᶠᶠⁱb̲ind< expands to
ˡc̲urve! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/curve?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/curve?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/curve"
}
Used in: k, k

ˡs̲ky! : (Num a, Num b) => a -> b -> Int

function · line 37

scene sc:s_ky! red green blue: the background, which fog fades to (0 to 1); -1 -1 -1 goes back to the dark default.

"s_ky! : float float -> int"         ᶠᶠⁱb̲ind< "scene/sky"
ᶠᶠⁱb̲ind< expands to
ˡs̲ky! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/sky?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/sky?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/sky"
}
Used in: k, k

ˡc̲ontrols : Num a => a -> Float

function · line 42

sc:c_ontrols scene: how far the mouse was dragged since last asked (x y, pixels), then 1 or 0 for each key held -- w a s d space shift and the arrows left right up down. Headless, XETAL_EVENTS may hold "keydown w", "keyup w" and "drag 10 0".

"c_ontrols : float -> floats"        ᶠᶠⁱb̲ind< "scene/controls"
ᶠᶠⁱb̲ind< expands to
ˡc̲ontrols ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/controls?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:scene/controls"
  (f̲loor n̲umbers ⎕N̲GET "ext:scene/controls?shape") r̲eshape v
}

ˡr̲emove! : (Num a, Num b) => a -> b -> Int

function · line 44

scene sc:r_emove! object: 1 if it was there, else 0.

"r_emove! : float float -> int"      ᶠᶠⁱb̲ind< "scene/remove"
ᶠᶠⁱb̲ind< expands to
ˡr̲emove! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/remove?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/remove?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/remove"
}
Used in: ʰt̲rim

ˡc̲amera! : (Num a, Num b) => a -> b -> Int

function · line 47

scene sc:c_amera! yaw pitch distance spin: where the camera orbits from (radians, scene units) and how fast it turns by itself (radians a second).

"c_amera! : float float -> int"      ᶠᶠⁱb̲ind< "scene/camera"
ᶠᶠⁱb̲ind< expands to
ˡc̲amera! ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/camera?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/camera?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/camera"
}
Used in: c, k, k, k, k, k

ˡn̲ext! : Num a => a -> Char

function · line 50

sc:n_ext! scene: the next event, waiting at most a frame (1/60 s): "frame", "key Space", "key q", "close". Dragging orbits by itself.

"n_ext! : float -> text"             ᶠᶠⁱb̲ind< "scene/next"
ᶠᶠⁱb̲ind< expands to
ˡn̲ext! ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/next?float=" c̲at f̲ormat s̲hape a
  ⎕N̲GET "ext:scene/next"
}

ˡc̲lose! : Num a => a -> Int

function · line 52

sc:c_lose! scene: close the window; 1.

"c_lose! : float -> int"             ᶠᶠⁱb̲ind< "scene/close"
ᶠᶠⁱb̲ind< expands to
ˡc̲lose! ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/close?float=" c̲at f̲ormat s̲hape a
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/close"
}

ˡpackage : Char

value · line 55

The native package behind these functions.

ˡpackage ← "scene"