Caffeine Abuse - The Blog

Hydraulic Piston in XSI

By looking at hydraulic pistons in action you’ll soon find there’s quite a lot things going on at the same time. When trying to recreate the same functionality in 3D, you’ll most likely become aware of it even sooner. As the arms, to which the piston is attached, moves the piston obviously needs to stay connected at both ends at all times. This is achieved by making it expand and contract. However, this will also change the rotation of the piston which is what makes the setup a bit complicated. While it is the hydraulic system that is driving the arm in reality, there’s really no point in creating the same setup in 3d since you’ll be animating by hand anyway. It’s far more intuitive to do it the other way around, animate the arm and make the piston follow the movement.
Open and examine the scene piston.scn which can be found on the included CD. For your convenience the hierarchy for the arm has already been created. All you have to do is to add the final touches. Use the Schematic View (hotkey [9]) to get an overview of all the elements in the scene. Start by making the Piston_upper object a child of Piston_upper_rot and the Piston_lower object a child of Piston_lower_rot. Next, make Piston_upper_rot and Piston_upper_target children of upper_arm and Piston_lower_rot and Piston_lower_target children of lower_arm. Select the null object named Piston_upper_rot. From the Constrain menu choose Direction and pick the null named Piston_lower_target. Now, select the null named Piston_lower_rot and apply a Direction Constraint and pick the null named Piston_upper_target. If you where to constrain the Piston_upper_rot directly to the Piston_lower_rot and vice versa you would get an evaluation cycle as they would depend on each other. While you can get away with cycles in some situations, you’re better of getting into the habit of avoiding them as they’ll then never become a problem later on. Now, whenever you rotate the arms the piston will automatically expand and contract as well as maintaining its correct rotation.

The project files used in this tutorial can be found at:

While it’s the piston that is forcing the arms to move in reality, makes more sense doing the opposite when building it in 3d. Besides, the visual appearance will be exactly the same. Avoid creating cycles with the direction constraints by using different nulls for the targets and the ones controlling the rotation

Quick tip
An alternative way of controlling the arms is to make use of a 2 bone chain. Parent the upper_arm under the first bone and the lower_arm under the second bone. (example scene included on the CD)