/* */

Saturday 14 January 2012

Parent add shape

Really useful technique for adding ctrl curves to a null Group.

1. Create your null Grp position, freeze trnsfrms etc, etc.
2. Create your Ctrl Curve and move it into position.
3. Select the curve shape (important to select the shape node by pressing down arrow key)
4. Select Null Grp
5. Type following code:
         parent -s -r

Done! Selet the curve, move it about, it now controls the null group. Select the curve in the hypergraph, delete it - the curve in the viewport is still there, it's connected to the group.

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.

Sunday 8 January 2012

simple window

Simple bog standard window to get the ball rolling, which begins with an if statement to check the window doesn't already exist. If this is the case, a deleteUI command is called to get rid of it.

if (cmds.window(myWindow, exists=True)):
    cmds.deleteUI( myWindow)

#Checks the window doesnt already exist, if so, it'll go ahead and delete the window and start from #scratch.

myWindow = cmds.window(title = "Slider Window", width =100, height = 200)
cmds.showWindow(myWindow)

#Creates a window withe title "Slider Window", width/height 100/200 respectively. Show window is #essential to display it on screen.