# Voxel-Based Digital Twin Framework for Earthwork Construction
## 4 Implementation of the Proposed System
### Graphical Simulation Environment for Model-Equipment Interaction
#### 4.1.3 Model Integration in Platform  
A platform was developed to implement the proposed system. The Unity game engine was selected because it can import 3D data from design tools, provide a robust physical system, and simulate model-equipment contact forces, allowing the simulation to be enhanced through scripts. It also supports the deployment of cross-platform development and interactive user interfaces (UIs), where the operator or manager can interact with the system. Unity has three challenges that must be overcome for successful platform implementation. First, Unity manipulates the data in mesh format, which requires the conversion of earthwork data, such as surface models, into mesh models. Second, the manipulation of voxel data in Unity requires an adaptive tree structure. Third, metadata or attributes attached to each voxel must be preserved. The earthwork geometrical data were converted into meshes inside Rhino 3D. The meshes can be imported into Unity 3D in Object (Obj), Drawing Exchange Format (DXF), or Filmbox (Fbx) formats. The problem with the Obj and DXF formats is that they export the selected model as an integrated mesh; for example, voxels are exported as a single mesh that cannot be manipulated in Unity 3D. Furthermore, exporting each voxel separately and integrating it into Unity 3D is time-consuming. Hence, the Fbx format was \begin{table}
\begin{tabular}{c c c} \hline \hline
**Model/Asset** & \multicolumn{2}{c}{**Input Setting**} \\ \hline  & Arm forward, arm backward & K, J \\  & Boom forward, boom backward & M, N \\  & Bucket up, bucket down & O, P \\  & Swing frame left, swing frame right & Keypad 7, 8 \\  & Move forward, move backward, brakes & W, S, Space \\  & Turn right, turn left & D, A \\ \hline  & Move forward & Arrow up \\  & Move backward & Arrow down \\  & Turn right & Arrow right \\  & Turn left & Arrow down \\  & Brake & Space \\  & Unload & Unload button \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Keyboard button configurations for moving equipment and its parts. Figure 9: Ground, target, and voxel-based as-planned model. selected to convert the earthwork models into meshes along with the material, color, and texture information. The ground and target models were assigned different layers with defined materials, colors, and unique names. The voxels were divided into different layers based on the soil type and exported in the Fbx format. This has the advantage of assigning them a name and tag in the Unity platform, which makes them recognizable. The earthwork geometrical models were exported through the Fbx format. The attribute conversion was achieved through the following two steps: exporting the attribute information into a comma-separated values (CSV) file from Rhino and importing it into Unity. A custom script was designed to iterate through each voxel in the design tool, extract key parameters, and save them in a CSV file. The next step is to read the exported attributes and integrate them into voxels. The script first identifies each voxel based on its ID and position, and then maps its respective data accordingly, ensuring that the data is assigned correctly to each voxel. The pseudocode for the script is presented in Algorithm 1: Conversion of voxel physical properties from Rhino 3D to Unity 3D.