Provide commands for interacting with the animation
- Last UpdatedDec 04, 2023
- 1 minute read
Animations are usually bound to external signals. The signals can come from the process simulator or just be available for the instructor.
Typical animations have real-time triggers, such as states, levels, or intensities.
Black box design
A good practice is to design the animation as a black box. This means everything for the animation is self-contained. This includes:
-
Avoid accessing animation graphic context elements from outside the animation logic file. For example, liquid levels, particles systems, or interpolators.
-
Provide a set of commands to be called from outside to drive the animation behavior. Usually, there is a command for each animation parameter driven from outside.
In this way, you can always modify or improve the animation without changing anything outside the animation logic script file.
Code example
A code example for an animation.
<Var name="ST2000_speed" type="sfloat" value="0.0"/>
<Command name="set_ST2000_speed" nodeInfo="">
<local name="val" type="sfloat" value="%0%" />
<setlocal name="val" condition="%0%<0" value="0" />
<setlocal name="val" condition="%0%>1" value="1" />
<setfield field="ST2000_speed.value" value="@%val%@" />
<setfield field="Turbine_ST2001.speed" value="@%val%@" />
<setfield field="SOUND_ST2001_comb.volume" value="@%val%@" />
<setfield field="SOUND_ST2001_main.volume" value="@%val%@" />
<if condition="@%val%@<0.05" >
<execute command="set_ST200_vapor_visible" value="false" />
<else>
<execute command="set_ST200_vapor_visible" value="true" />
</else>
</if>
</Command>