Woah! Thanks for the very prompt and, given my maths background, surprisingly lucid response. I shall be sure to experiment like a loon, now...<br>I don&#39;t have a huge amount of trouble with vector maths itself, it&#39;s just knowing enough scheme to be able to apply it that&#39;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 :)
<br><br><div><span class="gmail_quote">On 06/09/07, <b class="gmail_sendername">Dave Griffiths</b> &lt;<a href="mailto:dave@pawfal.org">dave@pawfal.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>&gt; Hi folks: I have a real pain-in-the-arse question here. I&#39;ve figured how<br>&gt; to<br>&gt; import an .obj file, thanks to the examples provided in the fluxus<br>&gt; releases,<br>&gt; but I was wondering about the details of actually manipulating the object
<br>&gt; once it&#39;s in there? Say, for example, I had the bunny.obj file open in<br>&gt; fluxus, but I wanted to make all of the points in it explode out, when (gh<br>&gt; 4) was triggered?<br>&gt; I apologise in advance: my understanding of programming and maths is still
<br>&gt; pretty weak: I can do basic primitive manipulation and so forth, but my<br>&gt; understanding of things such as vmul and mmul are still lacking<br>&gt; horrifically. I know that those are the handles involved in monkeying
<br>&gt; around with jittering planes and so forth, but I really don&#39;t know how to<br>&gt; apply them.<br><br>Simple answer - move the points along the normals by an amount controlled<br>by (gh 4)<br><br>To do this you need to learn some vector maths, but it&#39;s not as hard as it
<br>sounds - and it&#39;s a good way to learn.<br><br>Complicated answer:<br><br>One important thing to understand is that the vertex points are positions<br>in object space (relative to the centre of the object), whereas the
<br>normals are directions in object space - so if you add a normal to it&#39;s<br>vertex it will move in that direction (perpendicular to the surface of the<br>object i.e. &quot;out&quot;). In order to control the amount of movement, you&#39;ll
<br>need to scale the normal using vmul (by the audio harmonic in this case).<br><br>So it could look in Scheme like this (none of this code is tested btw):<br><br>(define (explode v)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; for each vertex
<br>&nbsp;&nbsp;&nbsp;&nbsp;(pdata-set! &quot;p&quot; v&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; set the position<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vadd (pdata-ref &quot;p&quot; v)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; to the last position +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vmul (pdata-ref &quot;n&quot; v) (gh 4)))) ; the scaled normal
<br>&nbsp;&nbsp;&nbsp;&nbsp;(if (zero? v)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(explode (- v 1))))<br><br>...<br>(define (update)<br>&nbsp;&nbsp;&nbsp;&nbsp;(grab bunny)<br>&nbsp;&nbsp;&nbsp;&nbsp;(explode (pdata-size))<br>&nbsp;&nbsp;&nbsp;&nbsp;(ungrab))<br><br>Now, this will constantly compose the vertex deformation on top of the
<br>previous vertex positions, so it&#39;s likely your bunny will explode into a<br>large amount of space rather quickly if your volume is turned up. (what a<br>strange sentence)<br><br>A more controllable way to do this is to keep a copy of the original
<br>points, and set p to be the result of adding the normal to the copy each<br>frame. This has the advantage of &quot;going back to bunny shape&quot; when there is<br>silence - which is probably what you actually want. We can use the ability
<br>to create arbitrary user pdata in fluxus to do this. I generally call this<br>copy the &quot;reference&quot;, and call the array &quot;pref&quot;:<br><br>(define (explode v)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; for each vertex
<br>&nbsp;&nbsp;&nbsp;&nbsp;(pdata-set! &quot;p&quot; v&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; set the position<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vadd (pdata-ref &quot;pref&quot; v)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; to the original position +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vmul (pdata-ref &quot;n&quot; v) (gh 4)))) ; the scaled normal
<br>&nbsp;&nbsp;&nbsp;&nbsp;(if (zero? v)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(explode (- v 1))))<br><br>...<br><br>(grab bunny)<br>(pdata-copy &quot;p&quot; &quot;pref&quot;) ; copy before any deformation has taken place<br>(ungrab)<br><br>...<br><br>(define (update)
<br>&nbsp;&nbsp;&nbsp;&nbsp;(grab bunny)<br>&nbsp;&nbsp;&nbsp;&nbsp;(explode (pdata-size))<br>&nbsp;&nbsp;&nbsp;&nbsp;(ungrab))<br><br>As an aside - you will get very different results if you try calling<br>(recalc-normals 0) or (recalc-normals 1) on the bunny beforehand.<br>You can also try adding some randomness to the scaled normal for more
<br>interesting mayhem - or changing (gh 4) to (gh v) :)<br><br>cheers,<br><br>dave<br><br></blockquote></div><br>