# M0004 - How to rig Computer Mouse in Maya ?#In this tutorial we will look at the technique of creating a computer mouse rig. We will walk you through the process of creating bones, ik handles, rig controls and finally painting weights.We will also teach you some cool MEL scripts that you can use in your rigging process. Lets get started.
#Final Output #
#Flow #[A]. Download project files, open Maya and set Maya Project. Open mouse.mb. Press F2 to select the Animation main menu and from the Skeleton click on Joint tool to select it.
[B]. Switch to top view in Maya and create three joints as shown in b1. The process is like click once to place a joint and hit enter to complete the joint creation. Press g to activate the skeleton tool again place second joint. Likewise repeat the process for third one.
[C]. Now create three NURBS circles, place and align them close to the joints. NURBS geometry is non renderable elements and are used to control the joints and joint weights. select the controller then select the respective joint, go to Constrain menu Parent option box, check maintain offset and apply, c2. Select the button controller and go to attribute editor, switch to first tab go to limit information go to translate and limit it to minimum -0.04 and maximum 0 for Trans limit Y. This will limit button's movement downwards that is in negative Y direction by 0.04 units.
[D]. Switch to channel box and select all attributes excluding Translate Y and right click and click on Lock and Hide selected, repeat the process for both the controllers. Select left and right click circles and group them by pressing Ctrl+G and name it buttonControls. Now select this group and shift select the mouse controller and press P to parent.
Now using the Joint tool, create a joint chain for the mouse cable, d1-d2.
[E]. Now go to Skeleton menu IK Spline Handle Tools option box, tool settings will get open, there make the settings as shown in e1.
[F]. Select the first joint of the cable and then select the second last joint of the cable. You’ll get offset in the joints due to less number of vertex in the spline ik curve, now you can insert vertex in the curve manually by right clicking on the curve go to curve point and click on the curve where you need extra vertex and adjust the position of the joints back to the cable. You can also use the script given below to get proper placed joints with spline ik on it, paste it in the script editor which you’ll get it in the Window menu > General Menu > Script editor.
$startJoint = "type your initial joints name here";
$endJoint = "type your second last joint name here";
select -r ($startJoint+".rotatePivot") ; select -add ($endJoint+".rotatePivot") ;
ikHandle -sol ikSplineSolver -pcv false -ns 13;
[G]. Now select vertex of the IK curve and go to Deform menu Create Cluster, repeat the procedure for all the vertices of the curve. Now create nurbs circles and place them to the position of the clusters and select the circle, go to Modify menu Freeze Transformations, Edit menu Delete by Type History and then rename the circles to controller name. Now select the controller then select the respective cluster, go to Constrain menu Point option box, check maintain offset and apply, repeat for all the clusters.
[H]. Now create a new control for the mouse, rename it as mouse_ctrl and then add two attributes in the controller by right clicking in channel box and name them as curveinfo and scaledivider. Create one more controller and name it as All. Create a controller for USB_connector and snap it to joint. Freeze the control and delete history, then select the control and then the joint go to constrain menu Orient option box-maintain offset off then apply, group the USB_control with itself and then select the usb joint and then the group and do point constrain.
[I]. Now connect the scaleX of all the joints excluding the USB joints, then select the ik curve and type arclen –ch -1 Now select the curve go to channel control in the Outputs select the curveInfo node and load it in the left hand side (LHS) of the Window menu General Editors Connection editor and load the mouse_ctrl to right hand side (RHS), then select Arc Length in LHS and curveinfo in RHS, it will connect the arclength of the curve to the curveinfo attribute. Now go to Window Animation Editors > Expression Editor and use the following expression.
////////////////////////////www.CGSutra.com////////////////////////////// mouse_ctrl.scaledivider=mouse_ctrl.curveinfo/All.scaleX;///////////////// wire_joint1.scaleX=mouse_ctrl.scaledivider/25.225;/////////////////////// ////////////////////////////www.CGSutra.com//////////////////////////////
This makes the wire stretchable.
[J]. Group the clusters together as cluster group and also group the IKhandle and its curve, then group both the groups together and name it as ikgroup, group all your ik controllers of cable as ikctrl_group, group all the mouse controllers together and name it as mouse ctrl group,then select all the controllers group (mouse ctrl, usb ctrl and ik ctrls of cable) together and group them by name ctrls, also group the all the joints together from outliner (note: only the upper joints of the hierarchy) and then select the joint group and controllers group then select All controller and press P.
[K]. Now the most important thing, select all mouse joints not cable joints then select the mouse geometry and go to Skin menu Bind—Smooth Bind (it will attach the mouse with the joints) now you have to adjust the weighting of the joints on the mouse, to adjust weighting go to Skin menu—Edit Smooth Skin- -- Paint Skin Weight tool option box (as shown in k1) and then paint weight for joints individually as full weight for button joint at their spread areas as shown in k2 for left mouse button, do it for all the joints. Now smooth bind the cable joints and just adjusts the weight for the USB_connector (just paint 1 on the USB joint).
[L]. Painting weights is little tricky and you would master it as you practice more and more. We are providing source files for download. If you face any problem or you have a query feel free to go to the forums and ask your doubts. Thanks for reading.
Dear guest, Only registered members can download projects/footages and Video files.Kindly get registered to download the files. Once you get registered downlaod link will appear here.