So far we have been using groups to animate our geometry (or more precisely groups translate nodes). In this section we will explore how to set up more user friendly rigs by using controllers, which are simply shapes laid out in a logical way in our scene, that when selected allow us to animate the the elements we want. The most simple version of this is using hierarchy, we can create some geometry and parent it to a controller. First off we will create a sphere in a new scene and call it ball_GEO. Now it is time to create a NURBs circle, this can be found in the curves/surfaces tab on the shelf and it is the first icon on the left. You can scale the curves up so it is a good size for the user to select, (remember to freeze transformations) once we have the ball_GEO and the NURBs circle sized the way we want, we can rename the NURBs circle to 'ball_CTRL'. Just like we have done with previous animations, lets parent the ball_GEO to the ball_CTRL, this is the basic way to create a controller.
Using this simple rig we will explore how to control what the user can do with this simple rig, we will stop the user from selecting the ball_GEO and also remove options for rotating and scaling the rig.
To stop the user from selecting the ball_GEO we will look at two methods I prefer the second as it is easier for the user to access if they need to.
First method is select the ball_GEO and open 'attribute editor' go to the 'shape node' and open the 'object display' tab and the secondary tab 'drawing overrides' in this section turn on 'enable overrides' and in the 'display type' drop down menu chose 'reference'. If you have been successful the ball_GEO should appear with black a black wire frame in the view port, the ball_GEO can still be selected in the 'outliner' if needed.
The second method is simpler and can allow easier access to turning it off and on. Select the ball_GEO and in the 'channel box/layer editor' under the 'display' tab in the 'layer editor' press the icon on the top right that looks like a circle on a plane which is the 'create a new layer and assign selected object'. The new layer will appear underneath and in the small box on the right of the layer can be used to cycle through 'template','reference' and 'off' and we want to chose 'reference'. This will now stop the user from selecting the geometry in the view port by accident, but can still access it through the outliner or by using the layer editor.
Lets look at how to lock and hide attributes of of an object, which will mean only the attributes we want the user to have access to will be visible in the channel box. This is a simple technique but recommend leaving this till the end of the rig creation process. Select the ball_CTRL and select all the attributes we want to hide right click on the selected and chose 'lock and hide selected' the attributes will now vanish from the channel box.
Add Attributes & Connections
We can also add attributes to the channel box which we can then use to control specific elements of a rig, for example we could set up a rolling attribute for the ball_CTRL that actually uses a groups rotate attribute for the rotation. First of all how to create an attribute in the channel box, under the 'edit' tab in the 'channel box' select 'add attribute' this will open the 'add attribute window'. (or go to modify - add attribute) In the 'add attribute window' type in the name you want the attribute to be called in the 'long name' box. Leave the 'add attribute window' on its default settings we'll explore this in a later section. For this example we will type in 'ball_roll_L_R' & 'ball_roll_bck_fwd' maintain our usual naming conventions underscores will not show up in the channel box, L_R denotes left and right & bck__fwd are backwards and forwards. (we place backwards first as it is considered negative so when slider goes negative the ball rolls backwards)
Time to look at how to connect these new attributes to an attribute on a different object in this case a group. So before we carry on lets select the ball_GEO and create a group which we will call 'ballRotate_GRP' make sure the ballRotate_GRP pivot point is in the centre of the ball_GEO. Select the ball_CTRL and in the channel box select the 'edit' tab and select 'connection editor' or go to windows - general editor - connection editor. Once selected the 'connection editor' should open in a separate window. In the connection editor we have two columns one for outputs and one for inputs. Because we selected the ball_CTRL all its attributes should be listed on the left. We want to connect the attributes we created with attributes from the group so select ballRotate_GRP and 'press reload' right on the top right of the connection editor this should load all its attributes on the right.
Select 'ball_roll_L_R' from the outputs column and then open the rotate trop down by pressing the little + icon inside a circle beside it, then select 'rotateZ' both words should be italicised meaning they are connected. Do the same for 'ball_roll_bck_fwd' but select 'rotateX' instead.
Creating a simple ball rig
Using what we know so far lets build a simple ball rig, first of all we need to decide what controls we want to give the ball. For this rig we will have a ball that can roll left, right, forwards & backwards, spin on its centre point, tilt left, right, forwards & backwards, move up & down and finally the ability to squash & stretch. We will use two controllers, one for controlling all the above which we will call 'ball_COG_CTRL' (COG stands for centre of gravity) and a second called 'ball_master_CTRL' which will move the ball in the x,y & z axises. So lets get started..
First thing we need to do is create the ball for this I am going to use a polygon sphere with 20 subdivisions so we have plenty of edge loops for a smooth squash & stretch. (this rig would suit a NURBs sphere as well) Scale the ball up to a size you are happy with, I would recommend keeping it in alignment with the grid to make snapping easier, also make sure the sphere is sitting on the world origin again this will make life easier when we create groups or other objects. Once you have the sphere ready, rename it 'ball_GEO' and freeze transformations and delete history. Lets create the controllers next, for the 'ball_COG_CTRL' we will use a NURBs circle. For the 'ball_master_CTRL' we will create arrows pointing in the direction of the x and z axis with the arrow facing positive z bigger, to indicate the direction the ball is facing. To make the arrow use the 'EP curve tool' found next to the NURBs circle make sure it is set to linear in the tool settings. (remember hold 'x' key to snap to grid)
With the controllers set up make sure you remember to freeze transformations and delete history. (create the groups by unselecting every thing and pressing 'ctrl & g' this will create null groups with nothing in them) Now we will create the groups we need to driver the different attributes we are going to create for the 'ball_COG_CTRL'. We want the ball to roll left, right, forward & backwards as well as spin so we will create a group called 'ball_rot_GRP' which we will use to drive the rotation of the ball so it is important to move its pivot point to the centre of the ball. Next we want the ball to tilt left, right, forward & backward so lets create another group called 'ball_tilt_GRP' this groups pivot point should be at origin point. Finally create a group called 'ball_dn_up_GRP' with pivot point at origin just for keeping scene clean as this pivot points position is not important.
Lets set up our hierarchies, we want the ball to be able to roll while being tilted and to be able to move up and down. So lets put the 'ball_rot_GRP' into the 'ball_tilt_GRP' and 'ball_tilt_GRP' into the ''ball_up_dn_GRP', then place these groups into the 'ball_COG_CTRL' and place that into the 'ball_master_CTRL'. To have these effect the ball we most finally add the 'ball_GEO' into the bottom of the hierarchy which of course is the 'ball_rot_GRP'.
Time to introduce the squash and stretch, we will do this by using the squash deformer. Select the 'ball_GEO' and go to 'deformer - nonlinear - squash' this will create a 'squash1Handle in the outliner. With that selected select 'squash' in the 'inputs' section of the 'channel box' this is where we will find its attributes. The 'factor' attribute is the amount of squash & stretch used and the 'low bound' and 'high bound' indicate the areas been effected. If we test the squash & stretch on the default setting the ball will be effected from the centre of the ball, we want the effect to happen from the bottom of the ball. So we will simple move the 'squash1Handle' down so it sits on the origin (remember the 'x' key). The last thing we need to do is fix the 'high bound' so it encapsulates all of the 'ball_GEO' the squash & stretch should work correctly now if you test it.
We need to place the 'squash1Handle' into our hierarchy, so where do we put it? If we put it in the 'ball_rot_GRP' it will work, almost.... what have we forgotten to do?
Change its pivot point to the centre so it rotates correctly with the ball.
If we test the rig we will notice that knowing what direction the ball will stretch after the ball has being rotated an number of times can be difficult. So let create an indictor for the top of the ball. Go to the side view and create a triangle pointing to the top of the ball. and we can call this 'ball_top_indictor' lets place this into the 'ball_rot_GRP' as well.
Time to create our attributes and connections. Select the 'ball_COG_CTRL' and open the 'add attribute' window by going to modify - add attribute here we will create our custom attributes. First will be squash, so type in 'ball_sq_dn_up' and press 'add'. Lets do rotate next, type in 'ball_rot_R_L' and press 'add' (notice we are always placing the negative direction first, so -10 would be down 10). Go through and name the rest.
Now lets link them up, select the 'ball_COG_CTRL' and open the 'connection editor' windows - general editors - connection editor a new window will appear. The 'ball_COG_CTRL' should be loaded into the right panel, if not select it in the outliner and press 'reload left' in the connection editor. Find the attributes we created such as ball_dn_up select it now select the 'ball_dn_up_GRP' in the outliner and press the 'reload right' button, find its translate attributes and select translate y thats them connected. (they should be in italics when connected) Go through the rest and connect them remember to reload each group to the left window for example select ball_rot_R_L select the 'ball_rot_GRP' and press 'reload right' find its rotate attributes and select rotate z ( the axis the ball would rotate around to move right and left). For the squash & stretch select the 'squase1Handle' and then in its 'inputs' in the 'channel box' select 'squash' to bring up its attributes and chose 'factor'.
We can now test our rig and to see if every thing is working or if there are any improvements that we can make before we clean up. Everything is working, but maybe we can give ourselves some more control over the squash & stretch, at the moment we can only squash & stretch in the balls up direction. We have the elements we need to do this already available, we just need to do some rejigging. Give it a go yourself, if you get stuck continue reading.
So what we want to do is create controls for squash & stretch direction, we have a 'ball_top_indictor' that is currently letting us know the direction of the squash & stretch. Lets use this to control the direction of the squash & stretch, first off rename it 'ball_sq_dir_CTRL' and make it the parent of the 'squash1Handle', it is now controlling the 'squash1Handle' but the rig is still working like it did previously, we need to figure out where to place it in the hierarchy? Lets group it into the 'ball_tilt_GRP' now it acts independently of the 'ball_rot_GRP'. Time to set up two more control attributes, select 'ball_COG_CTRL' go to 'add attributes'. We will call them 'ball_sq_dir_R_L' and 'ball_sq_dir_bck_fwd' once they are create go back to 'connection editor' and link them to the 'ball_sq_dir_CTRL' we should now have a nice functioning rig.
Clean up time, select the 'squash1Handle' and turn 'visibility' off in the channel box then select all the attributes and lock and hide them by right clicking on the selection and in the drop down menu chose 'lock and hide selected'. Go through all the groups and lock and hide any of the attributes that are not linked (linked attributes will be coloured yellow) and then lock and hide any of the controller attributes we don't need. Next we will make the ball_GEO un-selectable, select the ball_GEO and add it to a layer in the 'layer editor' and turn on the reference only button (the third button on the layer). Test the rig one last time, lets make the 'ball_sq_dir_CTRL' un-selectable as well as we don't need to be able to select it. To do this select the 'ball_sq_dir_CTRL' and right click on the layer we have already created and in the drop down menu chose 'add selected objects'.
rig found at link below
Phew thats it! but wait, did you say lets make a complex ball rig!
Create a complex ball rig
Just like the first ball rig, we need to create a sphere and some controllers,. However this time we are going to create a large circle at the centre which we will call COG_CTRL and two smaller circles one at the top and one at the bottom, called top_CTRL and bottom_CTRL and finally create an arrow controller called master_CTRL. (I have changed colours to make them stand out more in images)
Next create some groups, with nothing selected hold 'cmd' key and hit the 'g' key, this will create a null group in the outliner. The first group call ballRig_GRP, the second call ball_GRP, the third call ballDeformation_GRP, and the fourth call ballCTRL_GRP. Now we will create the hierarchy, place the master_CTRL and ball_GRP into the ballRig_GRP, then place the ballDeformation_GRP and ballCTRL_GRP into the ball_GRP. Now place the controllers into the ballCTRL_GRP and the ball_GEO into the ballDeformation_GRP. Next it is time to add some joints for the controllers to control.
Select the 'create joint' tool by either opening the sculpting tab in the shelf and selecting the create joint icon or go to the menu a select skeleton - create joint. Making sure you are in the side view and holding down the 'x' key to ensure you are snapping to the grid click at the bottom of the sphere and again at the top creating a simple bone and hit enter. (if you don't see the joints make sure Xray joints is turned on in the viewer) With the joints created lets rename them, call joint1 ball_JNT1 and joint2 ball_JNT2
We want the joints to follow the bottom controller so lets make ball_JNT1 a child of the bottom_CTRL by selecting ball_JNT1 and holding down 'cmd' and selecting bottom_CTRL and hitting the 'p' key . Now if we move the bottom_CTRL the joints should move too. Lets add more control to the rig by creating an IK handle, again this can be found in the rigging shelf or in the menu skeleton - create IK handle with the create IK handle tool selected click on the bottom joint first and then on the top joint, this should make the bone go a purple colour and an IK handle should appear in the outliner. We want the ikHandle1 to follow the top_CTRL so lets parent it. Its time to get these hooked up to the geometry using a parent constraint, select the ball_JNT1 and hold down 'cmd' key and select ballDeformation_GRP and go to the menu constraint - parent open the options and make sure it is set to default and hit add. Now if we move the top & bottom controllers the ball will move. Using the parent constraint lets hook up the rest of the controllers, parent constrain the top_CTRL to COG_CTRL, bottom_CTRL to COG_CTRL and COG_CTRL to master_CTRL.
The next function we want to add to the ball rig will be the squash & stretch. We are going to approach it differently this time. We will be using some nodes to drive the squash & stretch, at its most basic we will make the ball scale in on the x & z axis when ever it is moved in the y axis however we are going to use the distance tool to make this easier. The distance tool can be found in the menu create - measure tools - distance tool. So make sure you are in the side view select the distance tool (hold down 'x' key to snap to grid) click on the bottom of the ball and again on the top of the ball. This will create a distanceDimenson1 and two locators in the outliner, this is a simple node that measures the distance between the two locators which we will use to drive the squash & stretch. So we will need to parent the locators to the bottom & top controllers. Drop locator2 into the top_CTRL and locator1 into the bottom_CTRL. If we move the controllers the measure tool will change as they are moved.
We will be working with the node editor window so lets set up our screen to work best in this view, first thing we need to do is open up the attributes tab instead of the channel box, next open the node editor by going to the menu windows - node editor resize the window so you can see the outliner and the attributes window.
Select the master_CTRL and ball_GRP and middle mouse button drag them into the node editor. Open up the nodes by pressing on the three lines on the top right of the nodes this will expand the nodes. Open up the scale drop down menu and link up the X, Y and Z scale of the master_CTRL to the X, Y and Z scale of the ball_GRP. This means that when ever we scale the master_CTRL the ball_GRP will also scale. Try testing this in the view port.
We will need to get things set up for the next part, drag the distanceDimension1 from the outliner into the node editor, we will be using the shape node (distanceDimensionShape1) you can move the distanceDimension1 node out of the way. We can also drag in the ballDeformation_GRP and position it to the left of the screen.
What we intend to do is create two more nodes, one that will multiple and one that will divide to do this we will use the multiplyDivide node. The scaleX of the ball_GRP is going to be multiplied by the current height of the ball, we are going to use the results of that multiplication to be divided by the distance on the distanceDimension node and also divide the distance of the distanceDimension node by the same result. (so we are going to divide the distanceDimension distance by scaleX of the ball_GRP, we are also going to divide the scaleX of the ball_GRP by the distanceDimension distance) The trick will be that when we go to plug these into the ballDeformation_GRP we will put the scaleX into scaleY and then but scaleY into both scaleY & Z. This will mean that when the distanceDimension changes its measurement it will use that information to change the scaleX & Y. (when the ruler gets longer the X & Z axis scales will get smaller equally causing a squash & stretch effect) I hope this is explained clearly for you, if confused I recommend looking at the node editor window when this is all finished to try and figure it out yourself!
Thats the plan so lets do it.
To create the multipleDivide nodes hit the 'tab' key which will bring up a curser, type in multiplyDivide and select multipleDivide and hit enter to create the node, create another multipleDivide node. Rename one multiply and one divide, select the divide node and in the attribute editor in the operation drop down menu chose divide. Select the multiply node and in the input2 section type in the height of the ball in my example it is 80 and make sure operation is set to multiply. From the ball_GRP node connect the scaleX to Input 1X on the multiply node. Next select the OutputX from the multiply node and connect it to the Input1 Input 1Y and connect it to the Input 2 Input 2X of the divide node. Now connect the distance output from the distanceDimensions node to Input 1 Input 1X and connect it to Input 2 Input 2Y. Connect the OutputX of the divide node to the ScaleY of the ballDeformation node, and connect the OutputY of the divide node to the ScaleX & Z of the ballDeformation_GRP node. This should make more sense if you look at the connections in the image below.
Cross your fingers and have a look in the viewport, hopefully if you move the top_CTRL and the bottom_CTRL the ball will squash & stretch correctly.
As always do a quick test animation to make sure rig is working properly, you will hopeful notice every thing is not perfect, if you stretch the ball and then try to move the ballCOG_CTRL the stretch will snap back into place. This is going to demonstrate the power/importance of groups when setting up rigs. Because we used a parent constraint on the ball COG_CTRL and the top_CTRL and bottom_CTRL any time we move the ball COG_CTRL it will zero out the transformations of the child controllers as they are following exactly what the parent is doing. So if we put the top_CTRL & bottom_CTRL into a group and have that linked to the ballCOG_CTRL they can be moved freely, as the ballCOG_CTRL will be moving the group which has zeroed out transformations in the channel box. This is also going to apply to the master_CTRL and ballCOG_CTRL relationship.
(remember to break the connections of the parent constraints we created earlier by deleting the constraints in the outliner)
rig found at link below