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

Previous Table of Contents Next


PART VI
Using MaxScript

CHAPTER 13
MAXScript Basics

Featuring

  The MAXScript User Interface
  Performing Math Operations
  Using Strings
  Using Conditions
  Repeating Tasks
  Creating Functions
  Text File I/O: Reading and Writing Data

MAXScript is the easiest way to start programming in 3D Studio MAX. You do not need previous programming experience, nor do you need any extra software to work with it.

MAXScript was introduced in MAX R2. It gained momentum in MAX R2.5 but still needed some extra features and support, especially from the developers, who needed to add extra programming code to support MAXScript. It has a very important role in MAX R3, since it is now part of the main program and is used everywhere. The new functions and methods in MAX R3 enable you to go deeper inside MAX, even creating plug-ins through scripts.

You’ll see throughout this section examples and applications done with MAXScript. You’ll see that MAXScript is not hard to learn and will save you a lot of time in future projects.

This chapter has more theory than practice, but it’s well worth the time required to understand the foundations of MAXScript. You’ll be able to better grasp the basics and the way the language works. The remaining chapters in this Part will provide more exercises to help you learn.

The MAXScript User Interface

You can work with MAXScript through different parts of the interface, as seen in Figure 13.1. You will use the Utility tab whenever you have a MAXScript Utility. Most of your time will be spent on the Listener, which is the command-line area.


FIGURE 13.1  MAXScript interface

Utility Tab and Menu Bar

You can work with MAXScript using the Utility tab, as in MAX R2. To access it, open the Utility tab and click on the MAXScript button. You will see some buttons and a drop-down list. The buttons are the same actions found in the MAXScript menu:

Button Action
Open Listener Opens the Listener window
New Script Starts an empty MAXScript Editor
Open Script Opens a script in the MAXScript Editor
Run Script Runs a script

The drop-down list will display the Utility scripts you have loaded.

Macro Recorder

The Macro Recorder is a new feature in MAX R3 that allows you to record every action in MAX, in the form of a script. This script can also be dragged to a toolbar or Tab, which will automatically create a button for the script.

The Macro Recorder can be turned on and off using MAXScriptØMacro Recorder. When on, the Recorder is checked in this menu. Not all options are recordable, but only a very few are not. (See “Using the Macro Recorder” later in this chapter for more information about this feature.)

Listener

The Listener is probably the most important interface item in MAXScript. It’s where you type commands, see the output of functions, and view the recorded items. It’s divided into two areas, the Macro Recorder pane (pink) and the output/command pane (white).

You can use the Listener as a floating window, as a viewport, or in the Mini-Listener. Besides all the functions in the Listener, the Mini-Listener shows you a list of the latest commands typed or recorded and allows you to select any of them.

Sometimes, when you open the Listener, the Macro Recorder pane doesn’t show because it’s hidden in the top of the Listener window. All you need to do is drag the separating bar and it will show, or use a menu command to turn on the Macro Recorder.

MAXScript Editor

When starting a new script or opening an existing one for editing, MAXScript supplies you the MAXScript Editor. It is regular text-editing software with extra features to help us write scripts:

  Using Ctrl+D, your scripts will be color-coded, separating commands, comments, and strings.
  Ctrl+B highlights the parentheses in your script.
  Ctrl+right-click brings up a shortcut menu that will allow you to jump directly to commands, functions, and UI items.

Plug-in Scripts

Plug-in scripts are scripts that act like regular plug-ins. They can be objects, modifiers, render effects, helpers, etc. Plug-in scripts do not require an interface, since they are incorporated into the interface, as new plug-ins would be. See Chapter 18 for more information.

Working in MAXScript

Let’s create a simple script, illustrating how you can work in MAXScript. You’ll start creating the bubble-like Nicle system shown in Figure 13.2. First you’ll record an action and save it using the Macro Recorder, and then you’ll write a script that enables MAX to automatically create this bubble Nicle.


FIGURE 13.2  Bubble particle system

Follow the steps below to record the creation of a bubble fountain:

1.  Open the Listener in one of these ways:
  Select MAXScriptØMAXScript Listener.
  In the Utility tab, open the MAXScript rollout and select Open Listener.
  Right-click the Mini-Listener and select Open Listener.
  Press F11.
2.  In the Listener, select Macro RecorderØEnable.
3.  Turn on 3D Snap.
4.  In the top view, create a SuperSpray about 30 units large.
Now you’ll set the options that will make the bubbles rise.
5.  Go to the Command PanelØModify tab and specify the following values:
Location Parameter Setting
Next to object’s name Color Cyan
Basic Parameters rollout Off Axis Spread 20 degrees
Off Plane Spread 180 degrees
Percentage of particles 100
Viewport Display Mesh
Particle Generation rollout Particle Quantity Rate 3
Particle Motion Speed 3
Emit Stop 100
Life 30
Particle Size 6
Particle Timing Variation 30
Particle Type rollout Standard particles Sphere
Bubble Motion rollout Amplitude 30
Period 60


Previous Table of Contents Next

© 2000, Frol (selection, edition, publication)

 
Rambler's Top100