The local state functions control rendering either for the current state - or the state of the currently grabbed primitive. In fluxus state means the way that things are displayed, either turning on and off rendering features, changing the style of different features, or altering the current transform.
void
Pushes a copy of the current drawing state to the top of the stack. The drawing state contains information about things like the current colour, transformation and hints.
(colour (vector 1 0 0)) ; set current colour to red (push) ; copy and push drawing state (colour (vector 0 1 0)) ; set current colour to green (draw-cube) ; draws a green cube (pop) ; forget old drawing state ; current colour is now red again
void
Destroys the current drawing state, and sets the current one to be the previously pushed one in the stack. The drawing state contains information about things like the current colour, transformation and hints.
(colour (vector 1 0 0)) ; set current colour to red (push) ; copy and push drawing state (colour (vector 0 1 0)) ; set current colour to green (draw-cube) ; draws a green cube (pop) ; forget old drawing state ; current colour is now red again
void
Grabs the specified object. Once an object has grabbed it's state can be modified using the same commands used to set the current drawing state. (ungrab) needs to be used to return to the normal drawing state. Grabbing can also be stacked, in which case ungrab pops to the last grabbed primitive.
(colour (vector 1 0 0)) ; set the current colour to red (define mycube (build-cube)) ; makes a red cube (grab mycube) (colour (vector 0 1 0)) ; sets the cubes colour to green (ungrab) ; return to normal state
void
Ungrabs the currently grabbed object, and either returns to the normal drawing state, or pops to the last grabbed primitive.
(colour (vector 1 0 0)) ; set the current colour to red (define mycube (build-cube)) ; makes a red cube (grab mycube) (colour (vector 0 1 0)) ; sets the cubes colour to green (ungrab) ; return to normal state
void
Applies the current object transform to the vertex positions of the supplied object and sets it's transform to identity.
(rotate (vector 45 0 0)) (define mycube (build-cube)) ; makes a cube with a rotation (apply mycube) ; applies the rotation to the points of the cube
void
Sets the opacity of the current drawing state, or the currently grabbed primitive.
(opacity 0.5) (define mycube (build-cube)) ; makes a half transparent cube
void
Sets the shinyness of the current drawing state, or the currently grabbed primitive. This value sets the tightness of the specular highlight.
(shinyness 100) (specular (vector 1 1 1)) ; sets the specular colour (define mysphere (build-sphere 10 10)) ; makes a shiny cube
void
Sets the colour of the current drawing state, or the currently grabbed primitive.
(colour (vector 1 0.5 0.1)) ; mmm orange... (define mycube (build-cube)) ; makes an orange cube
void
Sets the wire frame colour of the current drawing state, or the currently grabbed primitive. Visible with (hint-wire) on most primitives.
(wire-colour (vector 1 1 0)) ; set yellow as current wire colour (hint-wire) (define mycube (build-cube)) ; makes a cube with yellow wireframe
void
Sets the specular colour of the current drawing state, or the currently grabbed primitive.
(specular (vector 0 0 1)) ; set blue as specular colour (define mysphere (build-sphere 10 10)) ; makes a shiny blue sphere
void
Sets the ambient colour of the current drawing state, or the currently grabbed primitive.
(ambient (vector 0 0 1)) ; set blue as ambient colour (define mysphere (build-sphere 10 10)) ; makes a boringly blue sphere
void
Sets the emissive colour of the current drawing state, or the currently grabbed primitive.
(emissive (vector 0 0 1)) ; set blue as emissive colour (define mysphere (build-sphere 10 10)) ; makes an bright blue sphere
void
Sets the drawing state transform to identity, on the state stack, or the currently grabbed primitive.
(push) (scale (vector 2 2 2)) ; set the current scale to double in each dimension (define mycube (build-cube)) ; make a scaled cube (pop) (grab mycube) (identity) ; erases the transform and puts the cube back to its original state (ungrab)
void
Concatenates (multiplies) a matrix on to the current drawing state or grabbed primitive.
(define mymatrix (mrotate (vector 0 45 0))) ; make a matrix (concat mymatrix) ; concat it into the current state (build-cube) ; make a cube with this rotation
void
Applies a translation to the current drawing state transform or grabbed primitive.
(transform (vector 0 1.4 0)) ; translates the current transform up a bit (build-cube) ; build a cube with this transform
void
Applies a rotation to the current drawing state transform or grabbed primitive.
(rotate (vector 0 45 0)) ; turns 45 degrees in the Y axis (build-cube) ; build a cube with this transform
void
Applies a scale to the current drawing state transform or grabbed primitive.
(scale (vector 0.5 0.5 0.5)) ; scales the current transform to half the size (build-cube) ; build a cube with this transform
matrix-vector
Returns: a matrix representing the current state transform or for the grabbed primitive.
(translate (vector 1 0 0)) (display (get-transform))(newline) ; prints the current transform (define shape (build-sphere 10 10)) (grab shape) (translate (vector 0 1 0)) (display (get-transform))(newline) ; prints shape's transform (ungrab)
void
Parents the currently grabbed primitive to the supplied parent primitive. The current primitive will now be moved around with the parent by aquiring all the parent's transforms.
(define parent-prim (build-cube)) ; make a parent cube (translate (vector 2 0 0)) ; move a bit in x (parent parent-prim) ; set parent-prim as the current parent (define child-prim (build-cube)) ; make a child cube (grab parent-prim) (rotate (vector 0 45 0)) ; the child will now be moved by this transform in addition to its own (ungrab)
void
Sets the line width (in screen space) of the current drawing state, or the currently grabbed primitive. Affects wireframe and things like that.
(line-width 5) (hint-wire) (build-sphere 10 10) ; make a sphere with thick wireframe
void
Sets the point width (in screen space) of the current drawing state, or the currently grabbed primitive. Affects point rendering and particles in hardware point mode.
(point-width 5) (hint-points) (build-sphere 10 10) ; make a sphere with thick points
void
Sets the blend mode of the current drawing state, or the currently grabbed primitive. This is the way that alpha is composited to the rendering surface.
(point-width 5) (hint-points) (build-sphere 10 10) ; make a sphere with thick points
void
Sets the render hints to solid of the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-solid) ; this is the default render style so this isn't too exciting (build-cube) ; make a solid rendered cube
void
Sets the render hints to wireframe of the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-wire) (build-cube) ; make a wirefame rendered cube
void
Sets the render hints to display normals in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-normal) (build-cube) ; display the normals on this cube
void
Sets the render hints to display points in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-points) (build-cube) ; display the vertex points on this cube
void
Sets the render hints to anti-alias in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-anti-alias) (build-cube) ; display a smoothed cube
void
Sets the render hints to unlit in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-unlit) (build-cube) ; display an unlit cube
void
Sets the render hints to use vertex colours in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint. Vertex colours override the current (colour) state.
(hint-vertcols) (define mycube (build-cube)) ; make a cube with vertcols enabled (grab mycube) (pdata-set "c" 0 (vector 0 1 0)) ; set the colour of the first vertex to green (ungrab)
void
Sets the render hints to bounding box display in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-box) (build-sphere 10 10) ; make a sphere with bounding box displayed
void
Sets the render hints to use multitexturing in the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-multitexture) (multitexture 0 (load-texture "tex1.png")) (multitexture 1 (load-texture "tex2.png")) (build-sphere 10 10) ; make a sphere with overlayed textures
void
Clears the render hints in the current drawing state, or the currently grabbed primitive. This allows you mainly to get rid of the default solid style, but also means that you can turn on and off hints without using push or pop.
(hint-none) (hint-wire) (build-cube) ; make a cube only visible with wireframe
void
Sets the render hints to display the object space origin of the primitive the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-origin) (build-sphere 10 10) ; make a sphere with the origin displayed
void
(note: Not yet implemented) Sets the render hints to cast shadows for the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint.
(hint-origin) (build-sphere 10 10) ; make a sphere with the origin displayed
void
Sets the render hints to ignore depth tests for the current drawing state, or the currently grabbed primitive. Render hints change the way that primitives are rendered, but may have different effects - or no effect on certain primitive types, hence the name hint. This feature is useful for rendering transparent objects, as it means objects will be shown behind previously rendered ones.
(hint-origin) (build-sphere 10 10) ; make a sphere with the origin displayed
void
Sets the texture of the current drawing state, or the currently grabbed primitive. Texture ids can be generated by the load-texture function.
(texture (load-texture "mytexture.png")) (build-sphere 10 10) ; make a sphere textured with mytexture.png
void
Sets the texture of the current drawing state, or the currently grabbed primitive in the same way as the texture function, but allows you to specify the texture unit (0-7) to apply the texture to. Multitexturing allows you to apply different textures and texture coordinates to the same object at once. Texture unit 0 is the default one (which uses the pdata "t" for it's texture coords) texture unit n looks for pdata "tn" - ie multitexture 1 looks for "t1". You need to add these yourself using (pdata-add) or (pdata-copy). Multitexturing is useful when the textures contain alpha, as they can be overlayed, i.e. decals placed on background textures. Note: fluxus needs to be built using scons MULTITEXTURE=1 to enable this feature.
(define obj (build-sphere 10 10)) ; make a sphere (grab obj) (multitexture 0 (load-texture "mytextureA.png")) (multitexture 1 (load-texture "mytextureB.png")) (pdata-add "t1" "v") ; make some texture coords for texture B (pdata-copy "t" "t1") ; copy them from the default texture coords (ungrab)
void
Prints out the current scene graph, useful for debugging.
(print-scene-graph) ; exciting...
void
Sets the hidden state for the grabbed primitive (also affects all child primitives). Hidden primitives can be treated as normal in every way - they just won't be rendered.
(define obj (build-cube)) (grab obj) (hide 1) ; hide this cube (ungrab)
void
Sets whether the grabbed primitive can be selected or not using the select command.
(define obj (build-cube)) (grab obj) (selectable 0) ; now it won't be "seen" by calling select (ungrab)
void
Loads, compiles and sets the GLSL harware shader pair for the current drawing state, or the currently grabbed primitive. Requires OpenGL 2 support. The shader's uniform data can be controlled via shader-set! and all the pdata is sent through as per-vertex attribute data to the shader.
(push) ; assign the shaders to the surface (shader "simplevert.glsl" "simplefrag.glsl") (define s (build-sphere 20 20)) (pop) (grab s) ; add and set the pdata - this is then picked up in the vertex shader ; as an input attribute called "testcol" (pdata-add "testcol" "v") (set-cols (pdata-size)) (ungrab) (define (animate) (grab s) ; animate the deformamount uniform input parameter (shader-set! (list "deformamount" (cos (time)))) (ungrab)) (every-frame (animate))
void
Sets the uniform shader parameters for the GLSL shader. The list consists of token-string value pairs, which relate to the corresponding shader parameters names and values.
(push) ; assign the shaders to the surface (shader "simplevert.glsl" "simplefrag.glsl") (define s (build-sphere 20 20)) (pop) (grab s) ; add and set the pdata - this is then picked up in the vertex shader ; as an input attribute called "testcol" (pdata-add "testcol" "v") (set-cols (pdata-size)) (ungrab) (define (animate) (grab s) ; animate the deformamount uniform input parameter (shader-set! (list "deformamount" (cos (time)))) (ungrab)) (every-frame (animate))