Hi, I’d like to place roads on a grid with square grid positions. A few points:
-
All roads will be straight and not diagonal across cells
-
Roads will either be dot (no connected road), single, straight, corner, tee or cross
-
Grid cells are made up of 2x triangles. A road can be placed on the cell if it is flat or within a specific incline in one direction (north, south, east or west)
I’m unsure on the following points:
- When a road is placed on a cell, that cell as well as the north, south east and west cells are updated. When a cell is updated it runs through a switch with 16x cases to define the road type and orientation. Is there a less intensive way of doing this?
- The easiest way to generate the road mesh would be to generate a separate mesh for each cell with a road on it. This also seems a bit intensive? Would the mesh draw calls be batched?
- I was thinking another way to do it would be to create a mesh for each type of road, all cells with that type of road would go onto one mesh (within a certain area depending on grid size). I think this would be okay for straight roads but unsure how to do this for corners and tees. If there’s two corners or tees connecting and sharing vertices, how would i handle the uvs? Would I have to duplicate vertices? Should you ever duplicate vertices (it seems wrong)?
- Is there another way of doing this that I’m missing?
Thanks for any help on this! When I get chance, I’m going to go with the separate meshes per cell to begin with because it will be the easiest! But just wanted to get some more opinions on it as well.