Functions – Apple Shake 4 User Manual

Page 958

Advertising
background image

958

Chapter 31

Expressions and Scripting

sign_mask.iff”, “Auto”, 0, 0);

Lovey = SFileIn(“/Server02/VolumeX/Scene12/truck/

truck.iff”, “Auto”, 0, 0);

MaryAnn = Mult(Lovey, mulVal, mulVal, mulVal);
Thurston = Outside(MaryAnn, Skipper, 1);
Ginger = Over(Thurston, Gilligan, 1, 0, 0);

3

Load the script into the interface with Load Script.

4

Open the local Parameters subtree in the Globals tab to reveal the mulVal slider.

In short, if you load a script to be modified in the interface, you probably want to
declare it as a curve type of data. If you are going to execute the script on the
command line and it is not going to change (that is, it is not animated), you can omit
the curve data type. There are some examples in the following sections.

Functions

Shake is a collection of functions. Some functions modify images, such as Blur. Some
return a number, like distance() (calculates the distance between two points) or cosd() (a
cosine function in degrees, not radians). Other functions build the interface, such as
nuiToolBoxItem. The nuiToolBoxItem function loads a button into the interface and
attaches a function to the button. When you call a function, you assign a variable to it.

The following example reads the angle parameter for the Rotate1 node, and returns the
cosine in degrees, assigning it to the variable named myCos:

curve float myCos = cosd(Rotate1.angle);

You can also use functions inside of other functions. In this example, the cosd function
is inside of a Rotate function:

Rotate1 = Rotate(FileIn1, cosd(45));

When you place a function inside of another, it is called a “nested function.” In both
cases, you call the function, and then enclose its parameters in parentheses. When you
assign a variable to a function, terminate the line with a semicolon, as shown in both of
the examples above. Everything in between the parentheses can be formatted
however you want, so the following two examples are identical:

Mult1 = Mult(FileIn1, 1,1,1);
and
Mult1 = Mult(

FileIn1,
1,
1,
1

);

Advertising