Next: , Previous: Renderer, Up: Functions



12.3 GlobalState

Global state is really anything that controls the renderer globally, so it affects all primitives or controls the renderer directly - ie camera control or full screen effects like blurring.

Example
     

12.3.1 (clear-engine)

Returns

void

Description

Clears the renderer, and physics system. This command should not be called directly, use clear instead, as this clears a few other things, and calls clear-engine itself.

Example
      (clear-engine) ; woo hoo!
     

12.3.2 (blur amount-number)

Returns

void

Description

Sets the full screen blur setting. Less is more, but if you set it too low it will make the on screen editing impossible to read, so save your script first :)

Example
      (blur 0.1) ; for nice trails
     

12.3.3 (fog fogcolour-vector amount-number begin-number end-number)

Returns

void

Description

Sets the fogging parameters to give a visual depth cue (aerial perspective in painter's jargon). This can obscure the on screen editing, so keep the amount small.

Example
      (clear-colour (vector 0 0 1))   ; looks nice if the background matches
      (fog (vector 0 0 1) 0.01 1 100) ; blue fog
     

12.3.4 (feedback amount-number)

Returns

void

Description

Full screen feedback for Jeff Minter style crazyness (renders the last frame in the background, including the previous feedback background...). This allocates large amounts of texture space and seems to be unstable, so it's probably better not to use it. If you do, use with feedback-transform, but don't say I didn't warn you.

Example
      (feedback 0.1) ; set the feedback amount
      (build-cube)
      (define (animate)
          (feedback-transform (mrotate (vector 1 1 (* 45 (sin (time))))))) ; change the transform
      (every-frame (animate))
     

12.3.5 (feedback-transform matrix-vector)

Returns

void

Description

Sets the transform for the feedback plane. See feedback for more details, probably shouldn't be used.

Example
      (feedback 0.1) ; set the feedback amount
      (build-cube)
      (define (animate)
          (feedback-transform (mrotate (vector 1 1 (* 45 (sin (time))))))) ; change the transform
      (every-frame (animate))
     

12.3.6 (show-axis show-number)

Returns

void

Description

Shows the worldspace origin axis. used.

Example
      (show-axis 1)
     

12.3.7 (show-fps show-number)

Returns

void

Description

Shows an fps count in the lower left of the screen. used.

Example
      (show-fps 1)
     

12.3.8 (lock-camera primitiveid-number)

Returns

void

Description

Locks the camera transform onto the specified primitive's transform. It's like parenting the camera to the object. This is the easiest way to procedurally drive the camera. Use an id number of 0 to unlock the camera.

Example
      (clear)
      (define obj (build-cube)) ; make a cube for the camera to lock to
     
      (push) ; make a background cube so we can tell what's happening
      (hint-wire)
      (hint-unlit)
      (colour (vector 0 0.4 0))
      (scale (vector -50 -50 -50))
      (build-cube)
      (pop)
     
      (lock-camera obj) ; lock the camera to our first cube
     
      (define (animate)
          (grab obj)
          (rotate (vector 1 0 0)) ; rotate the cube
          (ungrab))
     
      (every-frame (animate))
     

12.3.9 (camera-lag amount-number)

Returns

void

Description

The camera locking has an inbuilt lagging which means it will smoothly blend the movement relative to the primitive it's locked to.

Example
      (clear)
      (define obj (build-cube)) ; make a cube for the camera to lock to
     
      (push) ; make a background cube so we can tell what's happening
      (hint-wire)
      (hint-unlit)
      (colour (vector 0 0.4 0))
      (scale (vector -50 -50 -50))
      (build-cube)
      (pop)
     
      (lock-camera obj) ; lock the camera to our first cube
      (camera-lag 0.1)  ; set the lag amount, this will smooth out the cube jittery movement
     
      (define (animate)
          (grab obj)
          (identity)
          (translate (vector (modulo (round (inexact->exact (time))) 6) 0 0)) ; make a jittery movement
          (ungrab))
     
      (every-frame (animate))
     

12.3.10 (load-texture pngfilename-string)

Returns

textureid-number

Description

Loads a texture from disk, converts it to a texture, and returns the id number. The texture loading is memory cached, so repeatedly calling this will not cause it to load again. Use force-load-texture if you are changing the texture while running the script. The png may be RGB or RGBA to use alpha transparency.

Example
      (texture (load-texture "mytexture.png"))
      (build-cube) ; the cube will be texture mapped with the image
     

12.3.11 (load-texture pngfilename-string)

Returns

textureid-number

Description

Uncached loading of textures from disk, converts it to a texture, and returns the id number. Useful if you are changing the texture while running the script, otherwise use load-texture, which will be much faster. The png may be RGB or RGBA to use alpha transparency.

Example
      (texture (force-load-texture "mytexture.png"))
      (build-cube) ; the cube will be texture mapped with the image
     

12.3.12 (frustum top-number bottom-number left-number right-number)

Returns

void

Description

Sets the camera frustum, and thus the aspect ratio of the frame.

Example
      (frustum -1 1 -0.75 0.75) ; default settings
     

12.3.13 (clip front-number back-number)

Returns

void

Description

Sets the front & back clipping planes for the camera frustum, and thus the viewing angle. Change the front clipping distance to alter the perspective from telephoto to fisheye.

Example
      (clip 1 10000) ; default settings
     

12.3.14 (ortho)

Returns

void

Description

Sets orthographic projection - i.e. no perspective.

Example
      (ortho)
     

12.3.15 (persp)

Returns

void

Description

Sets perspective projection (the default) after ortho has been set.

Example
      (persp)
     

12.3.16 (set-ortho-zoom amount-number)

Returns

void

Description

Sets the zoom level for the orthographic projection.

Example
      (set-ortho-zoom 2)
     

12.3.17 (backfacecull setting-number)

Returns

void

Description

Turns backface culling on or off. Backface culling speeds up rendering by removing faces not orientated towards the camera. Defaults to on, but this is not always desired, eg for double sided polygons.

Example
      (backfacecull 0)
     

12.3.18 (clear-colour colour-vector)

Returns

void

Description

Sets the colour we clear the renderer with, this forms the background colour for the scene.

Example
      (clear-colour (vector 1 0 0)) ; RED!!!
     

12.3.19 (clear-frame setting-number)

Returns

void

Description

Sets the frame and zbuffer clearing on or off.

Example
      (clear-frame 0)
     

12.3.20 (get-camera)

Returns

matrix-vector

Description

Gets the current camera transform matrix. This is the low level function, use get-camera-transform instead.

Example
      (get-camera)
     

12.3.21 (set-camera)

Returns

void

Description

Sets the camera transform matrix. This is the low level interface used by set-camera-transform, which you should generally use instead.

Example
      (set-camera)
     

12.3.22 (get-projection-transfrom)

Returns

projection-matrix

Description

Gets the current projection matrix.

Example
      (get-projection-transfrom)
     

12.3.23 (get-screen-size)

Returns

size-vector

Description

Returns a vector containing the current width and height of the window.

Example
      (get-screen-size)
     

12.3.24 (set-screen-size size-vector)

Returns

void

Description

Sets the window width and height.

Example
      (set-screen-size (vector 10 10)) ; small window time :)
     

12.3.25 (select screenxpos-number screenypos-number pixelssize-number)

Returns

primitiveid-number

Description

Looks in the region specified and returns the id of the closest primitive to the camera rendered there, or 0 if none exist.

Example
      (display (select 10 10 2))(newline)
     

12.3.26 (desiredfps fps-number)

Returns

void

Description

Throttles the renderer so as to not take 100% cpu. This gives an upper limit on the fps rate, which doesn't quite match the given number, but I'm working on it...

Example
      (desiredfps 100000) ; makes fluxus render as fast as it can, and take 100% cpu.