Announcement

Collapse
No announcement yet.

Modelling a sphere

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • trotor
    replied
    Sample code

    is subversion's offer for source code still valid? If it is, please do send it to me (I can't use private messages yet, nor can I post mail addresses), but lets figure something out.

    I would love to see C# code for it.

    I am planning to create weather simulation (not forecaster) and would like to get some sphere handling help.

    Leave a comment:


  • Norselord
    replied
    There is no single regular geometric shape that will perfectly tile a sphere. This is because Pi is an irrational number.

    If you want to approximately tile a sphere then you need to decide on a level of resolution that is acceptable.

    If you want to use squares, and you can accept a cube as being a close representation of a sphere then all you need is six squares. Ofcourse a sphere that is tangent to the corners of that cube (so that it inscribes it) will have a surface area that is 4.7% larger than the cube.

    An icosahedron is a 20 sided figure made up of equilateral triangles, it is the largest regular platonic solid. It is possible to begin tiling an 'approximation' of a sphere based on the icosahedron. Imagine a sphere that inscribes an icosahedron. Imagine a line from the center of the sphere through the center of the face of one of the triangles, the point defined by the intersection of this line and the surface of the sphere can be used to generate three new triangles that use the base of the original triangle as their base and the new point as their opposite vertices. By doing this, a new polyhedron is created with 60 faces.

    repeated iterations yield polyhedra with 180, 540, 1620 faces etc. By the 10th iteration a figure is created with 1,180,980 triangles.

    Now, a little sidetrip: A chessboard looks flat, a basketball court looks flat, a factory floor looks flat. At a certain scale the curvature of the earth is negligible. What is this scale? The engineering scale says that the curvature of the earth over a distance of 50 meters is negligible.

    So, how many triangles are needed to tile the earth?

    About 630,000,000,000 triangles with 40 meter sides will tile the earth. Ofcourse the careful reader will notice that local variations in topography such as canyons, mountains, and rivers will start interfering with a tiling pattern on this scale. Secondarily, expecting a computer game to track several variables for each of those triangles every turn is asking too much.

    What is the best answer? I don't know. But for the sake of simplicity, the torroidoil earth presented in CIV is going to be the best thing available until serious advances in hardware permit the 6.3tera triangle spherical earth model.

    Eithe

    Leave a comment:


  • subversion
    replied
    sent you an email

    Leave a comment:


  • alms66
    replied
    Sounds good, you can just email it to me if that's ok. Thanks, subversion.

    Leave a comment:


  • subversion
    replied
    hi everyone...

    i'm a former Clash team member from many years ago, did some experimental Map AI coding for the path intensity stuff (my user name was JimC)

    anyway, this idea (geodesic/hexagonal grid over sphere) intrigued me so much that i knocked something together quickly to try it out, and it looks promising... got the 10242 vertex version running at a good FPS

    i have an existing code library with tile/graph based map system which works with an A* searcher etc... i'm now quite curious to see how easy it is to tie this spherical map into my existing framework

    bad news is its in c#/XNA (i'm a total convert these days)

    anyway, let me know if you want source code etc, i'll be happy to share if you can handle c#... for the non-graphical stuff its a pretty easy conversion between c# and java

    Leave a comment:


  • alms66
    replied
    I'd rather not take the impassible terrain route, it makes the tile seem like a waste of space. I didn't care for that in civ4 either.
    I certainly hope to have very large maps, but there's only one way to find out how big we can make them.

    Leave a comment:


  • LDiCesare
    replied
    Yes, the vertices in the middle of the stripes in Figure 6 are pentagons, but they drew them as hexagons in Fig. b in order to make it harder to spot. Still, knowing that 2 hexes are always in the poles is nice. The other ones are still a liability in terms of movement though. One could always trick a map generator into putting impassable terrain there, but it's going to create weird artfacts unless the map is very big.

    Leave a comment:


  • alms66
    replied
    Actually, they get very hard to see as they get smaller in those images, but according to the text, you've got the standard 12 pentagons in all of the ones shown. I think I can barely make out the pentagon near the western tip of Africa, but out in the Atlantic ocean.

    Leave a comment:


  • LDiCesare
    replied
    The 'and here' representation is nice in that it just gets pentagons on the poles.

    Leave a comment:


  • alms66
    replied
    I know I'd love to have spherical maps for Clash. The one thing I don't think I'd want to lose is it's tile-based nature though.

    Here's someone who's actually done something with a geodesic grid in a game prototype here

    ...and these are my old standby's of what I'd like to see for a spherical map:
    and here
    and also here

    Figure 1 in the "and here" link is about right for a tiny Clash map, don't you think? I'm sure contacting some of these people in these links would provide some help in getting this off the ground. So, are you volunteering to implement this or what?

    Leave a comment:


  • TimeHorse
    replied
    Actually, a Hexagon can also be converted to a trapezoid and then nudged into the shape of a square by bisecting each hexagon from vertex to opposing vertex either horizontally, vertically or diagonally for a Cartesian or Isometric grid layout.

    The problem, as I see it, is when you reach the 12 pentagons. The pentagon can be made into 2 quadrilateral by bisecting it with one point traveling through a vertex and the other through the mid-point of the opposing edge. Unfortunately, this means that along that now bifurcated opposing edge, you have a single hexagon which means 2 cells border the same cell on an edge, not a corner, which is weird. There are various solutions. One would be to split the pentagon into 3 triangle rather than 2 quadrilaterals. Another would be to insert a false edge that wedges the 2 quadrilaterals such that the opposing hexagon shared by 2 cells is connected by a corner vertex of each of the 2 quadrilaterals and yet you can pass directly between each of the 2 quadrilaterals by 'jumping' over the wedge.

    Weird, I know, but it is a thought. Freeciv is working on a hex mode but it's not yet working in the latest beta AFAICT. But those 12 pentagons are a real pain and the secret to turning a flat grid into a spherical approximation.

    Anyone want to work with me on this?

    Leave a comment:


  • TimeHorse
    replied
    And then nothing in the last 2 1/2 years? >sigh< Well, folks, let's get cracking. I have been desperate to have a globe-like version of a game like Civilization since I was a wee shaver and Comp Sci under-grad when, like, the first, very first version of Sid Meyer's Civizilization came out as in the first first first the original you might say! Yes, I've been waiting almost 2 decades for this so here I am to say YES!

    The buckmister-fuller approach of expanding on the icosahedron and then forming its dual is ideal. Someone suggested splitting the hexagons into triangle and I think we're better off with hexagons and the occasional pentagon. This is because when the grid is tessellated with hexagons, each edge has a hexagon but each vertex has nothing more than the previously counted hexagons. With triangles, you have 3 neighbours to be sure but when you consider things like vertex coverage, you add another 3 triangle each for a total of 9 vertex-adjacent cells. Remember in freeciv, for example, you the ability to travel diagonally and it seems unreasonable to restrict motion to just 3 directions or complicate it by 12. Thus, Hexagons are ideal and do indeed tessellate well!

    Now, it's easy to render a screen full of hexagons and for those game artists, you can pick up hex paper in any old hobby shop where ex-DnD'r might dwell, or visit a site like http://incompetech.com/graphpaper/ and print some yourself.

    It worries me, though, how you represent the pentagonal nodes on such a graph. Once could, for instance, construct the pentagon geometrically but build "snub" hexagons around it and just build the grid around it.

    Listen, Populus III at least could put play on a sphere, there's no reason than we, in 2010, can't have a sphere for the little map and project a 2-D hex-grid for the play area!

    Now, unfortunately, graphing the geodesic dome onto paper isn't as trivial as downloading a PDF. Take, for instance, the special case of the Dodecahedron; it would look something like this: http://en.wikipedia.org/wiki/File:Do...projection.png
    where the outer 5 pentagons form the 5 edges of the opposing pentagon to the one in the centre. Of course, we wouldn't use that exact projection and would probably just arbitrarily choose one of the 5 outer pentagons to be adjacent to the missing one so you could see all of them on screen at the same time (one assumes ones screen is capable of showing at least 12 squares at a time). Focusing on regular repeat patterns however may be over-complicated. Instead, we can take the dual of our geodesic dome and project the centres of each of the resulting polygons onto a flat surface using a polar projection. In other words, each of those points in the projection are the vertices between polygons of our original model and thus form the scaffolding from which we build our grid.

    As for how each cell is rendered, a layered approach like mentioned in the Wiki seems reasonable. With the stretched grid resulting from a polar projection where there is foreshortening and compression at the periphery mean a lot of computation would be needed to render each cell but hopefully machines are fast enough now since I'm no longer using that 386 or 486! But visually I think it's just the approach we need, where the centre of the screen is the least distorted and it gets more distorted as you move away. Of course, with more cells you have a smaller portion of the globe projected so it look more regular as you add more hexagons. It's the equivalent of zooming in; as a result of this work, it may be easy to add a zoom feature to the 2-D display as well!

    So that's how I see it working on the front-end. As for game play, I think using the letter keys should be avoided since these are already reserved for action keywords. Rather, I think we should stick with arrows + Page Up and Page Down. This projects nicely onto the number pad (well, not perfectly but home and end seem better served elsewhere). So Up/6 is up-left; Left/4 is left; Down/2 is down-left, PgDn/3 is down-right, Right/6 is right and PgUp/9 is up-right. Alternatively, you could have 789 for up-left, up, up-right and 456 for down-left, down, down-right or even Insert/Home/Page Up and Delete/End/Page Down for your controls. I think in the end, we just need to allow the user to choose controls but choose logical defaults. It'd be nice to use the arrow keys and Page Up and Page Down are unlikely to be used for anything else so I suggest we use the permutation I spelled out initially.

    Now, the nice thing about the game concept is that we could easily represent each cell as an object and have each object hold it's intrinsic properties: links to adjacent cells, terrain type, special type if any, road, rail, river, irrigation, farming, etc. as we as links to a resident city, if any, and a vector/array of links to each of the objects located on that square. There would still be a list of cities and a list of units and all kinds of other lists stored in memory and some grid manager to keep the whole thing contained since such a graph is both highly cyclic and without root. If we consider the path to each adjacent cell as the distance given by its terrain type and improvements as weight in its traversal, we can use the well-known Dijkstra Algorithm (http://en.wikipedia.org/wiki/Dijkstra's_algorithm) to compute shortest paths for goto and connect commands. This is the part that I understand best. It's a pretty neat algorithm and with that, and the unit rules et al. should pretty much stay the same except for the limits on movement as stated above. Sounds simple, eh? Well, a good algorithm for polar projection would be of use, but I'm sure we can find that. As for Dijkstra, we do need to take into account that it runs in |E| + |V| ln |V| time which since |E| is proportional to |V| so this reduces to |V| ln |V| which is not that bad for large sets -- about as quick as sorting the nodes -- but will get worse with a larger grid.

    All in all, I think we have a winner here! Let's try and make this happen! I'll lend as much help as I can, especially to the back end and I think 2010 will be the year of the Sphervilition!

    Disclaimer: My father probably oversees the funding of the CMMAP (http://www.cmmap.org/index.html) which is where kiwi.atmos.colostate.edu now redirects.
    Disclaimer: I used to live in Montréal so have a thing for Geodesic Domes thanks to ça: http://en.wikipedia.org/wiki/File:Mt...Sept._2004.jpg

    Leave a comment:


  • alms66
    replied
    See the following site(s), there are some interesting concepts that can be applied to modelling a sphere in Civ:

    http://kiwi.atmos.colostate.edu/

    In particular (for images)

    http://kiwi.atmos.colostate.edu:16080/BUGS/geodesic/

    Leave a comment:


  • mrmielke
    replied
    anyone here who is still interested in this please have a look at http://www.freeciv.org/index.php/Sph...erent_Approach and tell me what you think. especially the programmers. I really need a programmer to think through it and tell me whether it is possible.

    Leave a comment:


  • demipomme
    replied
    mrmielke and TimeTraveler:

    Good work! Although I'm now a CSS convert, both your methods are a step in the right direction. It's amazing that despite numerous iterations of the civilisation formula, none of the companies have managed to conquer this problem. Hopefully the independent/open source community can get there first!

    Leave a comment:

Working...
X