A Fire Escape Simulation System Based on the Dijkstra Algorithm

Despite the support of all kinds of fire prevention measures and hightech fire prevention equipment, fires still occur frequently because of both anthropogenic factors and natural disasters. This issue has drawn the attention of schools, all levels of government, and other organizations. Many types of organizations carry out fire drills throughout the year. Because this kind of drill cannot anticipate the specific circumstances of each fire, which are generally far more complicated than drills, most people cannot correctly choose the optimal escape route from real fires. Thus, a fire-scene virtual simulation system based on the Dijkstra algorithm is here proposed to address such problems as casualties caused by frequent fires and the inability of most people to correctly choose a fire escape route. This virtual fire escape simulation system uses Maya to carry out 3D reconstruction of the fire scene, the Unity engine to conduct interactive function design, and the Dijkstra algorithm to calculate the best escape route. The results of the example indicate that the simulation system solves the problems of the traditional simulation system, such as stiffness, lack of intelligence, and poor simulation.


Introduction
Fires occur frequently, and this has drawn the attention of schools, all levels of government, and many other types of organizations [1]. Most organizations that work out of modern buildings hold on-site fire drills [2][3][4][5][6], hoping to reduce casualties from fire through simulation exercises [7]. However, this kind of drill cannot fully anticipate the specific circumstances of each fire. A real fire situation is complex, and ordinary people often cannot choose the optimal escape route in the face of confusion. Traditional fire simulation systems cannot provide an escape route selection function, meaning that the fire safety simulation exercise cannot achieve its intended purpose.
Dijkstra algorithm indicate that the simulation system solves the problems of the traditional simulation bsystem, such as rigidity, unintelligence, and poor imitation.

The Dijkstra Algorithm
The Dijkstra algorithm, a representative shortest route algorithm [14,15], is mainly used to determine the shortest route between points (between nodes). The core feature is that one of the nodes is taken as the center node and spreads out layer by layer until the target node is obtained as follows: (1) Specify a node. For example, obtain the shortest route between node "A" and other nodes (Fig. 1).
(2) Create two collections (L, Y), where collection L is used to store the nodes that have obtained the shortest route and collection Y is used to store nodes that have not obtained the shortest route.
(4) Obtain the node with the shortest route in the collection Y and add it to collection L. For example, A->D=2. If the distance from AD plus D to B, C, and E is less than the distance from A to B, C, and E, collection Y will be updated. At this point, collection L contains: A->A=0, A->D=2; collection Y contains: A->B=3, A->C=3, and A->E=9 (Fig. 3).  (6) Judge the distance from A to D to E and the distance from A to C to E. Take the shortest distance, and then update collection Y. At this point, collection L contains: A->A=0, A->D=2, A->B=3, A->C=3, and A->E=6. Collection Y contains: null (Fig. 5).
(7) The shortest route between A and each other node is finally obtained.

Fire Escape Simulation System Based on the Dijkstra Algorithm
The fire escape simulation system based on the Dijkstra algorithm uses Maya to perform 3D reconstruction of the fire scene, the Unity engine to conduct interactive function design, and the Dijkstra algorithm to calculate the best escape route, in cooperation with technology such as the Visual Effect Graph and Shader Graph, to carry out special effect simulations of many fire scenarios. The system will be released on several platforms, principally the Virtual Reality (VR) platform and the mobile platform. Students can use VR headsets and mobile phones to experience realistic fire simulations in an interactive manner, which can give a more grounded sense of then experience while maintaining the safety of a fire drill.

Fire Escape Simulation System Development Process
The methods used to develop the fire escape simulation system based on the Dijkstra algorithm and the overall process of the proposed method are shown in Fig. 6.
The escape function module based on the Dijkstra algorithm was developed in the Unity engine. At the same time, intersection of ball detection technology with the addition of explosion point technology was used so that fire and explosion effects could be added for each explosion point. An eye-catching user interface (UI) was designed to provide the users with a clear sense of experience. Finally, the system generated was published to HTC VIVE.

Maya Technology
Produced by Autodesk, Maya [16][17][18] is a powerful 3D animation software that is often applied to 3D modeling, film and television animation, and film and television special effects. The most commonly used modeling method is polygon modeling, where developers can create clay figures to precisely control each point of the model. The operation mode of modeling is novel, and the Unique Visitor (UV) module in the new version of the software has been upgraded, which is convenient and suitable for VR application. For this reason, Maya was chosen in the study for modeling, UV processing, and map production of the dormitory scene.

