Relevant to Blender v2.31
Armatures are great also for rigging mechanical stuff, like robots, WarriorMechs etc. (Figure 16.55, “Four spider-mech legs.”).
First step is to create the mesh for the arms. We are not here for organic, we are here for mechanics. So no single mesh thing. The arm/leg/whatever is made of rigid parts, each part is a single mesh, parts moves/rotates one with respect to the other.
Although Figure 16.55, “Four spider-mech legs.” has four spider-like legs arms, each of which have 5 sections, it is clearer to explain the tricks with just a single joint arm.
My suggestion is this: make the arm with two equal sections, and the forearm, on the right, made by just one section. Note the cylinders which represents the shoulder (left) the elbow (centre) and the wrist (right) (Figure 16.56, “The Arm model”).
The other cylinders in the middle of the arm and forearm are the places where the piston will be linked to.
Note that it is much easier if the axis of mutual rotation (shoulder, elbow, etc.) are exactly on grid points. This is not necessary though, if you master well Blender Snap menu.
Then add the mechanical axes in the pivot points. Theoretically you should add one at each joint and two for every piston. For the sake of simplicity here there are only the two axes for the piston, made with plain cylinders (Figure 16.57, “The Arm model with pivot axis.”).
Note two things:
It is fundamental that the centre of the mesh is exactly in the middle and exactly on the axis of rotation of the piston.
Each axis must be parented to the pertinent arm mesh.
Now it is time to set up the armature. Just two bones are enough (Figure 16.58, “The Arm model and its armature”).
To have an accurate movement, the joints must be precisely set on the pivoting axis (this is why I told you to place such axes on grid points before, so that you can use the Move Selected To Grid feature).
Name the bones smartly (Arm and Forearm, for example). Parent the Arm Mesh to the armature, selecting the Bone option and the Arm bone. Do the same with the forearm mesh and forearm bone.
Parent to Bone effectively makes the Object follow the bone without any deformation. This is what should happen for a robot which is made by undeformable pieces of steel!
If you switch to Pose Mode you can move your arm by rotating the bones. (Figure 16.59, “The Arm model in Pose Mode”). You can add an Inverse Kinematics (IK) solver as we did in the previous section if you like.
Make a piston with two cylinders, a larger one and a thinner one, with some sort of nice head for linking to the pivoting points (Figure 16.60, “Hydraulic piston.”).
It is mandatory for the two pieces to have the mesh centre exactly on the respective pivoting axis.
Place them in the correct position and parent each piston piece to the pertinent mesh representing the axis. (Figure 16.61, “Hydraulic piston on the arm.”).
If you now rotate the two pieces in the position they should have to form a correct still image you get a nice piston. (Figure 16.62, “Hydraulic piston in Pose Mode.”, left).
But if you switch to Pose Mode and start moving the Arm/Forearm the piston gets screwed up... (Figure 16.62, “Hydraulic piston in Pose Mode.”, right).
To make a working piston you must make each half piston track the other half piston's pivot axis cylinder mesh (Not the other half piston! This would create a constraint loop). This is why the position of all the mesh centres is so critical (Figure 16.63, “Hydraulic piston with mutual tracking.”).
Select half a piston, select the other half piston's axis mesh, and,
in Object Context (F7) and
panel add a
Track To Constraint.
The buttons below
X, Y... must be appropriately
set (Figure 16.64, “Track settings.”).
If you prefer Old Track, remember also to press the
Anim Setting Panel for a nicer result.
Now, if you switch to Pose Mode and rotate your bones the piston will extend and contract nicely, as it should in reality. (Figure 16.65, “Pose Mode for the arm with hydraulics.”).
The next issue is, since pistons work when pressurised oil is pumped into them, for a really accurate model we should add some hydraulic hoses. But how to place a nicely deforming tube going from arm to piston? The two ends should stick to two rigid bodies reciprocally rotating. This requires IK!
First add a mesh in the shape of the tube you want to model (Figure 16.66, “Adding a flexible tube.”).
Personally I prefer to draw the tube in its bent position as a bevelled curve. This is done by adding a Bézier curve, adding a Bézier circle, and using the Bézier circle as BevOb of the Bézier curve. Then convert that to a mesh (ALT-C) to be able to deform it with an armature.
Then add an armature. A couple of bones are enough. This armature should go from the tube's 'fixed' end to the tube's 'mobile' end. Add a third bone which will be used for the Inverse Kinematics solution (Figure 16.67, “Adding the armature to the tube.”).
Be sure that the armature is parented to the object where the 'fixed' part of the tube is, well, fixed. In this case the robot arm. Also add an Empty at the 'mobile' end of the tube. (Figure 16.68, “The Empty for the IK Animation solution.”).
Parent the Empty to the 'mobile' part of the structure.
In this case the outer part of the piston to which the tube is linked.
In Pose Mode go to the Object Context and Constraints Panel.
Select the last bone, the one which starts from where the tube ends, and Add a constraint.
IK solver type of constraint and select the
newly created Empty as target Object
(Figure 16.69, “IK constraint.”). You can play with
Iterations: if you like.
Lastly, parent the tube to the Armature via the 'Armature' option. Create Vertex groups if you like. Now if, in Pose Mode, you move the arm, the two parts of the piston keep moving appropriately, and the Empty follows. This obliges the IK Armature of the tube to move, to follow the Empty, and, consequently, the Tube to deform (Figure 16.69, “IK constraint.”).
You can use a bone of the Armature, instead of an Empty, as an IK solver, but in this case you cannot parent the bone to the moving object. You can on the other hand, use a Copy Location constraint, but this is not as easy since the copy location would move the end of the armature to the center of the moving object, which is not the right place.