Титульная страница
ISO 9000 ISO 14000
GMP Consulting
 
Mastering 3D Studio MAX R3

Previous Table of Contents Next


CHAPTER 16
Animating with MAXScript

Featuring

  Working with Animation Controllers
  Manipulating Rendering Results
  Manipulating Bitmaps with MAXScript

Animating with MAXScript

MAXScript can be used to edit and adjust animation parameters. In this chapter, you will learn how to assign controllers, to manipulate keyframes, and even how to reverse the keys, playing your animation backwards. You will see how you can use expressions and scripts as custom animation controllers. In addition to all these features, MAXScript can control rendering and manipulate bitmap files. Let’s examine all these features and much more in this chapter.

Working with Animation Controllers

You can assign and change the animation controllers to all tracks of an object. You can also assign and change keyframe information and adjust many animation parameters through MAXScript.

Every animated parameter in MAX requires a different animation controller, which can be assigned in MAXScript. The controller will define how the keyframes will be interpolated, which means how the animation will be built between the keyframes. You can use MAXScript to adjust the information of each controller and keyframe.

Assigning Controllers

Access each property’s controller simply by adding .controller to the property. For instance, obj.position.controller will show us which controller is assigned to the object’s position.

All controllers can be assigned through MAXScript. Among them are these controllers:

  Bezier
  Linear
  Noise
  Path
  TCB
  Euler_XYZ

Let’s assign a noise controller to the scale of an object and adjust its parameters:

 obj = sphere()
 obj.pos.controller = Position_XYZ()
 obj.scale.controller = noise_scale()
 obj.scale.controller.noise_strength = [2,2,0]
 obj.scale.controller.frequency = 0.2
 obj.scale.controller.fractal = false

TIP You can use showproperties obj.scale.controller to list the Noise Scale options.

Track View Properties

You can access the object properties as they appear in the Track View. To do so, you need to add [index] after the object name. obj[3] is the Transform track and obj[4] is the Node track (called the Object track in Track View). These properties are called subanims.

These are the subanims an object can have:

Index Subanim
1 Visibility track
2 Space warps
3 Transform
4 Node (Object) track
5 Material
6 Image Motion Blur Multiplier
7 Object Motion Blur On Off

Notice that some objects will not use all subanims, if the property in a subanim cannot be assigned to that object—for instance, lights will not have materials assigned. However, even when a subanim is unused, the numbering stays the same.

To know how many subanims you have in a node, use the .numsubs property. To know the name of the subanims, you can use GETSUBANIMNAME and GETSUBANIMNAMES. GETSUBANIMNAME requires the index of the subanim. GETSUBANIMNAMES returns an array of all the properties, listing them in the Listener and making them available to searches such as FOR loops.

You can change the controller of any subanim, and any of its properties. You can also know if the subanim is or is not animated by using the .isanimated property.

The .value property will list the value of a subanim. If an object is animated, the .value property will show the subanim value at the current frame.

Figure 16.1 shows the Track View of a sample object—a sphere. To create the sphere and access its subanims, type:

 obj = sphere()
 obj.numsubs
 getsubanimname obj 3
 obj[3].numsubs
 getsubanimname obj[3] 1
 obj[3][1].value


FIGURE 16.1  Track View of the subanims, and their syntax in MAXScript

Notice that obj.numsubs returns 7, which is the number of subanims an object has. Then, getsubanimname obj 3 will list the name of the third subanim, in this case #transform.

Then we checked to see how many subanims Transform has, using obj[3].numsubs. It returns 3, which is expected since the sphere has a PRS Transform controller.

Finally, we asked for the name of the first subanim in Transform, and for its value. Notice we used [3][1], which means we’re accessing the first subanim of the third subanim. An XYZ Position controller also has 3 subanims, which means the Y axis is obj[3][1][2].


Previous Table of Contents Next

© 2000, Frol (selection, edition, publication)

 
Rambler's Top100