# Map building grid to planet

I'm trying to build a space game and one of the key parts is building on spherical planet. I want the buildings to be build on a grid (some building are 1x1, some 6x4,..., kinda like StarCraft). My problem is, I can't seem to find a way to build the buildings near poles, while maintaining properly oriented grid.

I think that joining cells near poles is a bad idea, because there will be parts, where 1 cell is continued by 2 cells and it will be impossible to build over these parts.

Any ideas how to solve this? Should I forget about the grid and just check, if the building collides with other buildings?

• Maybe the mathematics behind constructing a geodesic sphere could come in handy here - although you will end up with triangular tiles, not round ones. Commented May 14, 2015 at 9:38
• Are you completely sold on the idea to have orthogonal tiles? You could instead allow players to place their buildings freely at floating-point coordinates and rotate them freely by 360° (use quaternions to describe the rotation so you don't get any problematic behavior around the poles). You just check for intersection of the footprints and let the player worry about how to build a rectangular base on a round planet when they really want to be OCD about it. Commented May 14, 2015 at 9:43
• @Philipp I know. On the other hand, I'm planning for the building space to be very small and tiles would (imho) make effective placement much easier (you can see that you have exactly 2 tile space between buildings, so you know that some other building will fit between (without the tiles, you could put the 2 buildings 1.99 tile away from each other and you wouldn't be able to put the third building between)). Commented May 14, 2015 at 15:15

## 3 Answers

I can suggest to use a quad sphere

Introduce polar caps where there is no square grid and player can't build. Buildable areas will be ring-shaped alike in Civilization.

Topological representation:

The quad sphere is good, but I'd like to throw another suggestion in the ring. Let's say you want a hex grid on a planet. Hex grids are all sorts of useful for strategy games. How do you do that?

In the same way that a cube, subdivided, then projected to a sphere gives you a square grid on the surface of the sphere, you can take an icosahedron, subdivide it, and project it to the surface of a sphere. There'll be some pentagons in the mix, but otherwise it has all the properties of a hex grid.

It's called a Geodesic Grid and it's used a lot in climate science. It's annoyingly more complicated, but hex grids are cool :)

There's some good resources at the BUGS site.