Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


A tile system... for a sphere?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 Jossos   Members   -  Reputation: 216

Like
0Likes
Like

Posted 10 May 2013 - 06:04 AM

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.


Edited by Jossos, 10 May 2013 - 06:05 AM.


Sponsor:

#2 Olof Hedman   Crossbones+   -  Reputation: 2907

Like
1Likes
Like

Posted 10 May 2013 - 06:54 AM

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/



#3 AllEightUp   Moderators   -  Reputation: 4239

Like
2Likes
Like

Posted 10 May 2013 - 08:28 AM

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.



#4 LorenzoGatti   Crossbones+   -  Reputation: 2736

Like
0Likes
Like

Posted 10 May 2013 - 09:54 AM

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. 


Produci, consuma, crepa

#5 C0lumbo   Crossbones+   -  Reputation: 2386

Like
6Likes
Like

Posted 11 May 2013 - 12:30 AM

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.



#6 Dir3kt   Members   -  Reputation: 166

Like
1Likes
Like

Posted 13 May 2013 - 03:09 AM

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/



#7 Jossos   Members   -  Reputation: 216

Like
0Likes
Like

Posted 14 June 2013 - 03:21 AM

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.



#8 Zennoya   Members   -  Reputation: 178

Like
0Likes
Like

Posted 14 June 2013 - 05:58 AM

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).


Edited by Zennoya, 14 June 2013 - 05:59 AM.


#9 Sik_the_hedgehog   Crossbones+   -  Reputation: 1813

Like
0Likes
Like

Posted 16 June 2013 - 08:11 AM

 

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.

#10 Olof Hedman   Crossbones+   -  Reputation: 2907

Like
0Likes
Like

Posted 17 June 2013 - 02:58 AM

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



#11 Camilo   Members   -  Reputation: 189

Like
0Likes
Like

Posted 30 June 2013 - 01:49 AM

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.

 

I second the buckyball idea. Actually, you could use triangle tiles to draw it (just squishing the tiles that make up a pentagon a tiny bit), but for game logic purposes use the center of the pentagons/hexagons as tiles. Or alternatively, if you want all your faces to be the same size and shape (but irregular triangles) draw a pentakis dodecahedron and use the vertices as game positions. Either way, each of the 32 "game tiles" still has 5 or 6 neighbors.



#12 Legendre   Members   -  Reputation: 966

Like
0Likes
Like

Posted 30 June 2013 - 04:19 AM

Look at the sphere on the extreme right in this: http://sol.gfxile.net/sphere/

 

Take two triangles, they form a distorted square (where triangle join at the diagonal of the square).

 

Perhaps you can distort your square tiles in the same way and use them to tile the sphere?



#13 WorldPlanter   Members   -  Reputation: 266

Like
0Likes
Like

Posted 02 July 2013 - 11:07 AM

If you don't care about non-uniform tile sizes/morphology you can always try a quad sphere.

 

http://www.youtube.com/watch?v=N-X1eevWU9s






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS