[Fluxus] Importing and manipulating an obj model?

Gerry Grainger nowhere.elysium at gmail.com
Thu Sep 6 05:59:53 PDT 2007


Woah! Thanks for the very prompt and, given my maths background,
surprisingly lucid response. I shall be sure to experiment like a loon,
now...
I don't have a huge amount of trouble with vector maths itself, it's just
knowing enough scheme to be able to apply it that's my monster issue at the
moment. As such, the amount of info here should be able to tide me over to
success. Cheers again :)

On 06/09/07, Dave Griffiths <dave at pawfal.org> wrote:
>
>
> > Hi folks: I have a real pain-in-the-arse question here. I've figured how
> > to
> > import an .obj file, thanks to the examples provided in the fluxus
> > releases,
> > but I was wondering about the details of actually manipulating the
> object
> > once it's in there? Say, for example, I had the bunny.obj file open in
> > fluxus, but I wanted to make all of the points in it explode out, when
> (gh
> > 4) was triggered?
> > I apologise in advance: my understanding of programming and maths is
> still
> > pretty weak: I can do basic primitive manipulation and so forth, but my
> > understanding of things such as vmul and mmul are still lacking
> > horrifically. I know that those are the handles involved in monkeying
> > around with jittering planes and so forth, but I really don't know how
> to
> > apply them.
>
> Simple answer - move the points along the normals by an amount controlled
> by (gh 4)
>
> To do this you need to learn some vector maths, but it's not as hard as it
> sounds - and it's a good way to learn.
>
> Complicated answer:
>
> One important thing to understand is that the vertex points are positions
> in object space (relative to the centre of the object), whereas the
> normals are directions in object space - so if you add a normal to it's
> vertex it will move in that direction (perpendicular to the surface of the
> object i.e. "out"). In order to control the amount of movement, you'll
> need to scale the normal using vmul (by the audio harmonic in this case).
>
> So it could look in Scheme like this (none of this code is tested btw):
>
> (define (explode v)                           ; for each vertex
>     (pdata-set! "p" v                         ; set the position
>         (vadd (pdata-ref "p" v)               ; to the last position +
>             (vmul (pdata-ref "n" v) (gh 4)))) ; the scaled normal
>     (if (zero? v)
>         0
>         (explode (- v 1))))
>
> ...
> (define (update)
>     (grab bunny)
>     (explode (pdata-size))
>     (ungrab))
>
> Now, this will constantly compose the vertex deformation on top of the
> previous vertex positions, so it's likely your bunny will explode into a
> large amount of space rather quickly if your volume is turned up. (what a
> strange sentence)
>
> A more controllable way to do this is to keep a copy of the original
> points, and set p to be the result of adding the normal to the copy each
> frame. This has the advantage of "going back to bunny shape" when there is
> silence - which is probably what you actually want. We can use the ability
> to create arbitrary user pdata in fluxus to do this. I generally call this
> copy the "reference", and call the array "pref":
>
> (define (explode v)                           ; for each vertex
>     (pdata-set! "p" v                         ; set the position
>         (vadd (pdata-ref "pref" v)            ; to the original position +
>             (vmul (pdata-ref "n" v) (gh 4)))) ; the scaled normal
>     (if (zero? v)
>         0
>         (explode (- v 1))))
>
> ...
>
> (grab bunny)
> (pdata-copy "p" "pref") ; copy before any deformation has taken place
> (ungrab)
>
> ...
>
> (define (update)
>     (grab bunny)
>     (explode (pdata-size))
>     (ungrab))
>
> As an aside - you will get very different results if you try calling
> (recalc-normals 0) or (recalc-normals 1) on the bunny beforehand.
> You can also try adding some randomness to the scaled normal for more
> interesting mayhem - or changing (gh 4) to (gh v) :)
>
> cheers,
>
> dave
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pawfal.org/pipermail/fluxus-pawfal.org/attachments/20070906/c2a1854c/attachment.html>


More information about the Fluxus mailing list