Hex grid border highlighting

stuff about computer science and programming
Post Reply
User avatar
Site Admin
Posts: 114
Joined: Wed Oct 10, 2018 3:48 am

Hex grid border highlighting

Post by dendiz » Thu Oct 11, 2018 12:52 am

Previously I've been doing this by actually highlighting all the possible cells, but it looks a lot better if you just highlight the borders. Here are the results I've got after this implementation
35.png (195.65 KiB) Viewed 81 times
Calculating the border cells is a different task which I've explained over here. After we have the cells that we can navigate to we need to filter out the border cells. If you look carefully the edges that need highlighting from all the cells in range are the ones that do not have a navigable neighbor. In the image, the cell (4,-6,2) and (5,-6,1) are both in range, but they share a border with a navigable cell, so that edge should not be highlighted. The algorithm should be like this:
  1. Get all the cells in range and the starting cell, and add the starting cell to the cells in range.
  2. for all the cells loop
    • for all the neighboring cells of the current cell loop
      • if the cells current neighbor = null or cells in range doesn't have the neighbor highlight that edge

The actual highlighting is done by placing a quad with a bar texture with the correct rotation and coordinates easily calculated from the current cell we are processing.

Here is a video of the highlighting: https://www.youtube.com/watch?v=UkWKeim-n_Y

Post Reply