|
BOING!

A spring is a simple
but tricky object. When it comes to animation you can quickly get into
trouble. You want the spring to contract/expand and bend at the same
time, but you don't want the springmaterial to squash and stretch. In
this tutorial you'll learn how to make a correctly deformable spring
setup using messiah's flex effect. I assume that you have a basic knowledge
of messiah, so I won't go into stuff like how to apply an effect, or
how to create a null. If you are uncomfortable with the basics, go through
the messiah documentation first ;)
To create the spring
I use Lightwave's Modeler, but of course you can create it with the
modeling program of your choise as long as it exports an object format
that messiah supports.
Ok then, let's start!
In Modeler:
1. Create a spiral
shaped spline. I used the SpringMaker
lscript to build a 1440° spring.
2. In another layer create a disc at the
start of the spiral and railextrude it with the spline in the
background. Use "Uniform Lenghts" or "Uniform Knots"
and check "Oriented". In my case I used 40 segments. Delete
the caps at the ends or tranform them into tris or quads, because messiah
currently does not allow to subdivide objects with polys that have more
than 4 points.

3. Go back to the layer with your spline
spiral and convert it to a polychain - I chose 30 Uniform Lenght
segments using CurveToPolychain.
The trick here is to have enough segments to create an accurate curve
in messiah, while keeping the point count low, wich will determin the
amount of repetable steps you'll have to do in messiah.

4. Now select the topmost point of that
polychain and note it's y position (hit i on your keyboard to
bring up the info panel). Divide that value by the number of segments
(polys) in the polychain and note the resulting number, in my case 4
/ 30 = 0.13333. You'll need this later in messiah.
Save your object with the polychain layer and the spring body layer,
or save them as 2 seperate objects. That's it for the modeling part.

In messiah (studio rev9< or animate 4.0<):
5. Import your polycurve and spring
body object(s).
6. Go into the Setup > Effect
tab and apply Simeon Nasilowski's PointEdit effect to the polycurve
(you can get the plugin here).
This will create a null at each point of the polychain.

7. You can now actually delete the pedit
effect, all we need here are the nulls - sorry Simeon ;) Create a Master_Null
and drag-parent the points to it. Now you can also delete the polycurve.

8. Apply the Flex effect to the
spring body object. With the Flex effect selected go to the Flex tab
and chose Distorted (Tool Shape) in the Axis pulldown menu. Now
create as many curve points as you have _PE nulls, in
this case 31.
9. Drag-parent the flexcurve
points to the _PE nulls in the right order, so that you get
a ascending spiral curve.

We'll now create a central spine for the spring with a bone chain.
10.
Create a Skeleton from the Tools tab and parent
it to the Master_Null. We actually don't need the skeleton to
deform anything, so we don't have to create a bone deform effect but
just the tool - less cluttering :)

11. With the Skeleton selected, create
a Bone by hitting + on the numeric keyboard. Give it the
lenght of the value that you noted in modeler, here 0.133333. Rename
the bone to Skeleton_Bone, so we won't get mixed up with the
numbers later.

12. Create a XForm null under the
Master_Null and rotate it -90° on pitch. This will
be the parent for the bone chain, so you can leave the bone rotation
at zero while make them point upwards. You can drag the Flex effect
under the Master_Null, so we have everything together.

13. Drag-parent the Skeleton_Bone
to the XForm null. With the Skeleton_Bone selected hit +
30 more times to create the complete spine chain. Create a Spine_End
Null and parent it to the last bone.

14. Go to the Items tab (still in Setup
mode) and select Parent Items in the pulldown menu and check
Keep Position and Keep Alignment. Now select the first
Skeleton_Bone, shift-select _PE_0 and hit the Parent button.
Repeat this for Skeleton_Bone_1 and _PE_1 and so on until
Skeleton_Bone_30 and _PE_30. Here it is important that
you respect the right order.
For visual clarity I like to rearrange the hierarchy so that each child
sits right underneath its parent, but it is not necessary. Just pay
attention not to mix up the parenting if you want to do this.

15. Select
the Curve and return to the Curve Options (press F3 to expand
the block). Set the Vector (Bank) pulldown to Skeleton_Bone.

