A07   RIGGING FOR MOTION PATHS

The Rocket with Two Routes. (A rigging exercise).
RIGGING FOR MOTION PATHS

This section will introduce motion paths, constraints, and a choice of using two utility nodes (multiply & reverse) or a simple MEL expression.
So far we have only used the translate, rotate and scale channels of geometry or its rig to manipulate a character.   In this exercise we will be moving an object along a predetermined path which is defined by a NURBS curve.   A train running along a track, a bird swooping through the air, a fish swimming under
the water, are just a few suggestions of how a motion path can be helpful.   You could probably figure out how move an object along a motion path yourself but to get the best out of this technique you need to prepare properly.   The path takes care of the position and to some extent, the orientation of your character but it can also be very restricting if you are not properly organized.   This exercise is primarily about rigging your character for maximum flexibility.   The rocket, which you should build yourself, will be rigged to fly on either of two motion paths or completely free from either.   It will all be controlled from a single central control node.
There is an element of choice with regard to implementing the mathematics needed to complete this rig.   You can either use two utility nodes or some expressions to complete the functionality.
When implementing the instructions below, it is important that you follow them carefully and when you enter names or renames, that you enter them precisely as they are spelt here.   Naming strings are case sensitive within Maya.
The Tutorial A12 finalizes this exercise by adding a single particle emitter to provide exhaust gases from the base of your rocket.

THE BRIEF
A Rocket with Two Routes:

Artistic Elements Covered: Camerawork and General Chorigraphy
Technical Elements Covered: Setting up and using Constraints and Motion Paths


Scene file NOT provided.   Sequence Duration 8 to 16 seconds

Build a simple polygonal rocket and rig it to fly on two separate motion paths and control all from central a point.

Build a Rocket.

In a new scene, build a simple rocket from a polygon cylinder.   Build it so that length of the rocket is on the y axis and is approx 4 units in length.   When you finished the construction then make sure it is centered so that the bulk of the rocket is over the origin.   Freeze the geometry, which will zero the transformations, then delete history.   Make sure your rocket is renamed "rocket".   Make sure the pivot point of the rocket is set to the origin. Set the visibility of the rocket to "off", we will come back to this later.


Constraints.
We will now set up a three way point constraint so that we can control our rocket in three ways.   We will start by controlling the position of a polygonal cube by constraining it to three locators.   We will then make a controller so that we can easily select which locator we want to control the position of the cube.

Create a polygonal cube.
Create a NURBS circle and rename it "rocket_control".
Select both the cube and circle (rocket_control) and delete history.
Create a locator and rename it "M1" then move it to minus 4 on the Z.
Create another locator and rename it "L1" then move it to plus 4 on the X and minus 4 on the Z.
Copy this last locator and leave the name as "L2" and move it to minus 4 on the X and minus 4 on the Z.
Select rocket_control and add a float attribute with min 0.0 and max 1.0 called "useMotionPaths".
Select rocket_control and add a float attribute with min 0.0 and max 1.0 called "useR2".
From the outliner select M1, L1, L2 and lastly pCube1 using the Ctrl key and then create a point constraint.
From the Outliner, open the pCube1 by clicking the + to reveal the newly made point constraint.

The scene so far

Select this constraint from the outliner.   From the channel box, try changing the values of M1W0, L1W1 and L2W2.
You will notice that when you set M1WO to 0, L1W1 to 1, and L2W2 to 0 the cube moves to the position of the L1 locator.

When you set M1WO to 0, L1W1 to 0, and L2W2 to 1 the cube moves to the position of the L2 locator.
When you set M1WO to 1, L1W1 to 0, and L2W2 to 0 the cube moves to the position of the M1 locator. From the outliner select M1, L1, L2 and lastly pCube1 using the Ctrl key and then create an orient constraint.
This will enable the cube to follow the rotations of one of the three locators.
Group the locator M1 under rocket_control from the outliner so that rocket_control becomes the parent of M1.   Set the position of M1 to the origin (The cube should move too) and make M1 invisible.


Keying the channels of the point and the orient constraints directly would be inconvenient because firstly the constraints can't be selected directly from a geometry window.   Secondly, keying just two channels on the control centre is easier than looking after a total of six channels across both constraints.
The function of the extra attributes on the control centre will be as follows:-

When useMotionPaths = 0 then the cube
(eventually the rocket) will be controlled by the position and orientation of rocket_control.
When useMotionPaths = 1 and useR2 = 0 then the cube (eventually the rocket) will be controlled by the position and orientation of locator L1 which will be attached to a motion path.
When useMotionPaths = 1 and useR2 = 1 then the cube (eventually the rocket) will be controlled by the position and orientation of locator L2 which will be attached to a second motion path

.
Connecting the controls using Utility Nodes.

From the hypershade window create a multiplyDivide node and a reverse node.
Connecting nodes is a bit like knitting and can be confusing.   There are two main ways of connecting nodes.   You can use the hypergraph window or the connections editor.   Use the method you find the easiest.

Which ever method you use, connect as follows:-
rocket_control, useMotionPaths attribute to reverse1, inputX.
rocket_control, useMotionPaths attribute to multiplyDivide1, input2X
rocket_control, useMotionPaths attribute to multiplyDivide1, input2Y

rocket_control, useR2 attribute to reverse1, inputY
rocket_control, useR2 attribute to multiplyDivide1, input1Y

reverse1, outputX to pCube1_pointConstraint1, M1W0
reverse1, outputY to multiply1, input1X

