Creating the joints.
Before starting make sure that maya is set to the animation settings in the drop down menu below the taskbar and in the toolbar settings. This is shown in the screenshots below.
The first step to creating a rig is to import the object you are going to rig for animation.
In order to place the joints for the leg it's much easier to look through the side view
to be sure that you are placing the joints right. Perspective view makes it harder to see exactly where you are placing them.
Creating a new layer for the leg mesh makes things easier later on as this enables you to
hide the mesh and see what's going on inside and select joints more easily.
Make sure to label the layer so that you know what it is.
Turning on X-ray joints will enable you to see where you are placing the joints
whilst still having the mesh visable for placement.
Select the joint tool to create the joints for the rig.
Create joints at the hip, knee, anke, ball and toe as shown.
When creating the toe hold shift and drag from the ball joint you created.
This will make sure that the joint is straight.
Go back to perspective view to position the leg joints within the mesh.
Using the move tool move the joints into the correct position within the mesh.
Before mirroring the joints you need to make sure that all the joints are oriented the right way. To check which way the joints are oriented simply press F8 and click on the question mark shown in the diagram.
If a joint has it's axis facing a different way from the others you can fix it by clicking the orient joint option in the skeleton menu.
In the options box you can change which way the axis is pointing.
Now that the joints are in the right position and are oriented the same way we can mirror the joints to create the other leg.
Before doing this though be sure that all your joints are named properly.
Bring up the outliner in saved layouts so that you can see all the joints you've made.
Here you can rename the joints and see the order in which they flow.
Now to mirror the joints simply click the mirror joint option in the skeleton menu.
Click on the small box next to it to edit the mirroring options.
Here you can select which axis to mirror and you can also tell Maya to change all your naming conventions to finish with R instead of L to signify the right leg.
Create new layers for each leg and name/colour them appropriately.
Next is the joints for the centre of gravity to join the legs together.
Make a joint between the two hip joints then holding shift drag upwards to create a spine joint.
In order to set up the joints correctly we need to make the centre of gravity joint the parent of the legs.
To do this first select the leg and then holding shift select the centre joint and then press P on the keyboard. You should now be able to select the whole rig by click on the centre of gravity joint.
Take this opportunity to rename the joints to something appropriate in the outliner.
IK Handles.
Now that the joints are all set up correctly we need to create the IK handles to make sure that the leg bends properly. Double click the IK handle tool to bring up the options. (The IK handle tool is situated next to the the joint creating tool)
Make sure that in the drop down menu IKRP solver is selected. Then click the hip joint and then the ankle joint. This should create a line between the two joints. To test that the handle works move the leg up and down from the ankle and the leg should bend realistically. Repeat this for the other leg.
Binding the skin
Binding the mesh to the skeleton can be done at this point. Simply click the mesh, hold shift and click the skeleton (make sure it is all selected by clicking the spine joint).
Now from the skin drop down menu choose bind skin and there you can choose which kind of bind to use. For a human body we want a smooth bind so it moves organically but if we were creating a rig for something mechanical we would use a rigid bind so that the mesh would move more like a machine.
To test that the mesh is bound correctly move the leg and the mesh should move with it. If it doesn't it's probably due to the order in which you selected the mesh and skeleton as I had this problem a couple of times. Make sure to select the mesh first.