Skip to content

Tutorial ‐ Step 1

ptaillandier edited this page Jul 23, 2024 · 20 revisions

Step 1: Generation of the GAMA VR model

Creation of the project

Create a new GAMA project, then copy inside in this project the folders "models" and "includes" from "Toy Models/Traffic" of the model library. In the "model" folder, delete all the models except "Traffic and Pollution.gaml". To make the test easier later, set "fullscreen" to false in the "carte" display of the "traffic" experiment.

Fullscreen to false

Generation of the VR model

Open the "Traffic and Pollution.gaml" model in the editor, then, select in the "Unity VR" menu "Model to VR". A Wizard should open. ⚠️ The "Unity VR" menu only appears if you have the mouse cursor in the text editor of the model.

MenuVR

Page 1 - Define the general information to define the VR experiment

Minimum duration of a cycle (in s)

This represents the minimum time between two simulation steps. As GAMA will be sending information to Unity at each simulation step, setting a minimum value for this variable ensures that the Unity client doesn't receive too much information too quickly.

In this tutorial, we will set the value to 0.1.

Main experiment

Name of the experiment, which will be extended to include a VR version.

In this tutorial, we will extend the only experiment defined: traffic.

experiment

Page 2 - Define the information about the display

Main display

Name of the display, which will be extended to include a VR version.

In this tutorial, only we will extend the only display defined: carte.

Display to hide

Displays that will not be displayed in the experiment.

In this tutorial, we don't want to have the carte display, so it must be checked.

display

Page 3 - Define the agents and Unity properties for the geometries to send

General information

An important step is to describe how the entities (agents, geometries) will be sent to Unity, in particular how they will be represented in Unity and how the player will be able to interact with them. In the same way as for "aspects" in GAMA, it will be possible to define sets of properties that can then be assigned to agent species: for each agent species, you will be able to choose a way of sending it to Unity.

Regarding the representation of entities, the tool allows them to be represented in 2 different ways: by their geometry (with optional 3D extrusion) and by a prefab already defined in Unity.

For interactions, it is possible to define whether the entity will have a physical existence in the world (collider), whether the player will be able to interact with it and how he or she will be able to interact: interaction by ray or possibility of catching the entity. Finally, it is possible to define whether Unity will send GAMA information on the entity's location (for example, if the player moves it).

Definition of the building unity properties

In this tutorial, we want to send all building geometries to Unity without interaction. We therefore add a new property for this purpose. We have for that to fill the part Defining a Unity property: in the name field, write "building". As we don't want to interact with the buildings, leave all Interaction checkbox unchecked. For Aspect, as we want to represent building geometries and not use a prefab, leave has a prefab unchecked. We want to give them a height of 10m and show them in black. So we need to fill the height field with "10.0" and the color field with "black". We will not use a particular material for these agents, so we let the material field empty. Click then on the button "Add/Update".

buildingUP

Definition of the road unity properties

In this tutorial, we want to send all road geometries to Unity with the possibility to interact with them (to let the player close roads by selecting them through the ray interactor). We therefore add a new property for this purpose. Similarly as for the building Unity properties, we have for that to fill the part Defining a Unity property: in the name field, write "road". We add a tag as well to facilitate the identification of this type of entity in Unity. For that, in the tag field, write "road". As we want to interact with the roads using the ray interaction, in Interaction check the box has a collider and is interactable. For Aspect, as we want to represent road geometries and not use a prefab, leave has a prefab unchecked. We want to give them a height of 1m and show them in gray. So we need to fill the height field with "1.0" and the color field with "gray". Click then on the button "Add/Update".

roadUP

Definition of the people unity properties

In this tutorial, we want to send to send the location of the people agents to Unity without any interaction with them. We therefore add a new property for this purpose. In Defining a Unity property, write "people" in the name field. As we want no interaction with the people entities, leave all the check box in Interaction unchecked. For Aspect, we want to represent people agents using a specific prefab called Car, we then have to check has a prefab. In Path to the Prefab, we have to specify the path to the Prefab. For reasons of Unity limitations, this prefab must absolutely be in the Resources directory of the Unity project. In this tutorial, we want to use the Car prefab located in folder "Assets/Resources/Prefabs/Visual Prefabs/City/Vehicles/", we then write in Path to the Prefab "Prefabs/Visual Prefabs/City/Vehicles/Car". We set the scale of the prefab to "30.0", the rotation coefficient to "-1.0", the rotation offset to "-90.0" and the offset along the Y-Axis to "1.1". Click then on the button "Add/Update".

peopleUP

Page 4 - Define the species of agents to send to unity

This page lets you specify which agent species to send with which propriety. It also allows you to specify for each species whether agents will be sent only once at initialization (static) or at each time step under certain conditions.

In the case of this tutorial, we want to send roads and buildings only at initiation, and people agents at each time step. We therefore need to check these 3 species.

  • For buildings, we want to use the "building" property and check the "Static" checkbox.
  • For roads, we want to use the "road" property, adding a 2m buffer around the roads to represent them as surfaces rather than lines. To do this, we need to fill the buffer field with "2.0". Finally, as with buildings, we only want to send these roads at initialization, so we need to check the "Static" checkbox.
  • Finally, for people agents, we want to use the "people" properties. As we want to send them at every time step, we can leave the "Static" checkbox unchecked and leave the default value in the when field (send agent list at every time step).
geometries

Page 5 - Define the information about the player

Minimum number of players

How many players are required to run the simulation.

In this tutorial, we'll set this to 1.

Maximum number of players

Does an unlimited number of players can connect to the game?

In this tutorial, we'll check this option.

Maximum number of players

If the model/game has a maximum number of players, what is this maximum number (it must be greater than 0).

In this tutorial, we'll set it to 1 to limit the number of players to one.

Init location of the players

Sets the initial location of the players.

In this example, we'll set it to {1000,1000, 100}.

Perception radius of player agent

If this option is greater than 0.0, it filters the agents to be sent to Unity, sending only those agents that are at a distance less than or equal to the perception radius.

In this tutorial, we'll leave the default value (0.0) as we don't wish to filter the agents sent to Unity.

Minimum distance between agents to be sent

If greater than 0.0, this option filters the agents to be sent to Unity, so as to send only those agents that are too close (distance greater than this minimum distance).

In this tutorial, we'll leave the default value (0.0) as we don't wish to filter the agents sent to Unity.

Player Size

Player display size in GAMA.

In this tutorial, we'll set it to 20.0.

Player color

Player display color in GAMA.

In this tutorial, we'll set it to #red.

player

Finalizing

You can then click on finish to generate a new file: "traffic and Pollution-VR.gaml", which will be used to launch the VR version of the model (experiment vr_xp). If the file does not appear, refresh the folder (right click on the folder, then "refresh").

ModelCreated

You can now proceed to Step 2