LibGDX Celestial/Planetary bodies TileMap

Dear JGO-Community,

Currently I am doing some research about Planetary body Tilesystem.
But what is it what I am trying to figure out?
Well take for example these to pictures:

Picture 1: Celestial/Planetary bodies

Picture 2: Terraria Tilemap

The idea is to get the TileMap as Terraria i[/i] into a celestial/planetary body i[/i].
But I’ve no idea how to accomplish this type of Tile System/Management.
I think it’s just as simple as wrapping a TileMap around the body, but I’ve also no idea on how to accomplish that.

As far as I’ve researched, I cannot find any information about this subject. Maybe because I cannot find any information is because I don’t know how to describe the thing I want to find. So if any of you know anything about this subject, just post the link etc.

I really need the help of you guys, so if you know anything about this subject, or know some information (e.g. wikipedia article/github etc.) just post it.

If you have any question, feel free to ask them.

Thanks for reading and/or helping
-RoseSlayer

I think I understand you correctly.

It may be easiest to try this with a shader first, then use the same process else where if you need to.

Essentially what you want to do is map polar coordinates (angle, radius), of the planets, to rectangular coordinates (x, y), of the image. Let’s break that down:

Angle->X: We want the width of the image to run around the perimeter of the circle. So we treat both the perimeter and width of the image as going from 0.0, to 1.0, for convenience.

To get the angle, we simply take atan(diff.y, diff.x), which will be called atan2 in Java, which returns the angle in radians of the positive X axis, to the diff vector. This angle will be between -3.14 radians and +3.14 radians. We add 3.14 radians to make sure the result is positive, and divide it by 6.14 radians to normalize it. We use this normalized value as the X coordinate as we’ve also normalized our image width to between 0.0 and 1.0;

Radius->Y: The Y coordinate will be determined by the radius from the center of your planet as the full radius maps to the full height of the image. This is as simple as using the radius as the height, we pass that directly in. It’s a linear 1:1 relationship.

I quickly wrote up an example here for viewing: https://www.shadertoy.com/view/4tSGzd, let us know if that’s what you are, or are not after. :slight_smile:

Yes that is exactly what I meant. Is it also possible to have variation in Height, or even better using a dynamic Tilemap like in Terraria?

Sure, you don’t even need to think about the circularity. Your logical representation of the map remains a tile map grid. If you want a hill, just add more tiles upwards in your image.

However, my guess is that the game of the image you just showed works differently than what the approach I suggested will work for. The approach I suggest is best used when the terrain is a fixed radius from the centre, but you could visually get away with a few small deviations in that radius. With the approach I provided, tiles will grow bigger as you go outwards from the planet, and get really small as you go inwards, meaning you also have to scale the character with it.

If you want a fixed scale regardless of the distance you are from the center of the planet, you’ll need another approach. One approach would be to represent the shape of your planet as a polygon, with inner textures scaling towards each edge, and a different texture along the edge. I can’t really help you here as I don’t know how to do that in practice. Hopefully someone else can help. I think I’ll be trying it out myself as a learning exercise some time though.

I get it, was thinking about changing the texture aswell to get a hill etc. Thank you very much for your help.

The game in the last image is probably, as you said, another approach, but your approach is better for the thing I want to accomplish, so thank you very much.
Now I need to tackle another problem, the hitboxes etc.

I don’t need a fixed scale regardless of the distance you are from the center of the planet, well not for the tilemap, only for the entities (but that’s not any problem).

Thank you very much, for your fast responding and your help!
-RoseSlayer