In|Framez® Papers

Fun With Catapults

By Bilal Moubarak


This tutorial is divided into the following sections:


Skill Requirements



Introduction

"Fire!"

"O my lord the catapults are jammed... We need some one to fix them again..."
   Richard I (The Lion Hearted)

Ah great! Oh come on Rich! This is the third time you have those damn catapults jammed...
Ok ok... I know you're on a haste, so I'll do it for you, this is the last time, okay?!

I'm really tired of this thing actually, so I thought I'd show you guys how to do this, so when Sir Richard I needs someone to fix his catapults, it won't be me!

In this tutorial, we'll learn how to build a simple rig for animating a catapult in a reasonable manner. This isn't very obvious if you think about it, especially for the ropes that pull the thing before it's fired.
Below is a picture of the results we'll achieve throughout this tutorial:


Catapult rig in action


"Think no more of it, John; you are only a child who has had evil counsellors."
   Richard I (The Lion Hearted)

Make sure you have downloaded the scene files so you can properly follow up with tutorial...


Investigating The Parts

Before we begin working with Richard’s catapults, we need to know what parts it's made of, and learn how they come in action.
If you're not familiar with this piece of hardware, the picture below names all parts we're going to deal with today:


Original part names, as taken from Microsoft Encarta


When operating the catapult, One soldier rotates the roller handle which pulls the beam until it becomes near the ground. That's when the other soldier loads it with a projectile. Then, BANG!!! The handle is released and the beam throws away the projectile.

For this tutorial, we'll create a simple rig setup for the ropes that pull the beam, so Richard's soldiers can use it easily (they're not very good with XSI, you know).
Open the tutorial's database and find ‘start.scn’ scene file. Use this for tracking the steps along with the tutorial. Or you can view the final result of the tutorial in the ‘final.scn’ scene file.


The Hook

Before we start working the rope's setup, we'll need to prepare a setup for the hook at the end of the ropes.
Select it and verify that its center is at about the middle of the ring, so it rotates around it correctly.
Draw a 2D chain with one bone over it that is the same length as the hook, then parent the hook to the bone. This bone will be used next for controlling the direction of the hook.
Rename the chain's parts to something meaningful.
Verify that the beam's center is at the bottom of it, then position the hook's tree in its right place on the beam, and parent its tree under the beam, so it moves with the beam when rotated.


Captain Hook


The Rope's Rig

Now for the rope... We'll model this in a custom approach that aids the rigging setup. This is done by using a cylinder, and deforming it on curve. This way we can do a simple rig on the curve, rather than on the actual rope mesh. Additionally, we'll achieve the sliding effect for the rope mesh on the curve by using the curve deformer.

For the curve get a spiral and adjust its parameters as below: Note that we used a fairly high number of points. This is required to get a precisely deformed curve for the rope rig.
Now, position the spiral curve in its right place over the roller.
Select the first five points of the curve and move them a little bit over the roller (i.e. points with id 0-4). These points will be anchored to the hook.


Rolling ropes


Next select the sixth point of the spiral curve and create a cluster center for it. Rename the new cluster center to RBottomNull.
Now, we can complete the hook's setup by applying a position constrain for the hook effector to the cluster center null we just created.
Make sure to turn compensation mode off before constraining.
If you try rotating the beam, the hook should now point to the cluster's null.
The final step in the rope's rig is to connect the first five points to the hook.
Rotate the beam until the hook sets near these points.
Select the points and create cluster center.
Move the cluster's center to its right position inside the hook.
Apply a pose constrain on the cluster's null with hook, but this time with compensation mode on.
This way we complete the first step in the rope's rig. Now what remains is the rope model itself.


The rope's rig


The Rope's Model

For the rope model itself, get a polymesh cylinder and make it long and thin just like a rope would be.
Don't forget also to set a fairly high number of subdivisions. This is important to get a smooth mesh for the rope when deforming.
Personally, I prefer not to freeze the construction history for the rope so I can modify it easily later if I needed to.
Use the ‘Deform by Curve’ command to deform the cylinder on the spiral curve, then modify its parameters to fit on the curve.


The rope's cylinder PPG


You can now make a small test and rotate the beam. You will notice that the rope is sliding nicely on the curve, but the rope is not interacting right on the roller.


Animating The Roller

To animate the roller, we will use a simple expression to drive the roller's rotation based on the beam's rotation. This can be achieved through ‘link parameters’, but we will do it with expressions and use ‘link parameters’ for another case, so in the end you can experience with more tools.

The diagram below shows the idea behind the expression:


Expression logic


So the expression syntax will be like this:
	( 360 * ( ctr_dist( TheCatapult.Hook, TheCatapult.RBottomNull ) ) ) / ( 3.21 * PI )
where 3.21 is the spiral's radius in the sample scene multiplied by 2.
In the Local Kinematics PPG for the roller, set the previous expression for the X-rotation axis.

If you rotate the beam now you should notice that the roller is rotating correctly.


Adjusting The Rope

Finally, the rope's spiral should be sliding as the roller rotates. We’ll automate this by using the ‘Link parameters’ this time (as I mentioned before).
So, when the beam is at its extreme up position, the rope will be on the right side of the roller. As the beam goes down, the rope's spiral will slide towards the middle of the roller.

In the Local Kinematics PPG for the rope's spiral, right-click on X-pos and choose Link With...
Select the beam's local x-rotation from the floating explorer.
Set the beam's X-rotation to ‘12.5’ (extreme up position), and adjust the rope's spiral position to its right place.
Right-click and ‘Set Relative Value’ to finalize the first step.
Set the beam X-rotation to ‘-90’, and re-adjust the rope's spiral to its new position and set a new relative value.

One last thing to do after linking the parameters, is to open the animation editor for the linked parameters and make sure that the fcurve is linear. If not we’ll get accelerations in the linked animation, which gives unnatural results in our case.

Do some tests by rotating the beam. Yep! You should get the right effect of the rope rolling around the roller.


Last-Minute Automations

After we’ve finished our first rig prototype, we can now extend the same technique and setup another rope for the opposite side.
Note that it should have its X pos animation mirrored. The second spiral should be inverted, and you need to set a blend factor of 0.5 for the hook pose constrain in order to make the hook point between the two ropes.

To properly complete the catapult's automation, we can add simple expressions to the wheels to make them rotate as we move the GlobalSRT. The expression would look like:
	TheCatapult.GlobalSRT.kine.local.posz * (360 / (10 * PI))



Two ropes are better than one


Richard I is Now Happy

"Thus we have defeated the king of France at Gisors but it is not we who have done it, but God and our right through us."
   Richard I (The Lion Hearted)

Yep! We did it!

This is one setup that I devised to achieve accurate and easy rope animation. You can use the same approach with other cases that have a similar setup.

Until the next tutorial, enjoy!