Ok, so here is our basic hydraulic cylinder, all of the parts are combined onto one piece of mesh which is 556 faces. The rig that we will be setting up will allow the piston to extend indefinitely without coming apart. There are two attachments on the mesh for hoses, but we will not be getting into that in this tutorial, there might be on in the future for weighted hoses.
Download the scene files here.
Step 1: Creating Dummy Control Objects
Create polygon cube with a width, depth and height of 1
Locate the cube at 0,0,0
Under the Create menu, open up the CV Curve Tool Option box, select "1 Linear" for the degree of the curve.
With the polygon cube select hit the F key to focus on the cube, make sure you are in wireframe mode by pressing the 4 key.
While holding down the V button on your keyboard for vertex snapping, create an outline of the entire cube
Delete the polygon cube after all 12 edges have been drawn, your control object should look like this when finished.
Placing the control objects
The control objects should be located at the two insertion points for the piston, at the base and the top of the piston at 0,0,0 and 0,10,0. Scale the control objects to the appropriate size and rename them, Base_Control for the lower one and Insertion_Control for the upper one.
Place the control objects under there own layer, this will help to keep everything organized and allow you to hide the controllers when you don't want to use them, or there are too many in the scene and they become distracting.. I gave my control layer a yellow color so I can easily see all the control objects.
Step 2: Creating Locators
Under the create menu again, create a locator at 0,0,0
Duplicate the locator and move it to 0,10,0
Rename the locators to there appropriate names Base_LOC and Insertion_LOC
Create a third locator, name it Stage_2_LOC and move it to 0,8,0
Create a fourth locator named Piston_Up_LOC, move it to 2,5,0 and add it to the Control_Objects layer
The outliner should look like this after step 2:
Step 3: Point Constraints
Select the Insertion_Control then Insertion_LOC and point constrain them on all but the Z axis, this option is found under the Point Constrain Options by unchecking "all" and checking only the X and Y options under the Constraint Axes section.
Do the same for Base_LOC by point constraining it to Base_Control
Select both the Base_LOC then the Insertion_LOC followed by the Stage_2_LOC and point constrain on all three axis by rechecking the "all" option under the Point Constraint Options window. This will average the stage_2_LOC halfway between both the Base_LOC and the Insertion_LOC
Select the Stage_2_LOC, change the offset Y value to 3 under the point constraint settings, this will shift the locator back to its original position of 0,8,0 while keeping the connection to the other two locators.
Step 4: Parenting and Aim Constraints
Select Stage_2_LOC then select Base_LOC and hit the P key to parent
Select the Insertion_LOC then the Base_LOC, in the animation tool set, go under Constrain and open up the Aim Constraint Tool Dialog box, and use the settign displayed to the left.
Select the Base_LOC then the Insertion_LOC and use the same constraint settings except for change the Aim Vector from 0,1,0 to 0,-1,0
Step 5: Clusters and Parent Constraints
Select the piston mesh, and enter the vertex selection mode, using the guide to the left highlight and select the corresponding vertices one section at a time. With the first group of vertices selected, go under Create Deformers menu and open up the Cluster Options window, Make sure the Relative box is unchaecked and click create.
Repeat the previous step for each section on the piston Mesh, and rename the clusters for there corresponding section, Base_Cluster, Stage_2_Cluster, Insertion_Cluster.
Select the Base_Cluster and hit the "insert" key on the keyboard to adjust the pivot point of the cluster. While holding down the "V" key click the center of the Base_LOC to shift the pivot point to the same location of the Base_LOC.
Do the same for the Insertion_Cluster but move the pivot point to the Insertion_LOC
The pivot point of the Stage_2_ cluster should be shifted to the center of Stage_2_LOC as well
Parent the Clusters to there corresponding Locaters, and test out the piston by moving the control objects.
Final Out-come: Grouping everything together
Once everything is working properly, simply group everything except for the piston mesh together and name the group Piston 01. The Outliner should look the same as the one to the left.
The only thing left is to parent constrain the control objects to another piece of mesh and enjoy.
Piston Final Rig
To reposition the piston just select the group and move, rotate or scale it to adjust the piston's set position orientation and size.
To create a duplicate the piston, go under edit and open up the Duplicate Special Options window and use the following setting, make sure to select the GROUP when duplicating and not just the objects.
You can see the piston in action by clicking here
and downloading a sample movie.