Fluxus on Android

I recently took a long train journey and had an idea to use my android phone for taking timelapse photos for Miska Knapek. I had no laptop with me, and realised there was no way I could script anything on the phone itself to do this, or anything more complex. This was the kernel of an idea that ended up as two intense days of hacking fluxus into android.

It’s running as native code (underneath the JVM), and as it’s got the same type of processor as the NDS it shares some code with Betablocker DS which has similar restrictions. There is only a tiny amount of fluxus code ported at the moment, but the scenegraph and core maths is pretty much the same (with some changes to fixed point). I’ve used TinyScheme for the interpreter (the same one Impromptu is based on) which gives you an impressively complete language with a very small footprint.

This is just a quick proof of concept (how far I got is testament to the excellent documentation and ease of portability using C++ with the NDK more than my abilities). It would be nice to expose all the sensors to the script (motion, compass, GPS, camera, wifi) and make it quite general purpose. Writing code with the touch screen is do-able but not very usable – but I have some ideas in this area also…

Get the source and, of course the package. Touch the screen when it’s started up to view and eval the source.

Cloth simulation with NURBS

Another fluxus friday adventure…

; a simple realtime cloth simulation model
(clear)
(texture (load-texture "test2.png"))

(define rez 25) ; resolution of nurbs patch
(define dist 0.1) ; the desired spring length

(define p ; setup the nurbs primitive
    (with-state
        (backfacecull 0) ; we wanna see the back
        (ambient 0.2)
        (rotate (vector -90 0 0))
        (scale (vector 8 4 4))
        (build-nurbs-plane (- rez 1) (- rez 1))))

(with-primitive p (pdata-add "vel" "v"))

(define (spring a b) ; return vector trying to keep the length
    (let ((d (vsub a b))) ; between the two input points constant
        (vmul d (- dist (vmag d)))))

(every-frame
    (with-primitive p
        (pdata-index-map! ; for each control vertex
            (lambda (i v p)
                (let ((x (modulo i rez)) ; get the x and y from
                      (y (quotient i rez))) ; the index
                    (if (> x 0)
                        ; we want to 'pin' the top row of cvs 
                        (vmul (vadd v
                                (spring p (pdata-ref "p" (- i 1)))
                                (if (< x (- rez 1)) ; deal with the edges
                                    (spring p (pdata-ref "p" (+ i 1)))
                                    (vector 0 0 0))
                                (if (> y 0)
                                    (spring p (pdata-ref "p" (- i rez)))
                                    (vector 0 0 0))
                                (if (< y (- rez 1))
                                    (spring p (pdata-ref "p" (+ i rez)))
                                    (vector 0 0 0))
                                ; add constant gravity 
                                (vector 0 0 -0.001))
                            0.995) v)))
            "vel" "p")
        (pdata-op "+" "p" "vel") ; add velocity to the vertex positions
        (recalc-normals 1))) 

; setup the lights
(light-diffuse 0 (vector 0 0 0))
(define l (make-light 'point 'free))
(light-diffuse l (vector 1 1 1))
(light-position l (vector 10 300 -10))
(light-specular l (vector 1 1 1))
(light-ambient l (vector 0.3 0.3 0.3))

Diffusion-limited aggregation with particles

Trying to reinstate “fluxus friday” where I reserve some time for livecoding or fluxus hacking at the end of the week. First up, a new way of making fuzzy blobs in fluxus – particle aggregation. I like the analogue feel to it – reminds me of the voxels from last year. I also found this for syntax highlighting lisp for blog posts.

; a blurry particle aggregation example
(clear)
(hint-depth-sort)
(texture (load-texture "splat.png"))
(blend-mode 'src-alpha 'one)
(define p (build-particles 500))
(define r 1)

; setup the particle primitive
(with-primitive p
    (pdata-add "a" "f") ; 1 if we have attached to another particle
    (pdata-add "vel" "v") ; velocity array
    (pdata-map! (lambda (a) 0) "a") ; init to zero
    (pdata-set! "a" 0 1)
    (pdata-map! (lambda (c) 0.1) "c") ; init the colour
    (pdata-map!
        (lambda (p)
            (vmul (hsrndvec) r)) ; space out in a hollow sphere
        "p")
    (pdata-map!
        (lambda (vel p)
            (vector 0.02 0 0)) ; init velocities
        "vel" "p")
    (pdata-set! "p" 0 (vector 0 0 0)))