16. Now create a Spring_CONTROL
null at the root level of the item list and move it up on y to
the spring top, wich is 4m in this case. You actually can collaps the
Master_Null hierarchy.

17. We've finished in the Setup tab for
the moment, now go to the Command tab. Here we will create a
bunch of expressions to control the spring:
First there'll be
3 variables wich will control the Skeleton_Bone's rotation:
- Call the first variable
spring_heading and in the expression tab enter [Spring_CONTROL:heading]
into the expression field (Note: you can automatically enter an objects
selected channel into the expression field by right-clicking the empty
square next to the buffer field). Go to the Channels tab and add the
Skeleton_Bone bank channel.
- Create a new variable
(or copy the previous one), call it spring_pitch, enter [Spring_CONTROL:zpos]/50
into the expression field and apply this to the Skeleton_Bone pitch
channel.
- Call the third variable
spring_bank, enter [Spring_CONTROL:xpos]/50 into the expression
field and apply this to the Skeleton_Bone heading channel.
Now we'll create
the variable that makes the spring expand and contract:
- Create a new variable,
call it spring_scale and in the expression tab chose IKTel
(note: you can hold your mouse over the menu and type "i"
on the keyboard, wich will bring you closer to the function you want
to select). In the first argument pulldown chose Skeleton_Bone,
in the second pulldown chose Spine_End and in the third pulldown
chose Spring_CONTROL. For the last two arguments enter 0
and 1.
The next variable
will make the spring bend by translating the first Skeleton_Bone's rotation
(wich is controlled by the Spring_CONTROL) to all the other bones in
the chain using the InheritRoot function:
- name that variable
spring_bend and in the expression tab chose InheritRoot
from the first pulldown menu. For the arguments chose Skeleton_Bone
in the first pulldown menu, in the second pulldown menu chose Skeleton_Bone_30
and in the third pulldown menu chose rotate. Enter 0 for
the last two arguments. (Note: You could tie the last two values to
a slider, this way you can control the damping and the curl amount of
the spring. This could be of interest for a very long and flexible spring,
but in this example it isn't really necessary)
Lastly we'll create
a variable that will constrain the Spring_CONTROL null to the top of
the bone chain, wich makes the spring more intuitive to control:
- call this variable
attach_springControl and chose MoveTo from the function
pulldown menu. Fill the arguments so that the expression will look like
this: MoveTo(Spring_CONTROL,Skeleton_Bone_30,1)

Ok, that's almost it. We've finished with the expression part, and the
spring is ready to be animated with the null. We'll however do one last
thing to make the control null easier to select and the spring easier
to manipulate in the world view.
18.
Go to the Setup > Armatures tab. Create a New Armature,
call it Spring_Armature, check Realtime Draw and add a
handle by clicking in the world view somewhere near the control
null. Deactivate Realtime Draw again, and with the handle selected chose
Spring_CONTROL in the Controller pulldown menu. Rename
the handle to Spring_Controller.

19. In the Action block add a Click
> Controller Select action and a Drag > Controller Drag
action. Expand the Controller Drag action by clicking the little
+ sign and set LMB to 1 (ypos), MMB to 2 (zpos)
and RMB to 0 (xpos). Click in the middle column next to 0 (RMB)
to activate the little M icon, wich actually lets you control
2 axes at once.

20. Now you can go to the Animate tab
and collaps and lock all items in the list. You can set the bones display
to L, wich will draw a visual line in the world view representing the
spine without attracting to much attention (Note: you can use the Select
Items function in the Setup > Items tab to quickly select all the
skeleton bones or any other item type). Unhide the spring body and hide
everything else.

That's it! By dragging the armature handle with the left mouse
button you can contract/expand the spring and with the right mouse button
you can bend the spring. By rotating the Spring_CONTROL on heading you
can roll up or unfold the spring, wich you'll not necessarily need,
but it can be fun ;)
You can download the
complete setup here.
Here you can see
an animated example, and get the associated
file.
If you have any question,
comment, suggestion: here's the place.
Have fun! :)
|