Creating macros—in depth, Basic macro structure – Apple Shake 4 User Manual

Page 914

Advertising
background image

914

Chapter 30

Installing and Creating Macros

Note: You must strip out the alpha channel of the image. You can do this in Shake with
a SetAlpha node set to a value of 0. Set the FileOut to your $HOME/nreal/icons directory,
with the name TabName.Name.nri, and render the file.

3

In the RandomMoveUI.h file, remove the @ sign on line 3, and save the text file.

4

Restart Shake.

The RandomMove node appears with the icon.

Note: In all cases of the above code, case sensitivity is important. If the macro name is
in all capital letters, then all occurrences of the name must also be in all capital letters.
The same restriction applies to parameter and icon names.

For more information on customizing Shake, see Chapter 14, “

Customizing Shake

.”

Creating Macros—In Depth

This section discusses additional information, such as basic macro structure, common
errors when creating macros, and sample macros.

The macro files can be saved into the script that uses them, or can be saved in a file
with a .h file extension. These files are saved in your startup directory, located either in
<ShakeDir>/include/startup, $HOME/nreal/include/startup, or a startup directory under a
directory specified by the environment variable $NR_INCLUDE_PATH. For more
information, see “

Setting Preferences and Customizing Shake

” on page 355.

Basic Macro Structure

The following is what a macro looks like:

dataType MacroName(
dataType parameterName=defaultParameterValue,
dataType parameterName=defaultParameterValue,
...
)
{
Macro Body
return variable;
}

For example, the following function, called “angle,” calculates the angle between two
points, returns a float, using the atan2d function. (For more information, see the “Trig
Functions (in degrees)” section of the table in “

Reference Tables for Functions, Variables,

and Expressions

” on page 941.)

Advertising