The internal functioning of MORSE is based on Blender’s Game Engine events. These are defined in the Logic buttons window, using the graphical interface called “Logic Bricks”. These are a set of predefined Sensor, Controller and Actuator events which can be linked together. Actuators in particular are important because they are the places where Python scripts are called.
Each object in Blender have its own set of Logic Bricks. The entry point of a Morse scene is defined in the Scene_Script_Holder object which is available in ${MORSE_ROOT}/data/props/basics.blend (this object is automatically added by the Builder API if it is not found in the simulation). This specific object contains the entry point morse.blender.main.init() and the finalisation point morse.blender.main.finish(). It contains also the “Logic Bricks” to control cameras, reset the simulation, ...
Let’s take a look at the module morse.blender.main.
The morse.blender.main.init() is responsible to initialize all the Morse subsystems. It includes:
The initialization of all components, including middlewares and modifiers, is done by instantiating an object of the Python class specified in each component by the variable classpath. This classpath is not stored in blender file anymore, but described in the builder component (see morse.builder.sensors for example).
The method which terminates the simulation (called when you press ESC) is the morse.blender.main.finish()). However, the real cleaning logic is in morse.blender.main.close_all(), which try to properly finalize all resources used by the simulator, in particular, resources used by the different middlewares.
The Scene_Script_Holder defines too a method which it calls at each simulator loop. It is the method morse.blender.main.simulation_main() which: