Skip to main content
GameDev.net gamedev.net
🔒 Locked

Spherical Worlds

Started by Vendayan Jun 16, 2002 at 2:25 AM 12 replies 550+ views
Original Post
Vendayan
Vendayan
Can anyone explain to me, how it just might be possible to implement a spherical world into a game? I have considered breaking my world into a 2D grid so to speak of the ''levels'' in my world with north always towards the top of the grid, although this is obviously unrealistic because it would take the same time to circle the poles as it would to cirlce the equator. I also considered using some complex type of object like one made from a modeling app for my 3D map of the sphere. with each triangle being a ''level''. Although this doesn''t seem to work well since I want to be able to show true north on a compass which would move unevenly depending on whether the character is in the middle of the ''level'' or closer to the sides. I''m sorry, I know many of you would like to see graphical representations of my problem but please help me if you can understand my problem as its written. ~Vendayan
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
tsuraan
tsuraan
If your world is big enough, you can essentially treat it as a flat world. Represent an object in the world in terms of its polar coordinates (theta, phi, and r), but when moving it would probably be easiest to transform into cartesian coordinates. You could do something like this:

let the world be a spherical heightmap, represented as r(theta, phi). If you look around, you can find some algorithms for generating perlin noise on a sphere, which would make some nice heightmaps.

Let an object have some speed (a scalar), and a general direction (maybe a destination). Then, for each update of the game state, you can transform the object coordinates and destination coordinates into cartesian coordinates, and make a normalized vector from position to destination, as you would on a 2D map. After moving in that direction, convert back to polar coordinates and recalculate the height according to the heightmap, so you don''t fall through the world. Assuming your world is large enough, and the destination point is close enough, this would work decently although it''s not at all optimized.

I''m not sure if I answered your questions at all, but I did have fun writing this . I''m not feeling very coherent today.
Inmate2993
Inmate2993
Its a bit a matter of convention. You could take a simple 2d map, bend it into a sphere, and then pick out appropriate loactions for poles and continents. As long as you don''t make the false assumption that the lowest point on the 2d map is antartica and the highest point is siberia, seeing as how you''d bend them up together, you can safely design a world thats 3d, but representable on a 2d map. Coding it however, I have no immediate ideas.

-> Will Bubel
-> Machine wash cold, tumble dry.
william bubel
Vendayan
Vendayan
tsuraan, that was all pretty helpful but at the same time not, for the purposes of memory consumption I want to be able to break tis world into zones, I havent put too much thought into it but I want to have the levels about 3 times bigger than the viewing frustrum so I might have a seperate thread loading nessesary textures and models into memory. Each level should have a list of references to files that need to be loaded before the player gets into that level. I was thinking also that for this reason hexes might be best so that I will have to do as little of this as possible, since there will only be 6 adjacent ''levels'' as opposed to 8 if I were using squares. But I need to figure how how to calculate true north irregardless.

~Vendayan
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
gimp
gimp
Check iotd.flipcode.com a few weeks back someone release code on how to do it. Basically start with a isosehedron(spel?) and tesselate...

Mapping a bitmap to the target is possible but slightly sloppy as the images gets stretched a little. Still, you wouldn''t notice it standing on the ground of the world.

Chris Brodie
http:\\fourth.flipcode.com
Chris Brodie
Vendayan
Vendayan
couldn't find it. No such place that I can tell called iotd.flipcode.com


[edited by - Vendayan on June 18, 2002 2:19:06 AM]
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
Dwarf with Axe
Dwarf with Axe
If you want zones, why not constructing a large world out of linked lists?

You could have the zones situated like a matrix:

{z1, z2, z3, z4, z5}
{z6,z7,z8,z9,z10,z11}
{z12,z13,z14,z15,z16}

and have it so that going south of z2 would get you to the north of z7... east of z10 gets you west of z11.

~Dwarf
Vendayan
Vendayan
Nevermind
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
Graham
Graham
I think that this is an extremely difficult question to answer. The only person that could possibly figure out a solution would be John Carmack. Maybe you should send him an email.

Go on an Intense Rampage
Go on an Intense Rampage
guppy
guppy
quote:
Original post by Vendayan
[...]
I''m sorry, I know many of you would like to see graphical representations of my problem but please help me if you can understand my problem as its written.

~Vendayan


Hrmm... don''t know if I''ve understood this correct do you want to display a height map on a sphere? (I''ve done this and can be of some asistance) or du you simply want to organize a lot of maps so that they will fit together on a sphere?

In the latter case I guess you would want square maps (as opposed to triangle shaped maps) - just tesselate a cube until you got a sphere - I know there would be as manney maps near the ''poles'' as there are arround ''equator''. However this problem could easily be menede by simply defining the maps to get smaller the farther you get from ''equator''...

hope it helps & happy coding

/Please excuse my bad spelling - My native language is binary not english
|Visit me
\Take my advice - I don''''t use it...
/Please excuse my bad spelling - My native language is binary not english|Visit meTake my advice - I don''t use it...
Vendayan
Vendayan
NO this sphere will NEVER be drawn. Or at least if I were to draw it I dont think I''d have any problems with that.

I need to make a ''map'' of my world. This is only for my engine to know where and when the player is coming close to another level in the game. Which on my ''map'' will be another side of the sphere.


How do I make it so that this will work and what do I need to do in order to make my ''compass'' on the GUI always point towards the north.

More or less I simply need a mesh to represent my globe and a function to make the compass always point north. The problem is that my compass won''t turn correctly, or seem to like it should on a true sphere.

~Vendayan
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
Mordoch Bob
Mordoch Bob
Well, if you can assume that a "zone" represents a certain patch on the sphere, what you need is a function that projects the 2D zone onto a patch on the outside of the sphere, and thus allows you to convert a point within that zone into a point on the sphere. It''s late, and I doubt I could give you a method off the top of my head (though I''m sure it''s pretty simple), once you have that done, all you need to do is figure out the vector from the point on the sphere the player''s on to the true (or magnetic, I suppose) north of the sphere.

This may or may not have been clear, but it''s been a long day. If I figure out a method that''s workable, I''ll post some pseudocode.

------------------------------------------------
The wind shear alone from a pink golfball can take the head off a 90-pound midget from 300 yards.

-Six String Samurai
_______________The wind shear alone from a pink golfball can take the head off a 90-pound midget from 300 yards.-Six String Samurai
Vendayan
Vendayan
Mordoch I had considered that but thats flawed slightly.

Imagine I use a cube (which I won''t but for this just assume). When the player moves toawrds a corner of the cube his spherical coordinates will move slowly compared to when he is in the middle of a side when he is closest to the virtual sphere that we are projecting his point towards.

This may be as simple as using a very large and complex sphere, but that would make my world HUGE!! Decades of level designing. Then again making the levels themselves smaller should makeup for it.
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
gimp
gimp
Here is that flipcode link. Once you have the sphere I guess nominating a vert as the northern pole will allow you to do some vector math between that point on your current position for a compass type effect.

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=05-30-2002&forum=iotd&id=-1

Chris Brodie
http:\\fourth.flipcode.com
Chris Brodie

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.