Your online Softimage Educational Resource

The blog has been online for more than 4 years and there’s still not a single post even remotely related to the delicious brew called coffee… Perhaps it will someday, but in the meantime you can read the articles about Softimage. Most of the material are tutorials and Q&As I’ve written for 3D World Magazine sometime between today and 2003. If you have any questions please don’t hesitate sending me an email.

Thanks to Letterbox Animation Studios for hosting all the scene files.

Make sure you visit their for 100s of hours of free XSI video tutorials.

Tuesday, August 5, 2008

Animating a Rolling Tire

There is a number of ways to make the tire rotate properly based on its movement. On the following two pages we will give you an idea about how to approach the problem, and show you two different ways to solve it. Regardless of which of these techniques you end up using you will need to know the circumference of the tire. So the first thing we will need to do is to dig up the old trigonometry books we all loved so much at school.

After flipping through the book we know that the relationship between the circumference of a circle and its radius is the number π (pi). This means that once we know the radius, we can easily calculate the length the tire has to travel to make a full rotation by setting up the following equation, where C is circumference and r is the radius: C= 2π*r

The next step is to turn our newly gained knowledge into something useful inside of Softimage XSI. This is where expressions come in handy. An expression is a function which lets you control any animateble parameter with mathematic. In other words we can control the tire by using the above equation and adding the tire’s movement to drive the rotation.

Select your tire object and open up its Animation properties. Scroll down to Local Transform > Rotation and right click on the animation icon next to the Z-axis, and choose Set Expression…. This will bring up the Expression Editor. Before we start writing our expression there’s one thing we have to do, so click on the Expression Editors Lock icon to prevent it from updating.

If we where to use the tire’s own movement along it’s x axis in the expression we would soon run in to a problem. Since we are rotating the tire we are also rotating its local coordinate system, which of course changes the orientation of the X-axis. To fix this we need to put our tire in a hierarchy and use the parents x position to drive the rotation. Create a Null, align it with your tire and make it the Parent of your tire object. Once you’re done, head back to the Expression Editor.

Since we want to calculate how many degrees the tire should rotate we will start by dividing a full rotation, 360 degrees, with the equation of the circumference before we multiply the result with the distance traveled. In the white part of the editor write the following expression:
( 360 / ( 2 * PI * r ) ) * null.kine.local.posx just don’t forget to replace the r with the radius of your object. Click on the Apply button in the right corner. Select your Null and move it along the X-axis. As you can see the expression is working, but the tire is rotating in the wrong direction. Go back to the Editor and add a minus sign at the very front. The finished expression should look like this: -( 360 / ( 2 * PI * r ) ) * null.kine.local.posx

Expressions can be used to create a wide range of controls and animations and can be a huge timesaver, but there are other ways as well. In the Step by step section on the following page we will show you another way to animate your tire. Instead of the above technique we will create the path we want our tire to roll on and then link the rotation to the percentage traveled along it. Just as with expressions we can play around with the position, timing etc. without having to worry about the rotation.

Rolling tire Step by step

Step 1
First we need an object to act as our wheel. Start by creating a cylinder and increase the radius to 6.25. Rotate the cylinder 90 degrees along its X-axis, Freeze the rotation and name it Rim. Create a null and make it the parent of the Rim. If you want to add a little more reality without the hassle of modeling just load the scene called Wheel.scn from the CD-rom that comes with the magazine

Step 2
The next thing we need to do is to create the actual path we want our wheel to travel along. Draw a curve in the top viewport. Use the M key on your keyboard to move points around until your satisfied with the path. For a more precise control of the shape, you can create your curve in an external program, like Illustrator and then import it into XSI as an EPS file.
Step 3
Select your curve and name it wheel_path. With the curve still selected press Shift + Enter on your keyboard. This will bring up additional information about the selected object. Find the textbox labeled length and unless you’ve got a really good memory, write it down on a piece of paper. Since the length of the path is very unlikely to change during the animation we won’t assign this dynamical, we only need it to calculate rotation once
Step 4
Select the null and switch to the animation menu. Under Create>Path click Set Path. In the pop-up window just leave the In and Out frame to their default, but make sure you check both the Linear and Tangent checkboxes. This will make the wheel travel at a constant speed, and ensures that the nulls X-axis is pointing in the right direction. If your wheel gets re-oriented, just select the Rim and rotate it 180 degrees along its Y-axis.
Step 5
Select the Rim object and bring up its animation properties (hotkey Ctrl + K). Under Local Transform>Rotation, right click on the animation icon (the green dot) next to the Z-Axis and chose Link With… In the explorer expand the null>kinematics>Constrains>PathCns and click Path %age. You have now linked the rotation of the wheel to the percentage traveled on the path. The next step is to set the values for the rotation.
Step 6
Right click on the Z-axis animation icon and chose Set Relative Values. Go to frame 100 (hotkey End) and set another relative value. Open the animation editor. To determine the wheel’s correct rotation we’ll divide the length of our curve with the wheel’s circumference and multiply the result with 360 (a full rotation). Select the keyframe on the very right and enter the result as the value. Select both keyframes and switch the interpolation to linear, and off you go...


Pierre Schiller said...

How would I work with a gear? Applying this is fine when the wheel is flat, but in a gear with pinions? could you do a tutorial about that, please?

Ola Madsen said...

Hi Pierre

Is this what you’re looking for?