[Fluxus] Question (attempt 2, please ignore the previous incomplete message)

Dave Griffiths dave at pawfal.org
Tue Jun 29 00:41:26 PDT 2010


Hi Hugo,

On Tue, 2010-06-29 at 07:23 +0000, Hugo van Galen wrote:
> 
> - I want to manipulate its size and rotation.
>     So far, not a problem. After I 'build-cube' I manipulate this
> with:
> 
>       (with-primitive cube
>             (rotate (vector rotation rotation rotation))
>             (scale 1.2)
>       )
> 
>    Doing that every-frame will grow the primitive too large to display
> in the window, so it mans that this scale of 1.2 is 'multiplied'
> against the primitives current scale factor. 

Yes, all the transforms are compounded on top of one another, rotation
and translate too.

> That effect was 'interesting' so I kept it in. Then I ran into the
> problem I am trying to find a solution for:
> 
> - At a certain point, I want to "re-set" all the cubes to their
> initial size, i.e. "scale = 1".  This, without reseting its position
> and/or rotation. So the (identity) call is not what I am looking for
> (or is it?)].

Yes it is. If you want to set translate, rotate and scale in absolute
terms then you need to call (identity) each frame before setting them. 

> I have taken a look at all the various examples but there doesn't seem
> to be anything resembling what I'm trying to do here (and I cannot
> imagine me being the first trying). Iit seems to me that, if (scale
> 1.5) increases the size by 150%, the environment *must* know the
> current scale/size of that primitive? Or is my understanding
> completely flawed here? ;)
> 
> I have seen the "get-transform" function, but I am a bit puzzled by
> what it returns, it doesn't seem to have the info I'm looking for.

(get-transform) returns the current transformation matrix. It is
possible to extract the translation scale and rotation from here, but it
can be tricky (separating rotation and non-uniform scale is hard).

> As a workaround, I have tried to maintain an array of 'sizes' that I
> inspect, and calculate the new "scale factor" from it. Interesting
> idea but this horribly fails due to not having grasped how LISP
> handles variables / lists [array element does not get updated].

You can use vectors if you want to set elements of them - with
vector-set!.

It might be useful for you to check out structs:
http://docs.racket-lang.org/reference/define-struct.html?q=define-struct#%28form._%28%28lib._racket/private/base..rkt%29._define-struct%29%29

You can make fields mutable so you can set them. The reason this is
always a made bit tricky is because the language leans heavily in the
direction of functional programming, while not entirely forcing it on
you.

Lists are immutable, meaning that if you want to change an element you
need to rebuild the list each time.

cheers,

dave





More information about the Fluxus mailing list