an index, specifying the index of the modifier to delete, counting from the top of the stack.
collapses the modifiers out of a stack, leaving a resultant editable mesh as the base object of the node. If there are no modifiers in the stack when this is called, no action is taken. If you want to force an object to be an editable mesh, use the following function, convertToMesh().
The Modifier superclass in the class reference.
Mesh modifier-related functions in the the Mesh Operations topic.
Node modifier-related functions in the Node cass reference topic.
Modifier Sub-Object Transform Properties
Modifier Sub-Object Transform Properties
In MAXScript, the values of modifier sub-object transform properties, such as centers and gizmo pos, rotation and scale, are not given in the current working coordinate system. This is in contrast to scene node transform properties. The values given are typically modifier local and are exactly as would be seen in the sub-object's corresponding track view or as might be referenced in an Expression controller track variable for that subobject property.
FFD control point sub-object properties are now accessible through this mechanism but have several special considerations. The control points properties are named as they appear in the track view, subject to the MAXScript convention of using '_' underscores for spaces, so for example:
$baz.ffd_3x3x3.control_point_32 = [1,2,3]
The considerations are as follows:
1 You can only access control points that have ALREADY been animated by hand. The FFD doesn't actually create accessible control points until you do this, a behavior that shows up in the track view in normal MAX use - you can't actually place control point keyframes in the track view until you've interactively animated the control point at least once away from time 0.
2 Control point coordinates are in FFD lattice space. This is a normalized space, with [0,0,0] at the lower left-hand corner (at control_point_1) and [1,1,1] at the opposite corner of the FFD lattice, so you have to be careful about computing and scaling correct coordinates when you set them. This is also reflected in the track view for FFD control points in normal MAX use - if you look at their values in a keyframe property dialog or a function graph, they are in this normalized lattice space, not world-space coordinates. You'd have to work in this space also if you tried to use expression controllers to control FFDs.
The Rendering Environment
You can use the following functions for maintaining the list of atmospherics in the global rendering environment:
adds the atmospheric
gets the indexed atmospheric. Index is 1-based.
setAtmospheric <index> <atmos>
sets the indexed atmospheric
The global MAX variable numAtmospherics gives you the number of current atmospherics in the rendering environment.
The following global MAX variables give you access to the global rendering environment:
backgroundColor : color
backgroundColorController : color controller
ambientColor : color
ambientColorController : color controller
environmentMap : texture map
useEnvironmentMap : boolean on/off
numAtmospherics : integer, readonly
ambientColor = color 10 10 25
environmentMap = bitmapTexture filename:"foo.bmp"
created with Help to RTF file format converter
You can bind spacewarps to scene objects and access spacewarp binding modifiers from the scripter.
The form is:
bindSpaceWarp <node> <warp_obj_node>
which is used to bind the 1st argument scene node to the 2nd argument spacewarp object scene node.
Spacewarp bindings show up in the modifier stack and can be accessed like any other modifier. Use the deleteModifier() function to unbind objects from spacewarps.
See the Modifiers topic for more information about working with the modifier stack.
The following scriptable controllers are available in MAX, mirroring the expression controllers:
Float Script float controller
Position Script position Point3 controller
Point3 Script Point3 controller
Rotation Script rotation Quat controller
Scale Script scale Point3 controller
They function in similar way to expression controllers, providing a properties dialog in which a script can be entered that is used to compute the controller value. The primary advantages of script controllers are:
1 They can use all the features of the MAXScript language including loops, scripted functions, pathnames, etc.
2 Almost any property of any object in the scene can be used to help compute controller values, including things like mesh vertices, values of properties at arbitrary frame times, and other non-animatable properties that are not accessible in Expression controllers.
3 They can use MAXScript global variables to communicate and coordinate with other controllers and scripts in MAX.
lets you programmatically get and set the text for scripts. For example,
$foo.position.controller.script = "$baz.pos - [20,20,35]"
When you assign a Script controller to some parameter, a properties dialog becomes available through the right-mouse-button menu or the Properties button on the Track View toolbar. This dialog contains two text boxes and several buttons:
Script text box: You type the script to compute the controller value here. See the section below on writing controller scripts for details.
Result text box: This box shows the results of an evaluation or any error messages caused by errors in your script.
Evaluate button: Cause an evaluation of the controller script to be made and prints the result in the Result box. The evalutation is computed for the current position of the MAX time slider.
Load/Save buttons: Load and save scripts to text files.
Close button: Compiles and checks the controller script and if all is OK, close the properties dialog. Any problems result in a dialog box asking whether you really want to close the box with an incorrect script. If you do, the controller yields a null value (0, [0,0,0], etc.) when evaluated by MAX.
Writing Controller Scripts
MAX interprets the text you type into the Script text box as the body of a MAXScript block expression, so you can type as many expressions as you want on as many lines as you want and they are evaluated in turn and the value of the last expression is taken as the conroller value. This value must yield the right type for the controller, Float for float, Point3 for position, Quat for rotation, etc.
Because the text is effectively 'inside' a block expression, you can declare local variables which are visible only within the script and are temporary for one evaluation. You can also declare or access global variables that are shared with all other scripts in MAXScript and hold their values from one evaluation to the next.
A controller is always evaluated by MAX with respect to a specific animation time. This might be the current time slider or incrementing frame time if an animation is playing or a render is under way.
In the case of Script controllers, the time being evaluated is used to establish an automatic 'at time' context around the controller script, so any properties you access (outside of other explicit 'at time' expressions) yield the correct values for the current controller evaluation time. This means you don't have to do anything special in your scripts to work at the correct time. You can access the eval time if you need with the standard MAXScript variable, currentTime. You can also reference scene property values at other times by using explicit 'at time' expressions in your scripts, as in normal MAXScript programming.
Remember that MAXScript lets you write multi-line string literals, if you need.
A position script keeping the object at the center of all other objects in the scene as they move about:
local pos = [0,0,0]
for o in objects where o != $foo do
pos += o.pos
pos / (objects.count - 1)
The above script computes the average position of all objects except the current one (written as $foo here) by setting up a local variable that iterates through all objects except $foo, accumulates a total position vector, and computes the average in the last line, which is the final result of the script.
A position script keeping the object attached to the highest vertex in a given object:
local high_index = 1, high_z = (getVert $foo 1).z
for i in 1 to $foo.numVerts do
if (getVert $foo i).z > high_z then
high_index = i
high_z = (getVert $foo i).z
getVert $foo high_index
The above script runs over the vertices in $foo remembering the index of the vertex with the largest z and returns that vertex's coordinates as the new position.
Script controllers are not automatically updated when you interactively modify objects that they depend on.
If you move the time slider or if you animate the changes and then play the animation, the changes are reflected automatically. Because the scripts can refer to other objects in very indirect ways or conditional ways, it is not possible for MAXScript to automatically determine the objects a script depends on.
Track View Nodes
Added access to global Track View nodes. You can now access and modify controllers in the Global Tracks and Video Post sections in Track View, and even create new named global tracks. Among other things, these can be used to provide keyframe-able parameters in your scripted utilities.
There is a new class and several new variables and functions in support of this:
MAXTVNode is the class whose instances represent track view global track nodes. Each track can have any number of sub-tracks or sub-controllers. The sub-tracks and sub-controllers turn up as properties so you navigate through the nesting using property access.
There are three track nodes you can access through global variables, the root node to which you can add new custom tracks, the existing Global Tracks node and the Video Post tracks node which lets you get at global track and video post controllers. These nodes are also accessible as properties on the root node.
the track view node name as it appears in trackview
trackViewNodes : the overall root track view node
globalTracks : the top-level Global Track node
videoPostTracks : the top-level Video Post track node
newTrackViewNode [<tvnode>] <name_string> [#hidden]
if the <tvnode> argument is supplied, adds a sub-track node to it. If not, creates a new 'top-level' track in the Track View. If the optional #hidden flag is supplied, the node is not visible in the Track View.
deleteTrackViewNode [<parent>] <tvnode>
deletes the given node from the supplied parent or the top-level.
addTrackViewController <tvnode> <controller> <name>
adds the sub-controller to the given trackview node
deleteTrackViewController <tvnode> <controller>
deletes the controller from the given track view node
-- access a video post track
videoPost.glow.size = 5
-- set up some visible tracks for some keyframable parameters in a rollout panel
my_tracks = newTrackViewNode "Grinner"
happy_ctrl = position_controller ()
addTrackViewController my_tracks happy_ctrl "Happy"
-- plant keyframes in rollout spinner handler if the animate button is on
rollout grinner ...
on happy changed val do
happy_ctrl.value = [x, y, z]
-- add a new float controller to the global tracks float controller list
globalTracks.float.controller.available.controller = bezier_float ()
Scene Node User Properties
The functions described in this topic give you access to scene object user properties, accessible in the MAX User Interface in the User Defined tab in the Object Properties Dialog. The MAX SDK provides a way to get at the user defined properties in the Object Properties dialog in two ways -- either as one single string representing the entire contents or as a set of key/property pairs in the form:
<key1> = <property1>
<key2> = <property2>
where the keys are identifiers (with the same syntax as names in MAXScript) and the properties can be numbers, booleans (true/false) or text strings. If you set up the property box in the above form, there are two new MAXScript methods for setting and getting individual keyed properties. There are two other methods that let you treat the property text as a single big string, which can also be used to save and load property sets in the key/property form.
Caution: There is currently a bug in the get/set property functions in the MAX SDK for text string properties that truncates retrieved string properties at the first space character in the string value.
The <node> methods are: