» Back To Index
The <script> node
Function
The script node makes it possible to load an external script within the main XML script.
This external script can be written in various languages. But currently, only scripting based on
the LUA scripting language is supported.
Please refer to the
Demoniak3D/LUA API section for more information on the available functionalities.
LUA scripts loaded this way are autonomous and can have several operating modes (run_mode).
<script
name=""
filename=""
active="TRUE"
run_mode="EXECUTE_EACH_FRAME"
run_in_new_thread="FALSE" />
<raw_data>
<![CDATA[
]]>
</raw_data>
</script>
script element
script is the xml tag that defines a script node.
Attributes:
- name - [STR127] - name of the node. This name will make it possible to refer this node throughout
the XML script.
- filename - [STR255] - location of the file of script relative to thw XML script.
- active - [BOOLEAN] - enables (TRUE) or disables (FALSE) the script execution.
- run_mode - [ENUM] - specifies the working mode of the script:
- INIT: scripts before this run mode are executed once t the end of the scene tree compilation process. It is redommended
to create only one script of this kind per scene. This type of script cannot be started in a new OS thread.
- EXECUTE_ONCE: theses scripts are run once before rendering the first frame and can be started in a new OS thread.
- EXECUTE_EACH_FRAME: the script is run at each frame (synchronous). This kind of script cannot be started in a new
OS thread. It is useful for animations - valeur par défaut
- ASYNCHRONOUS: the script is run in an asynchronous manner. It can be started, for example, by a hotkey.
This type of script can be started in a new OS thread.
- run_in_new_thread - [BOOLEAN] - allows to run a script in an OS thread different from
the main thread of Hyperion. Use with full knowledge of the facts!
- group - [STR127] - name of the group in which to add the current node. A group makes it possible to control the
behavior of several objects in a single way.
raw_data element
raw_data allows to integrate the source code of a script directly in the XML code without requiring
an external file.
Example
<script name="updateScene" run_mode="EXECUTE_EACH_FRAME" >
<raw_data><![CDATA[
x, y, z = HYP_GetCameraPosition("Main_Camera");
HYP_SetShaderProgram_Constant_3f("waterShader", "view_position", x, y, z );
t = HYP_GetElapsedTime()*0.001;
HYP_SetShaderProgram_Constant_1f("waterShader", "time_0_X", t );
]]></raw_data>
</script>