Space Miner Automatic Planet Generation P3

Hi,

Some progress done today. Basically I have mapped the areas in code with their respective Cells and how every area is connected to areas close to itself.

For example, Area1 has the Cell with the surface on top and is connected to A8 for increasing height and A2 for decreasing height.

If Area1 wants to continue with an Area1 cell (with the surface on top of the cell), then the next tile will be placed with an x = 1, y = 0 increment.

If Area1 wants to continue with an Area2 cell (decreasing height), then the next tile will be placed with an x = 1, y = 0 increment

If Area1 wants to continue with an Area8 cell (increasing height), then the next tile will be placed with an x =1, y = 1 increment.

This mapping has to be done for every Area1, …, Area8.

By following these rules all the way through Area1, we can procedurally generate a surface in that area. By keeping a vector from the planet centre to the latest created tile, we can decide when we change to Area2, Area3, Area4, …, Area8 based on the angle of that vector.

This is the class I am using now to keep track of these mapping, you can think of one CellPlacing as one Area with some added information.

 //Maps the connections between different areas, also keeps the Cell tied to every Area
 private class CellPlacing
 {
 //The Cell to use as a tile
 public Cell cell;

 //The link to the next level CellPlacing (will be a link back to itself)
 public CellPlacing nextLevel = null;
 //The relative x, y for where to place the next tile
 public Vector2 nextLevelPos = null;

 //The link to the next decreasing height CellPlacing
 public CellPlacing nextLower = null;
 //The relative x, y for where to place the next tile
 public Vector2 nextLowerPos = null;

 //The link to the next increasing height CellPlacing
 public CellPlacing nextHigher = null;
 //The relative x, y for where to place the next tile
 public Vector2 nextHigherPos = null;

 //The starting angle for this area
 float startAngle;
 //The ending angle for this area
 float endAngle;

 //Takes the Cell to use as a tile, Area start angle and Area end angle
 public CellPlacing(Cell inCell, float inStartAngle, float inEndAngle)
 {
 cell = inCell;
 startAngle = inStartAngle;
 endAngle = inEndAngle;
 }

 //Creates a connection to the next level CellPlacing (should always be a link back to itself)
 public void SetNextLevel(CellPlacing inNextLevel, Vector2 inNextLevelPos)
 {
 nextLevel = inNextLevel;
 nextLevelPos = inNextLevelPos.cpy();
 }

 //Creates a connection to the CellPlacing with an increasing height Cell
 public void SetNextHigher(CellPlacing inNextHigher, Vector2 inNextHigherPos)
 {
 nextHigher = inNextHigher;
 nextHigherPos = inNextHigherPos.cpy();
 }

 //Creates a connection to the CellPlacing with a decreasing height Cell
 public void SetNextLower(CellPlacing inNextLower, Vector2 inNextLowerPos)
 {
 nextLower = inNextLower;
 nextLowerPos = inNextLowerPos.cpy();
 } 
 }

I did some basic graphics and did the mapping as described. I proceeded to generate the following “planet” by just choosing the next level CellPlacing and switch over to the next CellPlacing when the area changes.
planetProcedurallyGenerated01
There is no logic to figure out when the planet is finished yet, so the last side is kind of missing =)
The next steps will probably be to find out when to end the generation, and then start playing around with some randomly increasing / decreasing surfaces. This is coming to be a fun project =)

Until next time,
Kim

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s