Most of this week’s work on my space 4X game has been in putting together a good system for placing items like 3D models of buildings on a planet’s surface. Part of the difficulty is in the fact that the planet graphics are generated entirely on the GPU, so the CPU doesn’t have access to that data. I came up with a fantastic system that works around that issue and gives access to not only height data but also details like what type of terrain is on a particular spot or whether it’s in an ocean.
So now I can place buildings on the surface of a planet, zoom out, rotate the planet and the building appears to stay put on the surface. When placing certain buildings like a water extractor, I can make it only placeable on water or make it fulfil any other criteria I want. I could make mining drills that you move around to find the best spot, or geothermal power stations that can only be placed on fault lines. There’s a lot of versatility in the system, so it’s been fun to work with this week.
Right now you can go into the various planets in the generated galaxy and place buildings anywhere on the surface at all. The plan is to define specific colony sites that you can build a base colony building on, and then buildings must be placed on a grid surrounding that building. It’s a gameplay restriction that has to be done for balance reasons, and to make the city blueprint system work. Certain buildings will require extractors, like fossil fuel power plants will require a coal mine and factories will require a mineral mine. You’ll send scout ships out on survey missions to find resources and then place the extractors on them to make the building start up.
Graphics:
The main colony area is is where important buildings like factories and research labs are all placed, and extractors are placed far afield where resources are located. Graphically, I need a way to show the population increase in a colony. As the colony’s population grows, you’ll start to see a sprawling network of roads and houses emerging from the main colony area. By the time a colony is at its population limit, the area around it (example: most of the screenshot above) will look very developed.
I’ve been experimenting with different light angles for the planets, and although right now I have maintained authentic lighting angles based on the angle of the planet and its point in its stellar orbit, it often doesn’t look very good. A colony area might sometimes be in darkness, or glaring sunlight that makes the terrain look flat. Ultimately, graphics take priority over realism in a game like this, so I’ll likely lock the lighting to an angle that makes whatever’s in the center of the screen visually pleasing at all zoom levels. I’ll post some screenshots of this when it’s done.