Skip to content

Commit

Permalink
props
Browse files Browse the repository at this point in the history
  • Loading branch information
TomRuisseau committed Jul 16, 2024
1 parent 1f33d00 commit f8101b8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
37 changes: 36 additions & 1 deletion src/Doc/Steps/props.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# Props
# Props placement

### Quad tree

The props are placed in the room using a quad tree : the space is divided into four equal nodes, which represent rectangles in the room. The props are placed one by one randomly in one of the biggest empty nodes, namely the empty nodes with the lowest depth. The node chosen is then divided into four nodes once again. The process is repeated until all the props are placed inside the room. This ensures that the props have the highest chance of being placed without overlapping with other props, thus limiting the number of tries needed to place them.

<p align="center">
<img src="../../Img/ISGT.jpg" alt="Quad tree steps">
<br>
<em>Figure: 3 steps of the quad tree division process for prop placement.</em>
</p>

### Optimal nodes

For certain types of furnitures, the node choice is not fully random and follow some rules. This allows to place the furniture in a more realistic way. Thus, to generate other kind of rooms, you would have to add new types of furniture and new sets of rules.

Cuurently there are 2 main rules :
- **Beds** : They are more likely to be placed in nodes close to the walls, and is aligned with the wall.
- **Fridges and sofa** : They are more likely to be placed in nodes close to the walls, and oriented with their back against the wall.

### "Spawner" props

Some props place other props around them when they are instantiated. This helps having a coherent placement, while still having a random aspect. The props instancianting other props are the following :

- **TV stands** : They place a random TV on top of them, with a small angle.
- **Tables** : They place a random amount of chairs around them, and make them face the table.
- **Desk** : They place a random armchair in front of them.

### Add a prop

To create a new prop prefab, the game object needs some mandatory components :
- **A mesh** : The visual representation of the prop.
- **Accurate colliders** : The colliders must be as close as possible to the mesh, to avoid overlapping with other props. They need to have ```SimObjPhysics``` as tag.
- **A box collider** : It will be used to check which nodes are containing the prop, it doesn't need to be accurate. However, it needs to be on the ```Ignore Raycast``` layer and to have the ```BoundingBox``` tag.
- **```props.cs``` script** : You need to attach this script to the prop, link the prop's perfab and the bounding box collider. You also need to set the prop's type from a list.
- **```PropsSpawner.cs``` script (optional)** : If the prop is a spawner, you need to attach this script to the prop. Then, link the list of prefabs to spawn,as well as the list of spawn points, and indicate the type of the prop.
4 changes: 2 additions & 2 deletions src/Doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Then, you can build the project by going to `File > Build Settings` and selectin

Windows is the only build target that has been tested, but building for other platforms should work as well using the correct [Unity plugins](https://docs.unity3d.com/560/Documentation/Manual/PluginsForDesktop.html).

> [!NOTE]
> The .exe will not work if not associated with the other files created by Unity.

> :warning: The .exe will not work if not associated with the other files created by Unity.
Binary file added src/Img/ISGT.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f8101b8

Please sign in to comment.