[fluxus] skinning and pfuncs

Dave Griffiths dave at pawfal.org
Wed Jun 13 02:46:21 PDT 2007


Hi all,

Fluxus now has skinning operations - these are not primitive specific, so
we can skin polys, nurbs, blobbies or even particles etc. I'm going to
have to concentrate on importing data from blender soon, but for the time
being it gives a nice way of organically deforming stuff in an intuitive
way. The bones can be any fluxus scenenodes - so we can drive it with the
physics etc.

A not really very representative screenshot:
http://www.pawfal.org/fluxus/images/skin.jpg
(yes yes I'm putting shadows on everything atm)

So a bit more detail on pfuncs. This is currently quite experimental, so
things will probably change to some extent (mostly the strings are going
to change to symbols to make the scheme bit easier to read).

The general idea is to allow a common interface for doing complex
operations on primitives - some will be optionally loadable as plugins,
and also potentially run in parallel threads for multicore/processor
whizbang.

You make a pfunc with:
(make-pfunc "pfunc-name")

You can set parameters for the pfunc with:
(pfunc-set! mypfunc '("argument1" 0.3
                      "argument2" (vector 1 0 0)
                      "foo" (list 1 2 3 4 5)
                      "fred" 304))

And finally run the pfunc on a primitive by calling:
(grab prim)
(pfunc-run mypfunc)
(ungrab)

There are currently four flavours of pfuncs, the first one is very general:

arithmetic

Allows you to do fast per-element arithmetic on all the pdata arrays -
like pdata-op but more complete. Arguments are:

"operation" : add, sub, mul, div
"src" : name of the pdata array to read from
"other" : another (optional) pdata array to read from
"constant" : an (optional) constant value to use instead of "other"
"dst" : name of the pdata array to write to

eg: to make a pfunc to add 2.4 to all vertex positions:

(define mypfunc (make-pfunc "arithmetic"))

(pfunc-set! mypfunc (list
    "operation" "add"
    "src" "p"
    "constant" 2.4
    "dst" "p")) ; reads as p = p + 2.4

Similar, but more useful - to add element by element velocities to
positions to animate a particle system:

(pfunc-set! mypfunc (list
    "operation" "add"
    "src" "p"
    "other" "vel"
    "dst" "p")) ; reads as p = p + vel

... and to dampen the velocities

(pfunc-set! mypfunc (list
    "operation" "mul"
    "src" "vel"
    "constant" 0.95
    "dst" "vel")) ; reads as vel = vel * 0.95

The three other pfuncs are more specialised - for skinning operations:

genskinweights

Attempts to generate skin weights by looking at per vertex distance from a
set of bones forming a skeleton. This pfunc adds float pdata to the
primitive - called "w0" to "wn" where n is the number of bones-1. These
pdata arrays are the per vertex weights for each bone. Arguments are:

"skeleton" : a list of primitive id's representing each bone (locators are
probably the most sensible primitives to use, but you don't have to)
"sharpness" : a float (default 1) which affects the falloff between bone
influences. This changes the creasing properties in the skinned mesh.

skinweights->vertcols

Writes to the vertcolours to visualise the skinweights - for debugging. No
arguments.

skinning

This is the pfunc which actually does the skinning, using the weights
generated by the other pfunc, or eventually weights hand painted, or
imported from elsewhere. Requires a copy of the vertex positions pdata
array called "pref" to be added to any primitives it's run on - eg
(pdata-copy "p" "pref"). Arguments:

"skeleton" : same form as for the genskinweights pfunc - but represents
the changed, or animated skeleton
"bindpose-skeleton" : the initial, un-animated skeleton which the
skinweights were generated from

That's about it!

cheers,

dave




More information about the Fluxus mailing list