[fluxus] lotsa stuff

dave dave at pawfal.org
Wed Jun 27 14:09:42 PDT 2007


Hi all,

I seem to have crammed a lot into a big commit - apologies...

I've made the skinning stuff easier to use, primarally, skeletons are
now entirely represented by scenegraph subtrees. The means you only need
to specify the root primitive of your parented structure, rather than
building the whole skeleton out of lists or whatever to pass to the
skinning pfuncs - it figures it all out internally, by examining the
scenegraph.

This means genskinweights can now work for proper branching skeleton
topologies.

It also means that physics driven skeletons had to be changed, as the
physics drives primitive positions in worldspace - so parenting them all
together doesn't work. To get round this I've added a new
(hint-lazy-parent) which basically means if a primitive is parented to
anything, it won't pass it's transform on. 

I've added an example of physics driven skeletons and skinning at the
bottom of this email.

The other thing I've done is broken backward compatibility in a number
of ways. This is to replace numbers and strings as arguments into
symbols to make things easier to read - the following are affected:

* all the pfunc stuff
* make-light
* light-attenuation
* blend-mode
* build-polygons

I've also changed pdata-set to pdata-set! and pdata-get to pdata-ref to
make it more schemeish. As this is a fairly major change, I've added
some defines in scratchpad-boot.scm for backwards compatibility for
this.

I've also added (blobby->poly) which extracts the blobbies mesh into a
polygon primitive. The idea is that we can use the blobby primitive as a
way of generating nice organic meshes for skinning. There should be a
demo on it's way to demonstrate all of this in some more coherent and
exciting manner.

--->8---

; an example of physics driven skeletons and skinning

(clear)

; build the bindpose
(push)
(hint-origin)
(hint-lazy-parent)
(define b1 (build-locator))
(parent b1)
(translate (vector 0 1 0))
(parent (build-locator))
(translate (vector 0 1 0))
(parent (build-locator))
(translate (vector 0 1 0))
(build-locator)
(pop)

; build the animated pose
(push)
(hint-origin)
(hint-lazy-parent)
(define a1 (build-locator))
(active-box a1)
(parent a1)
(translate (vector 0 1 0))
(define a2 (build-locator))
(active-box a2)
(parent a2)
(translate (vector 0 1 0))
(define a3 (build-locator))
(active-box a3)
(parent a3)
(translate (vector 0 1 0))
(define a4 (build-locator))
(active-box a4)
(pop)

; connect the bones of the animated skeleton together with joints
(define j1 (build-hingejoint a1 a2 (vector 0 1 0) (vector 1 0 0)))
(define j2 (build-hingejoint a2 a3 (vector 0 2 0) (vector 1 0 0)))
(define j3 (build-hingejoint a3 a4 (vector 0 3 0) (vector 1 0 0)))

; set up some physics stuff
(ground-plane (vector 0 1 0) -1)
(collisions 1)

; make the skinning pfuncs we need
(define gs (make-pfunc 'genskinweights))
(define sc (make-pfunc 'skinweights->vertcols))
(define s (make-pfunc 'skinning))

; set up the parameters
(pfunc-set! gs (list 'skeleton-root b1 
                    'sharpness 9.0))

(pfunc-set! s (list 'bindpose-root b1
                    'skeleton-root a1
                    'skin-normals 0))

; make the actual object to be skinned
(push) 
(hint-vertcols)
(scale (vector 0.4 3 0.4))
(define o (build-cylinder 10 10))
(pop)
(apply-transform o)

; set it up for skinning
(grab o)
(poly-convert-to-indexed)
(pfunc-run gs)
(pfunc-run sc)
(pdata-copy "p" "pref")
(pdata-copy "n" "nref")
(ungrab)


(define (animate)
    (joint-angle j1 (sin (time)) 1)
    (joint-angle j2 (cos (time)) 1)
 
    (grab o)
    (pfunc-run s)
    (recalc-normals 1)
    (ungrab))

(every-frame (animate))





More information about the Fluxus mailing list