Wednesday, November 12, 2008

Surface Constraint

I set about to create my surface constraint setup script for attaching my muscles to bones. As a pleasant change of pace, it was a rather successful process. I emulated the method used in the original Rivet (button) script in which I attached a locater to a lofted surface defined by 2 edges on a polygonal surface. I added functionality by which the locater is automatically placed at the point on the surface closest to the object, rather than assuming a 0.5,0.5 uv location. I also allow the user to additionally tweak this position. Once the user is happy with this positioning, they can parent it to see how it works. Assuming this works out properly, the user can then bake the data that defines this constraint to the bone attribute file. The entry for each muscle follows the form:

muscle name, face defining edge1, face defining edge2, uPosition, vPosition, offset from face Vector, and which end of the muscle to parent (i.e. insertion or origin)

Once properly setup, each bone attribute file will have stored each muscle that can attach to it and where. The second part of the script, the constraint rebuild, will take a muscle and a bone as its input and read the attribute file to replace the muscle in its original position. Using the offset vector, it can replace the muscle in its original position, even if the bone has moved since original setup. This will be essential when generating parts on the fly. All thats left to do now, regarding this aspect, is go through the dog model and add each muscle position to each bone attribute file.

Below, see the script in action:



No comments: