Implementing the “config” package
The “config” package implements the evacuation simulation’s configuration. In this tutorial, we provide a detailed description of the steps necessary to provide a concrete implementation of the “config” package classes. Namely, we discuss the implementation of the following classes: “SkyBoxEnum” and “EvacuationVisConfig”.
1. Implementing the enum “SkyboxEnum”
A skybox is a method for creating backgrounds to make the 3D scene looks bigger than it really is. In this enumerator, you should list the set of Sky boxes that can be used in the 3D visualization of the simulation. To implement “SkyboxEnum” :
- Create a new “Enum” inside the “config” package. Right click on the “config” package > New > Enum > and create an enum named “SkyboxEnum”.
- Write the code below in the enumerator implementation to list the set of Sky boxes available to the evacuation simulator. Please note that these sky boxes are currently provided by DIVAS model library and are ready to be used.
package edu.utdallas.mavs.evacuation.simulation.config; /** * The name of skyboxes available */ public enum SkyboxEnum { /** * Sunny skybox */ Sunny, /** * Sunny nature skybox */ Sunny_Nature, /** * Cloudy skybox */ Cloudy, /** * Dusk skybox */ Dusk, /** * Night with Red skybox */ Night_Red, /** * Night with Stars skybox */ Night_Stars, /** * Sunrise skybox */ Rise, /** * A sunny day with sea skybox */ Sunny_Sea, /** * Sunset */ Sunset }
2. Implementing the class “EvacuationVisConfig”
This class describes the user configuration for the 3D visualizer. To implement this class:
- Create a new class named “EvacuationVisConfig” inside the “config” package. Right click on the “config” package > New > Class > and create a class named “EvacuationVisConfig”.
- Write the below code to implement the class:
package edu.utdallas.mavs.evacuation.simulation.config; import edu.utdallas.mavs.divas.core.config.ConfigKey; import edu.utdallas.mavs.divas.core.config.ConfigProperty; import edu.utdallas.mavs.divas.core.config.VisConfig; public class EvacuationVisConfig { public static final ConfigKey TERRAIN = ConfigKey.create("terrain"); public static final ConfigKey WATER = ConfigKey.create("water"); public static final ConfigKey SKYBOX = ConfigKey.create("skybox"); public static void register() { VisConfig visconfig=VisConfig.getInstance(); ConfigProperty terrain = new ConfigProperty<>(TERRAIN, false, "Run the visualizer without terrain rendering", "Terrain", false); visconfig.addCustomProperty(terrain); ConfigProperty water = new ConfigProperty<>(WATER, false, "Run the visualizer without water rendering", "Water", false); visconfig.addCustomProperty(water); ConfigProperty skybox = new ConfigProperty<>(SKYBOX, SkyboxEnum.Sunny, "Selects the skybox of the simulation", "Skybox", false); visconfig.addCustomProperty(skybox); visconfig.save(); } }
As shown in the above code, the developer can import from the configurations provided by the DIVAs framework and add it to the evacuation 3D visualization configuration. The above code describes three visualizer configurations currently provided by DIVAs and are used by our evacuation simulator:
- Terrain: This feature renders a terrain around the simulated environment.
- Water: This feature renders a water filter around the simulated environment and the rendered terrain.
- SkyBox: Displays a sky box that makes the 3D scene looks bigger than it really is.
The figure below shows an example of water and terrain surrounding the simulated environment