Skip to content
MatthiasHock edited this page Sep 15, 2020 · 2 revisions

Basic Tutorial

Project Creation

Execute the Visual SceneMaker by double-clicking on the .jar file or running it from the terminal.

After startup, you will be greeted by the Welcome screen. Here you have the option to create new projects, open existing ones or open example projects.

Click on New Project to open the Visual SceneMaker editor. Enter a name, e.g. "Test", and confirm.

Basic SceneFlow

You will now see an empty editor.

Let's start with a simple example. In the middle of the screen, you see a large, empty area, which we call the SceneFlow editor. In the top of the column left of it, you can see the different components used to construct a SceneFlow: two kinds of nodes, a speech bubble for comments, and six kinds of edges to connect nodes.

You can add components into the SceneFlow by dragging and dropping them into the editor. Add two Basic Nodes into the editor. The first node has a red arrow on its left side, indicating that it is the start node, i.e. execution of the SceneFlow starts there.

Now drag a Timeout Edge into the editor, drop it on the left node, and select the right node as the target. A Timeout Edge triggers a transition to the next node after a specified time has passed. You can use the default time of 1000ms.

Repeat this process with an Epsilon Edge from the right to the left node. An Epsilon Edge triggers a transition to the next node immediately after entering the current node. TODO after entering or after executing its code?

You're now ready to execute your first SceneFlow. Press the Play button in the middle of the tool strip at the top, choose a folder to save your project in, and the SceneFlow will execute. You can see the currently active node highlighted in red and the trace (sequence of previous nodes and edges) highlighted in grey.

A simple counter

Let's add some more interesting behavior to our SceneFlow. Instead of transitioning after one second from the left to the right node, let's create a counter and transition based on its value. In order to do so, we first have to create a variable. Right-click anywhere in the white background of the editor and select Add variable from the menu. In the dialog, enter a name for the variable (e.g. x), select its type (choose Int for a whole number variable; the default Bool represents a boolean, i.e. a truth-valued (true or false), variable). You can leave the initial value of 0 as it is. If you want it to be different, you can click on the magnifying glass icon next to the value field and enter a valid arithmetic expression. TODO grammar?

Confirm the dialog. You will now see the variable in the upper-left corner.

The desired behavior of our system is to increment a variable every second, and then transition to the node N2 once the value of the variable exceeds some threshold.

How can we increment our variable in a fixed time step? Every node can be associated with a sequence of commands in the ?? language. TODO Upon entering a node, these commands are executed sequentially. They can e.g. change the value of a variable, or play scenes or actions (described later, see TODO link).

You can open the command editor by right-clicking on node N1 and selecting the Add Command Execution option. We want to increment the value of our variable x. To do so, we can enter the expression x = x+1, which can be read as "the value of the variable named x becomes the current value of the variable named x plus one".

Now, whenever we enter node N1, x gets incremented. So, to count up every second, we can reenter N1 every second, by creating a Timeout Edge transition from N1 to itself.

Every node can only have one outgoing Timeout Edge, so we first have to delete the existing edge from N1 to N2. You can do that either by right-clicking on the edge and selecting Delete, or by selecting it using a left-click and pressing the delete key on your keyboard.

Now create a Timeout Edge from N1 to itself, with a time interval of one second.

Take a moment and execute the model. You should see N1 as the active node, see the Timeout Edge taken once every second, and in the upper-left corner of the editor, you can observe the value of x in real-time, being incremented with every transition. However, there is no way for us to reach N2 right now. So let's now add a way to transition based on the value of x, and to reset it afterwards.

To achieve this, we need a new kind of edge: the Conditional Edge. The Conditional Edge requires a boolean (truth-valued) expression to decide whether to take its transition or not. After the completion of all commands associated with a node, the expression of the Conditional Edge is evaluated. The transition is then taken if it evaluated to true, and not taken if it evaluated to false.

Finally, we now need to add a command to N2 to reset the value of x, i.e. set the value of x to its initial value of zero again: x = 0.

Now execute the system again: you should see x being incremented once per second, and after 5 seconds, when the value of x becomes 6, the transition to N2 should be taken, x's value be reset, and then immediately the transition from N2 to N1 be taken.

Congratulations! You have now finished your first introduction to the Visual SceneMaker. You can continue to more advanced tutorials TODO link, or browse the glossary here TODO link.