Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
3ds Max 6 Bible (2004).pdf
Скачиваний:
55
Добавлен:
17.08.2013
Размер:
50.02 Mб
Скачать

814 Part VII Animation

Table 32-6 (continued)

Motion

Expression

Variable Description

 

 

 

Rising Circular Coil

[Radius1 * cos(360*S),

Where Radius1 is the radius of the orbiting

motion

Radius1 * sin(360*S),

path and AscentSpeed is the speed that the

 

S*AscentSpeed]

object rises.

Back and Forth motion

[HalfDist * cos(360*S), 0, 0]

Where HalfDist is half the distance traveled.

Zigzag motion

[0, ZigDist*mod(F,ZagFreq),

Where ZigDist is the distance the object

 

AscentSpeed*F]

moves before returning the path, ZagFreq

 

 

sets the frequency of the zigzag motion, and

 

 

the AscentSpeed sets how quickly the object

 

 

moves along the path.

Accelerate Quickly

[Dist*sqrt(NT*Scale), 0, 0]

Where Dist is the distance that the object

motion

 

travels and Scale is how long the

 

 

acceleration takes.

Y-Axis Rolling motion

BallPos.x/BallRadius

Where BallPos.x is the linear movement

 

 

along the X axis of the ball and BallRadius

 

 

is the radius of the ball object.

 

 

 

Using Expression Controllers

You can use expressions to control the transforms of objects. You can access these transforms from the Track View or from the Motion panel. You can also use expressions to control object parameters such as a box’s length or material properties such as the amount of illumination applied to a material. You can access all these parameters from the Track View.

Animating transforms with the Expression controller

After you assign a controller to a transform track, the Expression pane in the Expression Controller dialog box includes the current values of the selected object. Position transforms display the X, Y, and Z coordinates of the object; Rotation transforms display the rotation value in radians, and Scale transforms display values describing the relative scaling values for each axis.

Note Radians are another way to measure angles. A full revolution equals 360 degrees, which equates to 2×pi radians. The Expression dialog box includes the degToRad and radToDeg functions to convert back and forth between these two measurement systems.

Animating parameters with the

Float Expression controller

To assign the Float Expression controller, select an object with a parameter or Modifier applied and open the Track View. Find the track for the parameter that you want to change, and click the Assign Controller button. Select the Float Controller from the list, and click OK.

Chapter 32 Using the Expression Controller

815

Note The actual controller type depends on the parameter selected. Many parameters use float expressions, but some use Transform controllers.

After you assign the Expression controller, the Expression Controller dialog box open, or you can open it by right-clicking the track and selecting Properties from the pop-up menu to load the dialog box. Within this dialog box, the Expression pane includes the current value of the selected parameter.

Tutorial: Inflating a balloon

The Push Modifier mimics filling a balloon with air by pushing all its vertices outward. In this tutorial, we use a balloon model created by Zygote Media to demonstrate how you can use the Float Expression controller to control the parameters of a modifier.

To inflate a balloon using the Float Expression controller, follow these steps:

1.Open the Balloon and pump.max file from the Chap 32 directory on the CD-ROM.

This file includes a pump created from primitives and the balloon model with the Push modifier applied.

2.Next, open the Track View by choosing Graph Editors Track View — Curve Editor. Navigate the balloon object’s tracks until you find the Push Value track (found under Objects b3 Modified Object Push Push Value). Select the Push Value track, and click the Assign Controller button. From the list of controllers, select Float Expression and click OK.

The Expression Controller dialog box opens.

3.In the Expression pane, you should see a single scalar value of 0. Modify the expression to read like this:

2 * NT

Click the Debug button to see the value results. With the Expression Debug window open, drag the Time Slider and notice that the balloon inflates.

Note If you use a parameter such as Radius as part of an Expression, then the parameter is unavailable in the Modify panel if you try to change it by hand.

Figure 32-8 shows the balloon as it’s being inflated.

Animating materials with the Expression controller

You can locate the material’s parameter in the Track View and assign the Expression controller to it to control material parameters. Some of these parameters are scalar values, but any material parameter set with a color swatch has a Point3 return type.

When using material parameters and color values, be sure not to combine them in expressions with vector values.

816 Part VII Animation

Figure 32-8: A balloon being inflated using an Expression controller to control the Push modifier

Tutorial: Controlling a stoplight

In this example, we use the if function to turn the colors of a sphere on and off to simulate a traffic light. We accomplish this task by applying the Expression controller to the Diffuse color track. The goal is to show the color green for the first third of the animation, yellow for the second third, and red for the last third.

To change the colors of stoplight sphere using the Expression controller, follow these steps:

1.Open the Stoplight.max file from the Chap 32 directory on the CD-ROM.

This file includes a simple stoplight created using primitives. One of the spheres moves between the three light positions and has had a green material applied to it.

2.Open the Track View — Curve Editor, and locate and select the Diffuse Color track, which you can find under Objects Sphere03 Material #1 Shader Basic Parameters tracks. Click the Assign Controller button, and double-click the Point3 Expression selection.

This assigns the Point3 Expression controller to the Diffuse Color track.

3.Open the Expression Controller dialog box by right-clicking the Diffuse Color track and selecting Properties from the pop-up menu.

Chapter 32 Using the Expression Controller

817

4.In the Expression pane, enter the following:

[if(NT>=.33,255,0), if(NT<.66,255,0), 0]

Then click the Evaluate button, and close the Expression Controller dialog box.

Click the Play Animation button to see the results. Figure 32-9 shows the stoplight alongside the Dope Sheet for this stoplight.

Before leaving this example, let’s examine the expression. The expression works with a Point3 number that includes the values of red, green, and blue. The first Point3 value represents red. Because yellow, in the RGB color system, is composed of equal parts of red and green, we want red to be visible for the last two-thirds of the time. To do this, we make the expression include the following statement:

if (NT >= .33, 255, 0)

This basically says that if the Normalized Time falls in the last two-thirds of the time, then set the red value to 255; if it does not, then set red to 0.

The second Point3 value is green, which appears for the first third of the animation and along with red for the second third to make yellow. So the following expression needs to go where the green value would be located:

if (NT < .66, 255, 0)

Figure 32-9: The Expression controller animates the diffuse color for this object.