IK Spine with Stretch

Moderator: BenChang

IK Spine with Stretch

Postby BenChang » Tue Mar 06, 2012 8:13 am

A technique for setting up the back using spline IK and expressions to create smooth stretching

Shaping curves with skinning
Instead of using clusters to shape the curve, we'll use a different technique that involves skinning the spline curve onto some additional control joints. Before getting to the spine setup,here's an example of how this works with a simple curve.
spline1.jpeg
Create a basic CV curve
spline1.jpeg (9.03 KiB) Viewed 807 times

spline2.jpeg
create two joints (independent, not connected)
spline2.jpeg (17.61 KiB) Viewed 807 times

spline3.jpeg
Select the two joints and the curve
spline3.jpeg (17.81 KiB) Viewed 807 times

spline4.jpeg
Skin->Bind Skin->Smooth Bind. Move the joints to shape the curve
spline4.jpeg (13.06 KiB) Viewed 807 times
User avatar
BenChang
 
Posts: 176
Joined: Mon Jan 17, 2011 4:48 pm

Re: IK Spine with Stretch

Postby BenChang » Tue Mar 06, 2012 8:21 am

Create the spine and spline IK

The same technique will work with a spline IK.

1. Create joints for the spine
2. Create the Spline IK: Skeleton->IK Spline Handle Tool
3. Click the bottom joint, then the top joint
spline6.jpeg
spline6.jpeg (18.58 KiB) Viewed 806 times

4. Create two joints to control the spline curve with. Name them controlJoint1 and controlJoint2, and point snap them onto the bottom and top joints on the spine joint chain.
spline7.jpeg
spline7.jpeg (19.95 KiB) Viewed 806 times

5. Move and rotate the control joints to see how the curve changes.
spline8.jpeg
spline8.jpeg (25.46 KiB) Viewed 806 times
User avatar
BenChang
 
Posts: 176
Joined: Mon Jan 17, 2011 4:48 pm

Re: IK Spine with Stretch

Postby BenChang » Tue Mar 06, 2012 8:52 am

Stretchy spine

One thing you'll notice is that it's very easy to move the control joints away from the end of the spine, beyond where it can follow. To get it to bend better, it also needs to be able to stretch. In this step we'll use expressions to scale the spine as it bends.

1. First, let's tidy up the scene by naming everything nicely. Name the spine joints spine1, spine2, etc. name the spline IK spineIK and its curve spineCurve.

2. Create some cubes to visualize the spine segments. Attach one to each spine joint using parenting or skinning.

3. Create control curves. Make two NURBS circles named "spineBaseCtrl" and "spineTopCtrl". Point snap them into position at the top and base of the spine, and freeze their transforms.

4. Parent controlJoint1 under spineBaseCtrl. Parent controlJoint2 under spineTopCtrl.

spline9.jpeg
spline9.jpeg (27.83 KiB) Viewed 805 times


Now, to make the spine stretchy. For this we'll use the curveInfo utility node to get the length of the spline curve, and use this to scale the joints proportionately.

1. select spineCurve
2. in the MEL command line, use the arcLength command to create a curveIinfo node.
Code: Select all
arclen -ch 1;

3. in the Hypergraph, note the new node that's been created, called curveInfo1.

spline10.jpeg
spline10.jpeg (17.7 KiB) Viewed 805 times


4. Open the Attribute Editor and note the value of the Arc Length.

spline11.jpeg
spline11.jpeg (8.99 KiB) Viewed 805 times


5. Open the Expression Editor and create a new expression, using the ratio between the arc length and the base arc length (here, 10.0) to scale the joints.

Code: Select all
$scale = curveInfo1.arcLength / 10.0;
spine1.scaleX = $scale;
spine2.scaleX = $scale;
spine3.scaleX = $scale;
spine4.scaleX = $scale;
spine5.scaleX = $scale;
spine6.scaleX = $scale;


spline12.jpeg
spline12.jpeg (21.49 KiB) Viewed 805 times
User avatar
BenChang
 
Posts: 176
Joined: Mon Jan 17, 2011 4:48 pm

Advanced Twist Control

Postby BenChang » Tue Mar 06, 2012 9:11 am

The spine stretches and bends nicely now, but it also needs to be able to twist. For this, we'll use the Advanced Twist Control feature of the Spline IK to use the top and bottom control curves to control overall twist.

1. First, the control curves should have the same rotation axes as the joints. Use the null group / temporary orient constraint technique to orient them.

spline13.jpeg
spline13.jpeg (8.19 KiB) Viewed 805 times


2. Select spineIK and open the Attribute editor.
3. Expand "IK solver attributes" and expand "Advanced Twist Controls"

World Up Type: Object Rotation Up (Start/End)
Up Axis: Positive Z
Up Vector and Up Vector 2: 0,0,1
World Up Object: spineBaseCtrl
World Up Object 2: spineTopCtrl
User avatar
BenChang
 
Posts: 176
Joined: Mon Jan 17, 2011 4:48 pm


Return to Art and Animation

Who is online

Users browsing this forum: No registered users and 1 guest

cron