Game Development Community

dev|Pro Game Development Curriculum

DayOfWar SixSidedSpheres 2nd try

by Bill Vee · 04/06/2008 (9:21 pm) · 17 comments

OK I got bored and a little mad so I decided to try the post again.

My approach is similar to the way Spore appears to do planets.

You take six heightfields and create a cube with them.

This is a unfolded cube. Each square is a heightfield.
dayofwar.com/Images/TGE_images/cube2Template.gif
Where 1 is the north pole and 6 is the south pole.
And 2 3 4 and 5 are regoins around the equator.
As should be apparent you have to wrap the terrains in a very special way or you will have visible seams.
Square 1's left side needs to wrap with square 2's top and 1's right side needs to wrap with 5's top and so on.

Now doing something like taking each heightfield and applying a spherical distortion will give you a bulged square that will give you a sphere with large gaps.
dayofwar.net/Images/TGE_images/Bad_sphere0.png
What is needed is to take the heightfield and project them from a center point.

The next set of images show how this specially projected atlas terrain is not square.

dayofwar.net/Images/TGE_images/projection0.pngdayofwar.net/Images/TGE_images/projection2.pngdayofwar.net/Images/TGE_images/projection3.png
This is a picture of the planet with all six atlas terrains configured like a cube.
dayofwar.net/Images/TGE_images/CubeSphere0.png
This shows the same planet with the top terrain moved up a little to show how they fit together.
dayofwar.net/Images/TGE_images/CubeSphere1.png
After 7 complete rewrites of my planet code here is what I have.
I have 3 different ways to achieve the spherical cubes from above.

The first is a custom importer that is used to create a atlas file with the correct projection.
This one is 100% done and has the benefit of creating atlas files that can be loaded by any version of TGEA with no code modification

The second is a runtime converter that takes a standard atlas file and applies the projection at load time.
This one is 95% done. I am still having some issues with re projecting the bounds for each chunk due to the way the atlas file stores them in the file.

And the best for last.
A atlas derived class that takes all six heightfields and creates a single Spherical Cube based CLOD terrain system. It has all the advantages of clipmapping, paged terrain, blended terrain and is able to load/create lightmaps in game.
This one is about 65% done.

#1
04/06/2008 (9:43 pm)
Wow, that's some impressive work you've done there. Spherical terrains seem to be the holy grail to many developers around here. I can't wait to see the interesting games that come from this.
#2
04/06/2008 (10:13 pm)
Very cool stuff Bill.
#3
04/06/2008 (10:42 pm)
Quite cool. do you have gravity behaving appropriately?
#4
04/06/2008 (10:54 pm)
Very cool.
#5
04/07/2008 (12:10 am)
Impressive work! And this may be useful for the physical behaviour:
http://www.garagegames.com/blogs/19442/14512
#6
04/07/2008 (12:57 am)
I won't need it (yet) but... WOW, looks great :)
#7
04/07/2008 (3:37 am)
@Ramen-sama
Gravity was solved by a special type of trigger some time ago.
#8
04/07/2008 (9:47 am)
Bill, it's always an interesting read to see how Day of War is using tech in new ways. Thanks for sharing!
#9
04/07/2008 (6:00 pm)
That really rocks Bill!

I would love to play with version 3 when it is done.
#10
04/07/2008 (11:23 pm)
How about water?
Is it possible to do the same with the water planes so there can be water on the planet?

Very cool stuff, by the way.
#11
04/08/2008 (6:49 am)
@Sorin Daraban
You can project the geometry for the waterblock the same way I did for the terrain.
dayofwar.net/images/Round_waterblock0.pngWhile the shape is a hemisphere the relection appears to be planer.
A change to the shader should fix that.
#12
04/08/2008 (2:56 pm)
Wow...

Very nice.
Thanks for the quick info.
#13
04/11/2008 (10:36 pm)
awesome stuff dude.
#14
04/15/2008 (4:49 pm)
Spherical Cube Test:

The camera position started in the middle so I thought the example wasn't working then I zoomed way out and found the planet. Nice Job....



img249.imageshack.us/img249/2212/dayofwargd1.jpg
#15
04/30/2008 (4:23 pm)
You would be able to make tunnels/dungeons the same way, wouldn't you? That would really increase the incentive for me to buy TGEA.
#16
08/06/2008 (12:20 pm)
The download link is broken.
#17
08/06/2008 (12:53 pm)
Link updated.

@ Nathan - The actual geometry for a atlas file is irrelevant. You could take almost any 3d object and convert it to an atlas file. The tricky part is the clipmap.

Of course you would need a custom import function like I created for these maps.

I have a half working obj to atlas conversion function but it needs more work before I offer it up as a resource.