Advertisement

A tile system... for a sphere?

Started by May 10, 2013 12:04 PM
11 comments, last by WorldPlanter 11 years, 5 months ago

So I'm trying to work out how I would go about doing a tile system wrapped around the shape of a 3d sphere (like a planet). I can do this in the shape of a Torus quite easily, but it's a sphere I'm after. I'm not even sure where to begin to be honest.Computer generated spheres (like in maya or 3ds max) seem to use triangles for the poles and the squares squash and stretch to fill the shape, which is just no good for a tiling system for a game.

Any help is appreciated.

I think the easiest would be to have triangular tiles all over the sphere, and generate a sphere like this: http://sol.gfxile.net/sphere/

Advertisement

Actually, I have always seen the subdivided cube approach as probably being easier for this particular item. You start with 6 faces (2 triangles each of course), when you subdivide you push the new verts out to the sphere boundary repeat. The advantage is ending up with rectangular areas after each subdivision which keeps the texture mapping simple.

Do you really need to tile the whole sphere at the same time? Maybe you can get away with a tangent plane; whenever the "camera" moves you switch to a nearby tangent plane, pretending that the sphere is flat.

Omae Wa Mou Shindeiru

The one you see most often from modelling tools is made by starting with an icosahedron and subdividing each triangle. As I think you're getting at, triangles aren't very good cells for a strategy game.

But, if you take your subdivided icosahedron and truncate it (http://en.wikipedia.org/wiki/Truncated_icosahedron), then you get an awesome shape sometimes known as a buckyball, which is made up of lots and lots (number depends on how subdivided the icosahedron was) of hexagons (which are great for strategy games) and 12 pentagons (which are rather inconvenient). However, if you can live with those pesky pentagons somehow, then this is a great option.

If you want square cells (or just a simple life), then as AllEightUp says, take a cube, subdivide it, then warp it into shape. When you warp your cube into a sphere, the squares become misshaped and inconsistently sized. This approach http://mathproofs.blogspot.co.uk/2005/07/mapping-cube-to-sphere.html is slighty better than the obvious approach of just normalising each vertex.

Beside using some ico sphere, there is another way to do it. It might work or not depending on the kind of game you are implementing.

Have your classic 2D tilemap with squares. Make it wrappable. That's it if you got to the end left you will come back to the right, etc.. Like Asteroid but make the camera move instead of the player. Navigating through such a space already give a 'sphere impression' because if you keep going in a direction at some point you will come back to your initial position. It's not 100% accurate though because if you go in diagonal the path would be longer than if you go in a straight direction.

Then the trick is to use a spherical vertex shader to make the 2D plane looks like a sphere. The idea is to rotate each point in function of their distance from the center of the screen. There is not much about it on the web but it's not difficult to implement if you know a bit of GLSL.

The nice thing is that all the logic is very simple because it's still 2D however it gives to the player the illusion that he is playing on a sphere. Here is a proof of concept (a project that I sadly abandoned) :

http://www.zappedcow.com/sphere/

Advertisement

Have your classic 2D tilemap with squares. Make it wrappable. That's it if you got to the end left you will come back to the right, etc.. Like Asteroid but make the camera move instead of the player. Navigating through such a space already give a 'sphere impression' because if you keep going in a direction at some point you will come back to your initial position. It's not 100% accurate though because if you go in diagonal the path would be longer than if you go in a straight direction.

This more of a torus really. But I like this idea a lot, and might just do that.

And what you think about hexagon sphere? Its possible to be done as easy as triangles (becuase its made of them), and also hexagons are nice fields for strategy game (a lot of games use those already).

Have your classic 2D tilemap with squares. Make it wrappable. That's it if you got to the end left you will come back to the right, etc.. Like Asteroid but make the camera move instead of the player. Navigating through such a space already give a 'sphere impression' because if you keep going in a direction at some point you will come back to your initial position. It's not 100% accurate though because if you go in diagonal the path would be longer than if you go in a straight direction.

This more of a torus really. But I like this idea a lot, and might just do that.

In case you're curious, the perspective would end up looking something similar to this:

Actually those special stages pull off that very same trick (OK, not exactly given the hardware that was on, but I mean it was just a 2D plane with a fake sphere look). I don't think anybody ever bothered to wonder how those special stages would map to an actual sphere.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

And what you think about hexagon sphere? Its possible to be done as easy as triangles (becuase its made of them), and also hexagons are nice fields for strategy game (a lot of games use those already).

It's not possible to make a sphere out of hexagons, without a few pentagons

This topic is closed to new replies.

Advertisement