# Using Game Engines for Visuo-Haptic Learning Simulations
## 3 Proposed Solution
### Proposed System Architecture  
This work proposes a novel architecture to develop multi-device visuo-haptic solutions in game engines. This architecture considers key-features that they provide in simulations. In Figure 3, the high level architecture diagram is presented. Each of the components that make up this architecture are described in detail in the following paragraphs.  
* **Haptic Connectivity (HC)**: This module is in charge of establishing connection between multiple haptic devices and the Haptic Manager (HM) component. Using the HC component, information of haptic devices, such as its maximum linear force, stiffness and damping, can be obtained. Moreover, haptic devices' positions, buttons' states, and orientation are read and sent to the HM component. By using this approach, all visual and physics interactions between the haptic device and virtual objects are delegated to the game engine, and the calculation of interaction forces and their control are generated within the HM component. Finally, this module is the one in charge of retrieving and deploying the interaction force calculated in the HM component.
* **Haptic Manager (HM)**: This module is in charge of retrieving haptic devices' information from the HC component and calculating interaction forces using the game engine's physics module. This component is in charge of initializing a thread to enable proper interactions of haptic devices, and it sends their information to the game engine. Using this data, the game engine is able to display the positions of the haptic device in the virtual scenario. Finally, interaction forces between the haptic device and virtual objects are computed using collision parameters from the physics module of the game engine. After their calculation, the generated forces are controlled, according to the haptic devices' models that are being employed, and they are sent to the HC component to send force feedback to the user.
* **Game engine**: Most game engines have the following four sub-modules. In the following paragraphs each one is described:
* **User Interaction**: game engines allow developers to create user interfaces (UIs). Their systems make it easy to display UIs that are positioned in the world among other 2D or 3D objects in the Scene. Moreover, modern applications often need to support a wide variety of different screen resolutions, and game engines' UI systems usually include a variety of tools for this purpose that can be combined in various ways. Finally, by using UIs, the mouse device, and keyboard, one can modify parameters in the simulation to modify the interactivity in the scene.
* **Physics**: To provide convincing physical behavior, an object in an interactive application must accelerate correctly and be affected by collisions, gravity and other forces. Game engines' built-in physics modules provide components that handle the physical simulation for developers. Virtual objects can behave passively in a realistic way by modifying few parameter settings. Moreover, by controlling the physics using scripts, developers can give an object the behavior of a vehicle, a machine, or even a piece of cloth. Finally, when haptic devices are incorporated, it is necessary to send a force to the haptic; then, by using their collision detection algorithms, the HM component can calculate interaction forces and perform the necessary control algorithms to send the force feedback to the haptic device.
* **Graphics**: game engines are equally suited to create 2D or 3D applications or both. Materials and textures are rendered on the surface of virtual objects to make them appear as realistic environments. The Camera can be used in perspective or orthographic mode, which can help developers generate views that enhance interactivity. Finally, light sources can be set-up easily around the world.
* **Visual Rendering**: game engines perform the necessary processes to compile and create the virtual environment and display it in the video device.