/* */

Tuesday, 10 January 2012

UV Driver

For use in ball joint areas such as shoulder and hip joints. Involves referencing the UV coordinates of a nurbs patch to drive a corrective blend shape or influence object.  

Create a nurbs patch:
Make sure its twice as wide as the upper arm joint
1 linear surface degree
X axis pointing down
1 U patch
1 V patch

Snap it to shoulder joint

Create Locator:
Point constain it to the elbow joint
Geometry constrain it to the nurbs patch
Now when the elbow joint moves, the locator translates on the nurbs patch


Create a "closestPointOnSurface" Node, name it cpos:
MEL code: createNode closestPointOnSurface -n cpos;

Open Connection Editor:
Load "cpos" into the inputs
Load Nurbs patch shape node (select and press down arrow for shape)
connect World position (patch shape node) to cpos input surface

Select Locator:
Load it into Outputs of the connection editor
connect its translate into the inPosition of the cpos Node

Select cpos in the channel box (under locators outputs)
load it into Outputs of the Connection Editor


Create new node - a point on surface Node:
MEL code: createNode pointOnSurfaceInfo -n posi;
Load it into Inputs of Connection Editor
Expand "result" under cpos
Connect its parameter U to posi parameter U
Connect its parameter V to posi parameter V

Reload Nurbs patch shapenode into Outputs
connect its worldSpace into the inputSurface of the posi Node


Set Driven Keys:
Now we'll create an object that will have an attribute driven  by the U and V parameter of the posi Node.
select it, go to Animate - set driven key
select the "posi" Node, load it as driver
In this example we'll control the scale Z of the sphere with the U Parameter and the Scale Y
with the V Parameter.
Select the "Parameter U" in the right hand column of the sdk window
Select the "Scale Z" of the nurbsSphere1
Hit "key" button to set default
Translate IK handle so its U position is at 0 on the patch
Scale the nurbsSphere1 in Z to whatever size you want it (I went to 2)
Hit "key" button
Translate IK handle so its U position is at 1 on the patch
Scale the nurbsSphere1 in Z to whatever size you want it (I went to 0.5)
Hit "key" button


Now when you translate the IK back and forwards, the nurbssphere's scale Z will change in
accordance with the U value of posi. This could be used as an influence object, alternatively
could be used to drive a corrective blend shape.

No comments:

Post a Comment