; check particle n against all others and return #t if we
; are close enouth to another to aggregate
(define (collide? n)
    (let ((np (pdata-ref "p" n)))
        (pdata-index-fold
            (lambda (i p a r)
                (if (and (not r) (not (zero? a)) (not (eq? i n)) (< (vdist p np) 0.05))
                    #t r))
            #f "p" "a")))

(every-frame
    (with-primitive p
        (pdata-map!
            (lambda (p vel a)
                (if (zero? a) ; if we're not attached
                    (if (> (vmag p) r) ; and we are outside the sphere
                        (vmul (hsrndvec) r) ; reset position
                        (vadd p vel)) ; move with velocity
                     p))
            "p" "vel" "a")
        (pdata-index-map! ; check all particles and set a if they
            (lambda (i a) ; have attached to any others
                (if (and (zero? a) (collide? i)) 1 a))
            "a")))

Al Jazari bootable USB version

I’ve been preparing an Al Jazari installation (split screen, 4 player livecoding action) for the funware exhibition at MU – part of the STRP festival. Due to various difficulties with my nordic location, we’ve decided to try getting it running on a bootable USB stick, which I can send via post, and can be run on any computer with no setup required (other than plugging in the gamepads). We will see how this turns out.

Using pure:dyne it was much easier to set up than I’d anticipated. Using this operating system as a base, which helpfully includes fluxus and fluxa already – I could add the script, textures and samples for the installation to the user data partition of the usb stick.

Then I added a .xprofile script to the home directory of the default user (lintian) containing:


cd /live/image/al-jazari-inst
./start

Where “start” is another bash script which does most of the startup work:


./stop  # kills all the processes involved to make sure we don't clash
xrandr --output VGA1 --mode 1024x768 # force a maximum resolution
xset dpms 0 0 0 # turn off the hardware screen blanking
xset s 0 # turn of software screen blanking
sleep 2 # I'm a bit overzealous with these pauses perhaps
jackd -R -t 4999 -dalsa -r44100 -p4096 -n3 -P -s -o2 -S & # start jack
sleep 2
fluxa & # start fluxus's audio server/synth
sleep 2
./bin/oscjoy 127.0.0.1:4444 & # run the joypad to osc program
sleep 2
# run fluxus with hidden mouse, full screen and execute script on startup
fluxus -hm -fs -x aljazari-mp.scm

Notice that fluxus blocks (no & at the end of the line). This prevents the window manager starting up, which means fluxus is running directly on X. Puredyne runs a very minimal wm by default (xfwm4) so the reason isn’t really performance, but rather that there are no window positioning algorithms to mess up when fluxus goes full screen, or decorations or borders either.

LazyBotz

I’m still trying to work out exactly how to livecode this, but I’ve written a little language for building robots in fluxus:


(Audio: “Dang Spot” by Plaid)

These fellows were premiered at Lazy Sunday yesterday, raving to DJ Conehead’s early 90s hardcore techno lushness.

The idea (inspired by Gabor Papp’s marching maggots) was to make a high level language in fluxus which takes care of all the physics operations – automatically creating active objects and joints in ODE. The code can be found here.

Fluxus 0.17

Fluxus is a 3D game engine for livecoding worlds into existence.

“act of a flowing; a continuous moving on or passing by, as of a flowing
stream; a continuous succession of changes”

We spent too long livecoding and forgot to do any releases, so this is
your semi-annual fluxus release fanfare:

Changes:

* Render to texture makes recursive worlds possible
* Freeframe plugins supported
* Windows support
* OpenAL 3D sound playback
* AR/Camera module
* Planetarium/dome projection
* Livecode text effects to confuse your audiences
* Experimental voxel primitive
* Icosphere primitive
* Unicode support in the scratchpad
* Some proper games stuff – frustum culling, scene inspection etc.
* Stereo panning in fluxa.

Get it here:

http://www.pawfal.org/fluxus/packages/

Pixelache #2: Kerava groworld installation

Lina Kusaite and I installed the groworld project as part of Camp Pixelache at Kerava Art Museum. It was the first time the plant eyes game had been exposed to so many public – but as I’ve come to expect, younger visitors needed surprisingly little explanation to figure out how to play (i.e. none), while older people needed a little help. It was also the first showing of the huge pataforest drawing.

The arduino and plant sensor worked constantly throughout the day (not surprising as it’s sister has been working tirelessly for months) feeding the game with environmental information from the test subject plant – a pink Gerbera.

The camp in general was an interesting experience. The day started (after some last minute setup) with barcamp style discussions – I took part in one on Art and renewable energy before having to switch modes and present Fluxus and talk about livecoding with Gabor as part of the puredyne sprint debriefing. It was good to connect the two threads by using the groworld installation downstairs as an example of fluxus being used.

Aymeric Mansoux presenting the puredyne penknife.

Pixelache #1 Suomenlinna puredyne sprint

Part one of my pixelache experience was on the ice surrounded island of Suomenlinna, where Gabor and I spent 3 days working on fluxus. With the help of the puredyne sprint team we got the debian packaging working on launchpad – which is Ubuntu’s system for organising software packages and making sure they build on the various architectures and Ubuntu OS versions. We now have a fluxus ppa so people running a debian based system can directly get updates from us with apt-get upgrade.

We also spent a little time discussing the situation with proprietary graphics card drivers and Linux. This has recently become a personal matter, as my graphics card is no longer supported by ATI for current Linux kernels. We talked about avoiding locked away features as artistic constraint, and looked at people trying to do something about this like the xorg crack pushers and phoronix. One plan is to make the more cutting edge xorg code availible as a puredyne package so we can quickly test these free software drivers for installations and performances.

Kansallisteatteri Building Projection

The Kansallisteatteri is the Finnish National Theatre, and thanks to Miska Knapek and Ville Hyvönen I have the opportunity to try a quick bit of building projection as part of the Pixelache festival. I’m going to try growing plants from bits of the building that seeds would be able to rest on (i.e. any upward facing surfaces):

This is a test animation for the growing – they look quite a lot better now, but I like the style of this movie: