In this lesson, you will
learn how to rotate the wheels by an amount that corresponds to
the distance travelled by the car model.
Let’s start by taking
a look at the trigonometry involved in calculating the wheel rotation.
In any circular object,
the amount of rotation (a)
is defined by the radius of the circle and the arc length encompassed
by the a angle.
That amount of rotation (a)
expressed in radians, is equal to the arc length, divided by the
radius of the circle (arc length / R), where:
- The radius of the
car wheel is constant and equal in this case to 13 units.
- The arc length,
when flattened, represents the distance travelled by the car and
its wheels.
Therefore, the wheel
rotation calculation (arc length / R) becomes distance / 13.
Whereas the radius of the wheel is constant and equal to 13, the
distance travelled is variable.
Set up the lesson:
- Continue from the previous lesson or open car_rig_02.max.
Rotate the wheels (in World X coordinates):
- In the Perspective viewport, select the
car body.
The car is currently
oriented on the World X axis: you will begin working in this coordinate
system.
- Right-click the car body object and from
the quad menu, choose Wire Parameters.
- From the menu, choose Transform Position (2nd) Position XYZ X Position.
NoteIt is important to
always leave the first animation controller at the top of the list
(in this case, the Position XYZ Controller) untouched, since it
serves as a “lock” for the parent/child relationship. When choosing controllers
to work on, always work from top of the controller list downward, starting
with the second controller.
A rubber band shows the
link you are about to make between your two selected objects.
- Select the front left wheel of the car
(Wheel-FL).
- From the menu, choose Transform Rotation (2nd) Euler XYZ Z Rotation.
The Parameter Wiring
#1 dialog opens. You use this dialog to set up one and two-way control
relationships between objects. The position and rotation of the
two objects you just selected to affect one another are highlighted.
- On the Parameter Wiring dialog, click
the right-pointing arrow above “control direction”.
This ensures that the Chassis X
position is controlling the Wheel-FL Z rotation and
not the other way around.
The bottom-right corner
of the Parameter Wiring dialog displays the wheel object Expressions
panel. It shows the distance travelled as X_Position.
- Next to X_Position, type /13.
The expression should
now read X_Position/13, the distance divided by the radius of the
wheel.
- Click Connect, but do not close the dialog.
- Test your work by moving the car body
on its X axis.
Notice how the front-left
wheel does not rotate. Even though you added a position list controller
to the car and wheel, the first controller in the list (the one
that ensures the parent/child “lock”) is still active. You need
to make the second position controller (the one used in the wiring process)
the active one.
- If you moved the car model, press Ctrl+Z to undo the move.
- With the car body selected, on the Motion panel PRS Parameters rollout,
click the Position button at the bottom of the rollout.
- On the Position List rollout, highlight
the second Position XYZ controller and click Set Active.
- Try moving the car on its X axis again.
TipTo better see the
wheel rotation, use the Front viewport, and change its display mode
to Smooth + Highlights.
The wheel now rotates,
and at the correct rate, but its motion is backward.
- In the Parameter Wiring dialog, on the
Expressions panel, add a minus sign (-) in front of the expression,
then click Update.
- Move the car on its X axis again and
notice how the wheel rotates in the proper direction.
- Repeat the preceding steps for each of
the remaining three car wheels.
TipTo select the wheels
on the right side of the car, you can press H after you choose the car body’s
X Position, and then use the Pick Object dialog to pick the wheel.
Because the wheels were
mirrored, the wheels on the right side of the car do
not need the minus sign added to their expression, whereas
those on the left side do.
- Close all the Parameter
Wiring dialogs.
Add subcontrollers for Y rotation:
In the previous procedure,
you learned how to add controllers that determine car wheel rotation
for the length of distance travelled by the model along the World
X axis. However, if you tried to rotate the car in any way, wheel
rotation would be reduced or stop altogether. You therefore need to
add controllers that account for the car’s displacement in a Y direction.
- In the Top viewport, select the car body
object and rotate it 90 degrees clockwise so that its front bumper
points at 12 o’clock.
The car is now oriented
on the World Y axis, so you will begin working in this coordinate
system.
- Orbit the Perspective viewport
until you can see the front left side of the car.
- Move the car forward and
backward on the Y axis. Notice that the wheels do not rotate.
To get the wheels rotating,
you will need additional animation controllers, ones that will control
the car’s displacement in the Y direction. You will add these as
sub-controllers, so you do not overwrite the controllers already
in place.
- Go to the bottom-left corner of the 3ds Max window,
right-click the MAXScript area, and choose Open Listener Window.
- On the MacroRecorder panel, highlight
the line that reads:
$.rotation.controller.Available.controller
= Euler_XYZ ()
Be sure not to include
the line’s carriage return when you make your selection. Press Ctrl+C to copy this line to memory.
If you are not continuing
from the previous lesson, this line will not be available from the
Open Listener window. If this is the case, copy the line from the
text of this tutorial.
- Close the MAXScript Listener
window, then select the front left wheel
(Wheel-FL).
- Click inside the MAXScript entry field
(the white box in the bottom-left corner of the 3ds Max window),
press Ctrl+V to paste
the line of code, then press Enter.
- On the Motion panel PRS Parameters rollout,
make sure that the Rotation button is active, Then on the Rotation
List rollout, verify that a new sub-controller has been added to
the rotation list (there should be 3 in all).
- Repeat step 7 to add a fourth rotation
sub-controller. You will need this later on in the tutorial.
The front left wheel
should now have four Euler XYZ tracks.
- Select another wheel and
repeat steps 7 to 9 until all four wheels have four Euler XYZ tracks
in their respective rotation lists.
Rotate the wheels (in World Y coordinates):
- Select the car body, then right-click
and from the quad menu, choose Wire Parameters.
- From the menu, choose Transform Position (2nd) Position XYZ Y Position.
- Select the front left wheel (Wheel-FL).
- From the menu, choose Transform Rotation (3rd) Euler XYZ Z Rotation.
- On the Parameter Wiring dialog, click
the right-pointing arrow above Control Direction to ensure that
the Chassis Y position is controlling
the Wheel-FL Z rotation.
- On the right-hand Expressions panel,
type /13, then click Connect.
The expression for the
left-hand wheel should be Y_Position/13
- Click Connect.
- Repeat steps 3 to 8 for each of the other
three wheels.
NoteThe expression for
the right-hand wheels should be –Y_Position/13.
- Close the Parameter Wiring
dialogs.
- In the Top viewport, rotate the car so that it
is not pointing horizontally or vertically.
- On the main toolbar, click (Select And Move), then set
the coordinate system to Local.
- If you need to, adjust the Perspective
viewport so you can see the side of the car.
- Move the car on its local X axis. Notice
how the wheels are rotating properly.
- In the Top viewport, rotate the car until
the front bumper is pointing to the left.
- Save your file as mycar_rig_03.max.
Rotate the wheels (under a path constraint):
In the previous procedure,
you learned how to add controllers that rotate the car wheels for
any distance of travel in World X and Y space. The wheels will therefore
rotate properly when you manually move the car around the scene
in any direction.
However, you would most
often animate motion of a car by placing it on a predefined path
using the Path constraint. This type of animation requires a different
expression.
This new expression uses
the same formula (distance divided by radius) as the ones you have
been using, but while the radius of the wheel remains constant,
the distance travelled is calculated differently.
- Continue from the last procedure or open the file car_rig_03.max.
- From the main menu Selection Sets list, choose Car
Path.
A warning message displays.
- Click Yes to display the path you will
use to animate the car motion.
- From the main menu, choose Create Helpers Point.
- On the Parameters rollout, turn on Box
and set Size to 100.0.
This increases the size
of the helper gizmo and makes it easier to select in the scene.
NoteMany animators use
the Dummy helper instead of Point. The advantage of using a Point
helper is that you can adjust its size without having to scale it.
Scaling a helper in a hierarchy will affect its children objects:
This is an effect that usually you want to avoid.
- In the Top viewport, click a point near
the car to place a Point helper.
- With the Point helper still selected,
on the main toolbar click (Align), then in any viewport,
select the car body.
- In the Align Selection dialog Align Position group,
make sure X Position and Y Position are on and Z position is off.
- In the Current Object and Target Object
groups, make sure Pivot Point is chosen, then click OK.
- In the Front viewport, move the Point
helper on its X axis to the right until it is just to the left of
the rear axle of the car.
The Point helper location
you have specified will become the pivot point of the car when the
front wheels turn.
- On the command panel Name And Color rollout, rename the helper Dummy_CAR.
- In any viewport, select the car body.
- On the main toolbar, click (Select And Link), then
in the Front viewport, click the car body and drag to the Point
helper. This makes the car body the child of the Point helper.
- On the main toolbar, click (Select Object) to exit
link mode.
- From the main toolbar Selection Sets
list, choose Garage_All. Click Yes to dismiss
the warning and unhide the rest of the scene geometry.
- In the Top viewport, use (Zoom Extents) to view the entire
parking lot.
- In the Perspective viewport, click the
Perspective label and from the menu, choose Cameras Camera_Wall-E.
Animate the dummy by constraining it
to a path:
- In any viewport, select the Dummy_CAR helper.
- From the main menu, choose Animation Constraints Path Constraint.
- In the Top viewport, click on the green
path (CarPath).
The helper and the linked
car are repositioned at the start of the path.
NoteYou could, as an
alternative, constrain the car directly to the path. In this case,
however, it is preferable to constrain the helper parented to the
car so you can retain extra control over the car’s behavior (such
as defining skids around tight corners).
- Scrub the animation.
The car’s orientation
remains constant throughout the animation.
- In the Motion panel Path Parameter rollout Path Options group,
turn on Follow.
- Scroll down to display the Axis group,
and turn on Flip.
The Flip option prevents
the car from driving in reverse.
- Scrub the animation again.
Car motion is improved,
but at the last frame the car points at an awkward angle. This is
a common behavior to paths based on a NURBS curve. You will now
correct this problem.
TipNURBS curves, when
used as animation paths, provide a smoother “ride” than ordinary
splines.
- Go to the last frame of the animation
(frame 150), and make sure the Point helper is selected.
- Turn on (Auto Key).
- In the Motion panel Path Parameters rollout Path Options group % Along Path box, type 99.9 and
then press Enter.
- Turn off (Auto Key) and scrub the
animation.
The car is properly oriented
on the path, but the wheels no longer rotate. This is because the
expression that defined the wheel rotation you formulated earlier
no longer applies. The distance travelled by the car was dependent
on the X and Y displacement in the World coordinate system. Displacement
is now tied to the length of the path and the percentage of the
path that the car has travelled. You must therefore modify the expression
to reflect this change.
Wire wheel rotation to a path:
- In any viewport, select the animation
path (CarPath) then go to the Utilities panel.
- Click Measure and in the Shapes group,
take note of the path length.
- Select and right-click the Point helper,
then from the menu choose Wire Parameters.
- From the menu, choose Transform Position Path Constraint Percent.
- Click one of the car wheels and choose
Transform Rotation (4th) Euler Rotation Z Rotation.
- On the Parameter Wiring dialog, set the
control direction to the right, which places the Percent parameter
in control of the wheel rotation.
- On the right-hand Expressions panel,
type (2365*Percent)/13.
NoteThe value 2365 is
the length of the animation path you measured earlier. When multiplied
by the percent variable, it calculates the distance the car has
travelled at any given moment in time along the path. When divided
by the radius of the wheel (13), it provides the amount of rotation
needed for the wheel to turn.
- Click Connect.
- Scrub the animation to see the wheel
rotation.
- To better see the animation, click (Time Configuration) and
in the Time Configuration dialog Time Display group, choose FRAME:TICKS.
- Repeat steps 3 to 8 to link the Point
helper to each of the remaining three car wheels.
Remember to add a minus
sign (-) operator to the expression of the wheels on the right side
of the model so they don’t rotate in the opposite direction.
- Save your file as mycar_rig_04.max.