Blade3D Macros provide a very simple way to add logic to the application. Eamples of this is playing random animations, sounds or invoking actions when a trigger volume is entered.
To create a macro right click on the Macros folder in the Object Browser and select the type of macro to create.
Macros can be invoked in a number of ways:
1. Click on the Macro tab in the property sheet for the created macro and set the Play property to True.
2. You can also use a script to dynamically play macros. Here is an example of playing a macro in a script: IObject macros = context.Site.GetObject("#Module/Macros"); IObject macro = macros.GetChild(0); macro.SetValueFromStringByName("Play", "true"); 3. Macros can be triggered through Macro Triggers. For more information see the Trigger Volume section. Here are the types of macros that can be created in Blade3D:
Set Value MacroThe Set Value Macro is used to set the value of a given property for a specified object.
| Target Instance | The object to modify |
| Target Property | The property to change |
| Time | The duration in seconds within which the value of the property will be changed |
| Interpolate | If true, the value of the property will be interpolated over the given time |
Note that when you select the target property for the macro, the control to edit that property will appear at the bottom of the property sheet. Use this control to set the value of the property to the desired one.
In the example below when the macro is played, the radius of the specified sphere will be changed from its current value to 5 over a 10 second period.
Play Sound MacroThe Play Sound Macro is used to play an audio sample or a sound.
| Sound | The audio sample or sound to play |
Play Animation MacroThe Play Animation macro is used to play an animation for a specified animated model.
| Animation | The animation to play |
| Model Instance | The model instance to play the animation for |
Random MacroRandom macros are containers for other macros. When a random macro is invoked, the contained macros will be played randomly.
Distribution
| An enum value which controls how the macros will be selected from the contained macros Flat - All child objects have an equal chance of being chosen Logarithmic - Child objects further down the list have 50% less chance of being chosen |
Compound MacroCompound macros are containers for other macros. When a compound macro is invoked, all contained macros will be played in sequence.