[Fluxus] state machine

Dave Griffiths dave at pawfal.org
Thu Feb 21 02:20:06 PST 2008


Hi Glauber

> Hi i just changed my mail cause the web interface of my isp mail account
> is a bit boring and i lose track of mails cause im not with my setup
> connected, sorry for the inconvenience, now i hope it will work :),

Not a problem - fwiw I hardly check the moderation requests any more due
to way too much spam.

> the thing is  cant understand exactly how i can program functions like
> build-cube as if it was draw-cube, down here im using build-text but the
> same thing would happen if it was a cube instead, it would draw millions
> of it makeing fluxus to become slow, could someone help me here ive
> already read the entire fluxus.texipaying attention to this topic and it
> is well documented i even think i understood it but i cant make it work so
> i cant say for sure i understood, thanks for any input i know this is a
> begginer question but im still one.

I think this is probably something that needs explaining better. It's
actually very hard for me to know what to spend time on when documenting,
so emails like this are valuable.

Ok, so your script is more or less doing the right thing, but I don't
think it's doing what you want. You don't need to bother with
draw-instance for this, and you are getting confused between defining
functions and values - but it shows you understand broadly what's going
on, give this a try (I haven't tested it):

(clear)
(define (clearall) (begin (clear) (clear-texture-cache)))
(define a "false")

(texture (load-texture "text1.png")) ; this should go before build
(define tek (build-text a)) ; (define (tek) ...) defines a function,
                            ; this defines tek to be the result of
                            ; (build...) - the primitive id number

(define (teste)
    (with-primitive tek ; switches the current state to that of tek
        (translate (vector 0 0 (* (sin (time)) 2)))))

(every-frame (teste))

Basically, scripts which use build-* and draw-* are designed differently.
Using draw-* is easier, as you draw each frame afresh, and you don't need
to worry about managing your scene.

Scripts using build-* have two parts, the first is the definition of the
scenegraph, which is run only once - and builds all the primitives you
need to use in the right order, parenting and assigning textures etc, you
also store the ids of the primitives you want to change later.

The second part is run every-frame and allows you to modify or animate the
primitives you've built, using the id's you've stored. This is a little
more work and conceptually it's harder to grasp, but it's a tradeoff
between flexibility (draw-*) and speed (build-*).

Keep asking questions,

dave




More information about the Fluxus mailing list