What's New in Director 8.5 > Working with Models and Model Resources > Models > Model commands

 

Model commands

Use these commands to work with models:

Command

Description

Returns

addChild(aNode, preserveWorld)

Adds aNode to this model's list of children. An equivalent operation is to set aNode.parent to equal this model.

The preserveWorld argument is optional. It can have two values: #preserveWorld or #preserveParent. If the value is #preserveWorld, the default, the world transform of the child being added remains intact. If the value is #preserveParent, the child's existing transform is interpreted as parent-relative.

Nothing

child[index]

Returns the child at the specified position in the index.

Node object

child(name)

Returns the child named name.

Node object

clone(name)

Clones a model named name, adds it to the child list of the model's parent, and adds it to the world.

The clone shares the same model resource, shader list, and parent as the original model, but it has unique copies of the model's transform and modifier properties.

All children of the model are automatically cloned. This can be avoided by removing the children, performing the cloning operation, and then adding the children back.

If the name is omitted or is "", the clone isn't added to the model palette, has no parent, and has no children. This option lets you quickly create temporary model instances.

Lingo model object

cloneDeep(name)

Clones both the model and the model resource used by the model's children. Modifications to the clones' resource don't affect the source model's resource.

This is a more memory-intensive operation than clone(name).

Lingo model object

addtoWorld()

Adds the model to the currently active 3D world, setting its parent as "world."Equivalent to model.parent=member("scene").group("world")

All newly created models are added to the world by default, without it being necessary to use this command.

Nothing

getWorldTransform()

Sets this model's position and orientation relative to the world model's position and orientation.

Nothing

removeFromWorld()

For models whose parent hierarchy terminates in the world, this sets their parent to void and removes them from the world. Otherwise it does nothing.

Nothing

isInWorld()

For models whose parent hierarchy terminates in the world, the value is TRUE (1) and the model is potentially visible.

TRUE (1) or FALSE (0)

registerScript(eventName, handlerName, scriptInstance)

Registers a handler named handlerName that is called in the scriptInstance when the member function sendEvent() is called with eventName as an argument.If scriptInstance is 0, a movie script handler is called.

The user defines what eventName is.

TRUE (1) or FALSE (0), with TRUE (1) indicating that the event happened and FALSE (0) that it did not

addModifier(symbol)

Adds the modifier symbol.

TRUE (1) if symbol is a valid modifier

FALSE (0) if symbol is not a valid modifier

removeModifier(symbol)

Removes the first modifier identified by symbol.

TRUE (1) if symbol is a valid modifier and attached to the model

FALSE (0) if symbol is not a valid modifier or is not attached to the model

update()

Updates animation timing without rerendering.

Used to force update of bone positions in an animation while inside a Lingo call.

TRUE (1) or FALSE (0)

translate(xIncrement,yIncrement,zIncrement,relativeTo)

Moves the model forward by xIncrement along the X axis, yIncrement along the Y axis, and zIncrement along the Z axis.

The relativeTo parameter is optional. It determines how arguments are interpreted. The possible values are as follows:

#self: the default. Increments are applied relative to the model's local coordinate system.

#parent: increments are relative to the model's parent's coordinate system.

#world: increments are relative to the world coordinate system. Equivalent to #parent if parent is the world.

node (model, light, camera, or group): increments are relative to the coordinate system of the argument object.

Nothing

translate(directionVector, relativeTo)

Moves the model directionVector.length() in the direction of the vector directionVector. The relativeTo argument is optional and defaults to #self.

Nothing

translate(x,y,z,relativeTo)

Moves the model distance x along the X axis, distance y along the Y axis, and distance z along the Z axis. The relativeTo argument is optional and defaults to #self.

This command can also be written astranslate(vector(x,y,z) relativeTo).

Nothing

rotate(x,y,z, relativeTo)

Rotates the model by around the X axis, around the Y axis, and around the Z axis.

The relativeTo argument is optional and defaults to #self. If included, it defines the coordinate space of the axes.

This command can also be written asrotate(vector(x,y,z) relativeTo).

Nothing

rotate (position, axis, angle, relativeTo)

Rotates the model around the axis vector in the specified position the specified number of degrees. The relativeTo argument is optional and defaults to #self.

Nothing

scale(uniform ¬Scale)

Scales the model the same amount in all directions.

Nothing

scale(x, y, z)

Scales the model by a factor of x in the X dimension, y in the Y dimension, and z in the Z dimension. Scaling is applied in object-relative space.

Nothing

pointAt(worldPosition, worldUp)

Rotates the model until it points at the world-relative position worldPosition. The optional worldUp argument gives the general position of the model's Up axis. The exact position can't be determined using this method.

Both the object-relative axes are defined by the pointAtOrientation property. Default values are an object-relative forward direction of vector (0, 0, -1) and an object-relative up direction of vector (0, 1, 0).

Nothing

getWorldTrans ¬ form()

Calculates and returns a transform that converts object-relative positions for this model into world-relative positions.

A transform object