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

Previous Table of Contents Next


Using Built-in Selections

MAX has built-in selections based on the object type. This makes it easier for you to select all 3D objects in the scene, or all lights, etc. These built-in selections are:

Selection Objects Selected
objects All objects in the scene
geometry All 3D objects
shapes All 2D objects
lights All lights
cameras All cameras
spacewarps All space warps

You can combine these selections with the previous commands to create any selection you need. For instance, these three commands select all cameras and 3D objects, and then remove some specific objects:

 select cameras
 selectmore geometry
 deselect $*02

The last command removes from the selection every object that has “02” at the end of its name.

Identifying Objects with Object Classes

MAXScript identifies each different object type as a class. For instance, spheres are from Sphere class and boxes are from Box class. This helps you filter objects and know exactly which objects you want to select or manipulate.


NOTE Classes aren’t valid only for objects. Classes are ways to identify each and every object, modifier, material, or effect in MAX.

In order to know which class an object belongs to, use the CLASSOF command. For instance, create and select a sphere in your scene. Now type classof $. MAXScript will return the class of that object, sphere.

Besides the class, MAXScript has a property called superclass, the general category the object type belongs to. For spheres and boxes alike, typing superclassof $ will return geometryclass, since both classes are 3D objects.

You could now build simple script to select all spheres in the scene:

 clearselection()
 for i in 1 to objects.count do
 (
 if classof objects[i] == sphere then selectmore objects[i]
 )

In this script, CLEARSELECTION is a new command; all it does is remove all selections. The FOR command steps through each object in the scene. The IF command checks to see whether the object is a sphere and, if it is, adds the object to the selection.

Accessing Global Object Properties

Some properties, like name and class, are valid for all objects in the scene. You’ll address them often in your scripts, so let’s examine them.

You can access all the properties listed in the Object Properties dialog box (Fig-ure 14.2) in MAXScript. These properties include the name, wireframe color, and cast and receive shadows. Other properties, valid for almost all objects, will define the hierarchy, the material, whether the object is hidden or frozen, whether it is a target or is looking at one target, and more.


FIGURE 14.2  Object Properties dialog box

All properties in the Object Properties dialog box can be accessed through MAXScript. Just type object.property = value and you will set its value. If the property is represented by a check box, the value will be either true (checked) or false (unchecked). Other properties require a different value; Object Channel, for instance, is an integer number. Here are a few of the properties that can be accessed:

Property Description
.name Object name
.wirecolor Viewport color
.ishidden Returns true if the object is hidden
.gbufferchannel Object channel ID
.visibility Controls the object’s visibility track
.renderable Controls whether the object renders
.boxmode Display as box

TIP You do not need to memorize all the properties. Just turn on the Macro Recorder and change any number of object properties. All changes will be recorded.

Spline Properties

MAXScript has some properties that are valid only for splines. These properties control the General Properties for splines, which are shown in Figure 14.3.


FIGURE 14.3  Splines General properties rollout

In scripts, these properties are .steps, .optimize, .adaptive, .renderable, .thickness, and .mapcoords, relating exactly to the same commands displayed in Figure 14.3. None of these properties supports direct animation.

Replicating Objects

Sometimes you might need to create copies of an object, maintaining or not maintaining a relationship with the original. You can do so using any of three commands: COPY, INSTANCE, or REFERENCE. They produce exactly the same result as the Copy, Instance, and Reference operations in MAX. For example, if you create a box using b = box() and want to copy it, use c = copy b. REFERENCE and INSTANCE work exactly the same.


NOTE Another interesting way to create a copy is the SNAPSHOT command. It copies the object, converting it to an editable mesh, but it considers all space warps and effects applied to the object.

Accessing an Object’s Position, Rotation, and Scale

It’s very important for you to know where the object is in space and which transformation has been applied to it. You might access a box object in MAXScript and read its height, but this will not serve for anything if you don’t read which Z scale was applied to it.

All transformations depend mainly on which controller has been assigned to an object. Usually, you access position, rotation, and scale simply by adding .position, .rotation, and .scale to an object.

Position and Scale

Position is the easiest to work with. Simply adding .pos or .position will usually access the object’s position. Position’s value is a point3 variable, where you can access independently .x, .y, and .z.

Position values can also be specified when the object is created (as in b = box pos:[10,20,10]), just like any other object option.


Previous Table of Contents Next

© 2000, Frol (selection, edition, publication)

 
Rambler's Top100