multiplyDivide1, ouputX to pCube1_pointConstraint1, L1W1
multiplyDivide1, ouputY to pCube1_pointConstraint1, L2W2

The connections in the Hypergraph

When you are happy with these connections then connect in the orient constaint (there are only three connections to do).

reverse1, outputX to pCube1_orientConstraint1, M1W0
multiplyDivide1, ouputX to pCube1_orientConstraint1, L1W1
multiplyDivide1, ouputY to pCube1_orientConstraint1, L2W2


If find this too complicated then you might find expressions little easier.


Connecting the nodes using Expressions.

The text proceeded with "//" are comments only and have no effect on the functionality.
If you have named everything correctly then you can copy and paste these expressions into the expressions editor and it should work immediately.
// this sets M1W0 to the reverse value of useMotionPaths.
pCube1_pointConstraint1.M1W0 = 1- rocket_control.useMotionPaths;

// this sets L1W1 to the reverse value of useR2 but is attenuated by useMotionPaths
pCube1_pointConstraint1.L1W1 = (1 - rocket_control.useR2) * rocket_control.useMotionPaths;

// this sets L1W1 to the value of useR2 but is attenuated by useMotionPaths
pCube1_pointConstraint1.L2W2 = rocket_control.useR2 * rocket_control.useMotionPaths;



To connect up the orient constraint, just copy the above but swap out the word "point" for "orient".
It should then look like the folowing:-

pCube1_orientConstraint1.M1W0 = 1- rocket_control.useMotionPaths;

pCube1_orientConstraint1.L1W1 = (1 - rocket_control.useR2) * rocket_control.useMotionPaths;

pCube1_orientConstraint1.L2W2 = rocket_control.useR2 * rocket_control.useMotionPaths;



From the top orthographic geometry window, make a NURBS curve in a basic shape of a circle using around 8 to 10 cvs (control vertex) to an overall diameter of approximately 18 to 22 units.   There must be no gap between the start and the end points of the curve so make sure the start and end cvs are at the same point and are tangentially aligned. Rename this new curve as "route_1" then duplicate this curve.   Change the shape of the new curve (route_2) by moving the cvs around in the Y axis.   The outcome should be that you have two distinct routes defined by two continuous curves called "route_1" and " route_2".

Select locator L1 and curve route_1 and select animation section menu Animate/ Motion Paths/ Attach to Motion Path.
Select the newly formed node "motionPath1".
From the channel box highlight the "U Value" channel and right mouse select "cut selected" which removes the default animation curve.
Select locator L2 and curve route_2 and select animation section menu Animate/ Motion Paths/ Attach to Motion Path.
Select the newly formed node "motionPath2".
From the channel box highlight the "U Value" channel and right mouse select "cut selected" which removes the default animation curve.

Keying the channels of the motion path U values directly would be inconvenient because the motion paths can't be selected directly from a geometry window.   It makes more sense to centralize these two U values.

Select rocket_control and add a float attribute with min 0.0 and max 1.0 called "route1Uvalue".
Select rocket_control and add a float attribute with min 0.0 and max 1.0 called "route2Uvalue".
Select rocket_control, motionpath1 and motionpath2.   Using the hypergraph or the connections editor, make the following connections:-
rocket_control, route1Uvalue attribute to motionPath1.uValue.
rocket_control, route2Uvalue attribute to motionPath2.uValue.

From the outliner menu select Display, set the tick next to shapes and open the pCube1 by pressing the plus sign to the left.
Select pCube1Shape node and delete.
Reset the tick next to shapes shapes.
From the outliner, group the rocket under pCube1.
Make rocket visible.
Rename pCube1 to Rocket_grp.

The rocket is now fully rigged and ready to animate.

We can now animate the rocket by moving it using our rocket_grp controller with useMotionPaths attribute set to zero or we can use both motion paths like in the example that follows.

Scroll the time line cursor to frame 0 and select the rocket_grp.
From the channel box, highlight channels route1Uvalue and route2Uvalue and key selected to value 0.
Keeping rocket_grp selected, scroll the time line cursor to frame 100.
From the channel box, highlight channels route1Uvalue and route2Uvalue and key selected to value 1.
Keeping rocket_grp selected, increment the time line cursor to frame 101.
From the channel box, highlight channels route1Uvalue and route2Uvalue and key selected to value 0.
Keeping rocket_grp selected, scroll the time line cursor to frame 200.
From the channel box, highlight channels route1Uvalue and route2Uvalue and key selected to value 1.
Keeping rocket_grp selected, scroll the time line cursor to frame 75.
From the channel box, set channel useMotionPaths to value 1.
From the channel box, set channel route2 to value 0 and key selected.
Scroll the time line cursor to frame 125.
From the channel box, set channel route2 to value 1 and key selected.
From the graph editor, make sure the keys for route1Value and route1Value are LINEAR.
From the graph editor, make sure the keys for route2 at FLAT.
Your rocket should now animate around the route 1 curve until frame 75 when it will gently change to route 2.
If the rocket is facing the wrong way then correct by rotating.

This site and all the learning materials are the copyright of Henry Lutman.   The sole purpose of the site and downloads are to aid the teaching of 3D Computer Animation and related topics.   Please do not reproduce any of the content of this site, or any of the downloads for purposes other than to use as a guide to learning, without the written permission of Henry Lutman.
Web Site Author: Henry Lutman.     Web Site Editor: Martin Capey
Lutman Animation Copyright Henry Lutman