---
# System prepended metadata

title: MS software architecture and logic

---

# MS software architecture and logic

## How do we use and represent the marching squares wall-prefabs? 

We have the following five indoor wall configurations:

![](https://i.imgur.com/6Eel9KI.png)

Adding thicker outside walls, we get seven additional tiles:

![](https://i.imgur.com/aU9aW80.png)

Adding diagonal variants to all purely indoor wall cases, we get nine additional tiles:

![](https://i.imgur.com/MZ1FMUc.png)

The addition of diagonal outside/inside-wall hybrids would add 18 other tiles. And the inclusion of doors/windows and the possibility of adding no walls would make the tileset even bigger. A tileset with 100+ tiles is not feasible for our project. Thus we propose the following solution: Create all the tiles at runtime as a combination of base tiles. 

A possible combination of two base tiles can be seen here:

![](https://i.imgur.com/cWptK6f.png)

We could solve the indoor/outdoor and the diagonal wall cases with only six base tiles (5 if mirroring at runtime is possible) instead of 39. The six cases are shown below.

![](https://i.imgur.com/miGFR2l.png)

Creating appropriate prefabs in unity is straightforward. As a root object, the prefab needs an empty object placed at the rotational center of the mesh on ground level. This is everything. 

!TODO add screenshot of prefab wall

## Do we change the wall thickness while changing the grid-scale?

No: nothing to do here.

Yes: This would mean the maximum wall thickness is defined by: (indoor wall thickness)/2 + gridsize/2. Furthermore, all the prefabs would need a thickness parameter in the root object to change the scaling.

## How to save diagonal walls, no walls, windows, and doors?

In each voxel, it is defined with an enum array. The array has the following possible values: NORMAL, WINDOW, DOOR, NOWALL, DIAGONAL, DIAWINDOW, DIADOOR, DIANOWALL. And each entry stands for one of four wall segments depicted below. 

![](https://i.imgur.com/bE6Z0do.png)

## How do we add windows and doors in the rendering?

Each window and door prefab needs a way to make a suitable hole into the wall.  To create the hole, each window and door prefab also comes with a boolean intersection primitive. We use this primitive to cut holes into the assembled tiles before placing the window or door prefab.

TODO add example of window prefab