Unity Technology
This fire escape simulation system has very high criteria for the authenticity of 3D scenes, which requires an engine capable of producing 3A level images. Many interactive functions and the production of UI should be added, and the implementation of these functions and effects can be achieved only by Unity.
Unity [19][20][21] is an engine for developing 3D games, especially in the mobile game market. The development language is C sharp (C#), which is based on module-oriented development and is compatible with all platforms. Unity is used to achieve the special effects display and interactive functions in the system.
Unity development involves all module-oriented development, and the Visual Effect Graph [22] module is mainly used in the system. The powerful effect and control power of this module were key to our realization of vivid special effects. However, the Shader Graph module was also necessary for us to realize physical rendering.

Visual Effect Graph Technology
There are many explosion and flame effects in the fire simulation system, but these effects, especially photographic-level effects, are difficult to achieve using traditional computer graphics (CG) technology [23,24]. Moreover, operation efficiency should be considered. The use of the latest Visual Effect Graph technology of Unity ensures smooth operation of the system and helps to achieve photographic-level effects.
Visual Effect Graph is a new technology that was released after Unity 2018.3, which is a new special effects tool. It is similar to the original particle system, but its most intuitive feature is a visual node that supports programming and runs beyond the Graphics Processing Unit (GPU) [25,26]. These features enable it to support a larger graphic computation burden and provide a more flexible development space for developers and creators. Therefore, it can be used to create many special effects in AAA games.
The methods of using Visual Effect Graph technology in Unity are shown as follows.

1) Installation and configuration
Visual Effect Graph needs to be installed by the Package Manager. It currently only supports the High-Definition Render Pipeline (HDRP), so HDRP needs to be installed. After installation, the HDRP configuration file should be created in the create menu of the project window.

2) Creation and editing of VFX Graph
First, a Visual Special Effects (VFX) Graph asset must be created. After dragging it into the scene, a game object is generated automatically. A Visual Effect module will be automatically added to Unity. Refer to the VFX Graph asset created before, which can be edited after being opened (Fig. 7).
System: The collection of several contexts enclosed by dashed lines is called the System. One System contains Initialize, Update, and Output. One VFX Graph can contain more than one System. Spawn: This context defines the quantity and time of particles that are generated.
Initialize: The context, similar to the start method of writing a script, is used to initialize the particles and should be started with the Capacity and Bounds.
Capacity defines the maximum quantity of particles that can exist at one time. This value is important because it determines how much memory is allocated initially. The value should be set according to the quantity of particles produced. It can commonly be calculated by the formula: Rate × Max Lifetime = Capacity.
Bounds: Defines the simulation region of the particles.
Update: The context, similar to the Update method of writing a script, is used to set how the particle changes over time. Forces such as collision and force fields can be used by it.
Output: Used to render particles. It determines the type, texture, color, and orientation of the generated particles. A System can contain more than one Output.

3) Operational test
By setting the appropriate parameter values, the effect shown in Fig. 8 can be obtained.

2) PBR rendering effect test
Through the connection of various nodes and debugging parameters, the edge luminous effect shown in Fig. 9 can be obtained.  The escape route module was improved and added to the existing VR reproduction system owing to its functional modules and shortcomings.
The function modules are as follows: 1) Scene module: Create fire scene models, add special effects in the process of various fires, and add a real-time updated UI.
2) VR core module: The Dijkstra algorithm, the VFX Graph technology, and the Shader Graph technology.
3) Real-time simulation: Triggering events and real-time display of interactive effects.

Case Study
The Fire and Mars effects were added to the scene by the Visual Effect Graph technology, and all material rendering was realized based on the Shader Graph technology. A real-time UI for real-time interaction and escape route function module based on the Dijkstra algorithm was added to select the optimal route. According to the research, this system enabled users to use VR to control the scene and UI interaction, and truly restored various effects of the fire scene.

Conclusion
A fire-scene virtual simulation system based on the Dijkstra algorithm was developed to solve the problems of traditional simulation systems, such as casualties caused by frequent fires and the inability of most people to correctly choose a fire escape route. This paper discusses the overall design, development process, and technical solution plan of the fire escape simulation system. The key technologies such as the Dijkstra algorithm, Visual Effect Graph, and Shader Graph and explain how various explosions and flame special effects simulations are realized and how the fire escape simulation prototype system was developed. The results of the case study indicate that this method can reproduce visual effects of the fire scene, solving the problems of the traditional fire simulation system, which include the lack of any optimal escape route module, lack of intelligence, and low level of realism.