Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Looking for a geosphere algorithm

Author
Message
El Goorf
18
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Uni: Manchester, Home: Dunstable
Posted: 24th Sep 2007 02:49
I want to program a geosphere generating function for the first part of my project. Whilest im perfectly familiar with memblock meshes and have used them for all sorts of shapes, i can't figure out how geospheres actually work, ie what formation the triangles are meant to be in. If anyone could care to explain or knows of a tutorial, it'd be handy.

whenever i try google i just get some dictionary defition of something to do with the earths crust >.<

http://notmybase.com
All my base are not belong to anyone.
Mr Tank
22
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 24th Sep 2007 04:20 Edited at: 24th Sep 2007 04:29
They're based on icosohedrons. Google image search if you don't know what one looks like. It's a fun exercise to figure out what the coordinates are. Seem to remember the coords come out with multiples of phi, which is cool. Also they have the same symmetry of a football- each vertex would be in the middle of one of the pentagons.
If you then subdivide each face - into 4 or 9 or 16 etc triangles, and make all the new vertices a set distance from the centre, it gets rounder. This way you get 20, 20*4=80, 20*9=180 etc poly spheres.
You can also make a 60 triangle shape using the vertices of the original, and vertices in the centre of the original faces. Subdividing this means you can make a 60*4=240 poly sphere, etc.

I coded a geosphere to make low poly explosions years back before i realised you could do this stuff much easier in Milkshape or whatever (used make object triangle commands to make all my models too... )
Can't you just export a geosphere from a modelling prog?

Edit:
This should be useful. Has the coordinates.
http://en.wikipedia.org/wiki/Icosahedron

SUPER BADASS SPACESHIP X: WEBSITE
FORUM TOPIC
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 24th Sep 2007 09:28
Cool.

A lot better than the DBPro spheres, as they have a north and south pole, and unequal surfaces.

I have attached an image of the geometry of a polar sphere and geosphere.

"I don't like it, and I'm sorry I ever had anything to do with it" - Erwin Schrodinger
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Sep 2007 11:07
You can also start with a standard shape such as a cube or an octohedron make from tri's, and then repeatedly subdivide the tri's until you have the level of detail you want, then push the vertices out to the size of sphere you need.

I have old-ish code that does this if you want it (attached). The only problem it has is that I could never quite get the texture coordinates right at the poles.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th Sep 2007 13:04
I found it quite hard to notice any pattern, and found this slightly exgagerated image:


Just thought it might be of use

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 24th Sep 2007 14:42
I don't think that the triangles are actually perfectly equilatril.

-= Out here in the fields, I fight for my meals =-
pcRaider
18
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 24th Sep 2007 15:23 Edited at: 24th Sep 2007 15:45
It may be this.
"Geodesic dome"

This has many users, Many documents are shown.
http://en.wikipedia.org/wiki/Geodesic_dome

I like "thought of Mr. Buckminster Fuller".
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 24th Sep 2007 17:45
The buckminster fullerine has 60 vertices, arranged as the dual of the convex hull of a dodecahedron and icosahedron combined.

Or putting it more simply, it is a football where each of the edges are extruded into squares. I have included a picture of its dual.

"I don't like it, and I'm sorry I ever had anything to do with it" - Erwin Schrodinger
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 24th Sep 2007 17:54
Additionally, I have made 5 different geospheres, each one being the 3rd subdivision of each of the platonic solids. Here they are, attached as 5 .x files in a .zip file.

Geosphere 1 - Icosahedron (Most complex)
Geosphere 2 - Dodecahedron (similar size to icosahedron)
Geosphere 3 - Cube (similar size to octahedron)
Geosphere 4 - Octahedron (my personal favourite)
Geosphere 5 - Tetrahedron (Most compact)

They are about 1-2 units wide each, so you'll have to scale them up.

"I don't like it, and I'm sorry I ever had anything to do with it" - Erwin Schrodinger
El Goorf
18
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Uni: Manchester, Home: Dunstable
Posted: 24th Sep 2007 22:14
thanks for the input guys, ill take some time to digest all of the info. i cant simply use primitives made in milkshape because i'm trying to experiment with random planet generation.

http://notmybase.com
All my base are not belong to anyone.
Lucy
18
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 25th Sep 2007 01:01 Edited at: 25th Sep 2007 01:07
Quote: ""Geodesic dome" "


Basically an icosahedron. The problem with the icosahedron is they're exponential on facets when you start increasing the frequency. The reason DBPro uses the kind of spheres it uses is because it uses the fewest polygons for the level of detail.

As for random planet generation, the most versatile method is the fault technique.

http://local.wasp.uwa.edu.au/~pbourke/modelling_rendering/planets/

My husband and I made a modification on this technique that produces far more variation with less lopsiding. (basically you make it so that it doesn't always cut the sphere down the middle, and you need to make the water center on the center of gravity, which makes it a lot less lopsided and reduces the mirror effect.

We also tried it with both icosahedron and the usual globe type sphere and found that the globe type is more more aesthetically pleasing. The poles don't even show up visually with this technique anyway.

Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 25th Sep 2007 08:57
The reason he deosn't want to use a polar map, I think, is if he wanted to map a texture/heightmap onto the surfaces and vertices repectively, is the fact that vertex density is highest around the poles. Also, the surfaces are largest around the equator, and don't even retain their height/width ratio.

An icosahedron map, on the other hand, has 20 triangles which can each be subdivided by 4, and because of the near-even density of vertices it means a heightmap can be placed over it easily.

The only possible stigma attached to this method is because DBPro doesn't know how to texture it. Consider the following statements:

All images are rectangular.
Each limb can only have one texture.

At this point it seems logical to use 20 different images, as well as limbs. But that is not necessary. There is another thing called UV mapping. This means that in the .x model info it tells you where each vertex is on a "texture map". In other words, you could have a single image composed of 20 different triangles, and UVmap the planet's vertices onto the image.

However, quite a lot of space will be waste trying to tessalate 20 triangles into a rectangular space. A more logical option might be the subdivided octahedron. This looks round, like any other geosphere, but its vertex structure couldn't be more different.

It's geometry is like 6 chessboards folded into a cube, but each of the vertices are projected onto a sphere. This means you can have a simple image storing the texture data for all 6 sides.

Also, because it is a "cube projected onto a sphere", it means that it has square surfaces and could easily be mountainised using 6 heightmaps.

However, the last option is to use a normal polar sphere, like in the web page referred to by Lucy. You could then load the files into Dev-C++ (free with C++ for Dummies) and turn into a DLL. You now have the C++ algorithm in DBPro.

"I don't like it, and I'm sorry I ever had anything to do with it" - Erwin Schrodinger
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Sep 2007 11:10
Now that I think about it, the method Lucy posted seems pretty straight forward. The good thing about it is you can do it with any shape you want. All you have to do is get a random normal, put an imaginary bo over that hemisphere of the planet, and any vertexes inside that box (I think a few years ago I saw someone solve how to do this) move slightly away from the center of the object. Keep doing that, and you get something really good.

The hard part about that is that you dont have it stored in any data structure, so generating a texture would be quite hard.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Sep 2007 19:50 Edited at: 25th Sep 2007 20:09
This is my version so far of the tutorial Lucy posted.



It's a bit exgagarated still.. dont worry about that, but it seems to be working. I plan to change a few things, which I think should fi the pole issues.


[edit]

Didn't notice you had to move the other side of the normal in.

Here's the updated code with some nice water.


"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Lord Einstein
19
Years of Service
User Offline
Joined: 22nd Oct 2005
Location: Well here, of course...
Posted: 25th Sep 2007 20:43
dose not seem to work on my computer. Could you post a screen shot?
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Sep 2007 20:54
Here you go:



"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
El Goorf
18
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Uni: Manchester, Home: Dunstable
Posted: 25th Sep 2007 21:25
aye, when posting code, its courtesy to use a screen resolution the majority of gpu's/monitors can handle

http://notmybase.com
All my base are not belong to anyone.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Sep 2007 21:34
Spheres aren't even spherical with 1024x768 res

Everything gets too squished :/

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Lucy
18
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 25th Sep 2007 21:46 Edited at: 25th Sep 2007 21:49
I applaud you Zotoaster.

You've implimented fault line planet generation in dbpro. Good job! I wasn't sure it could be done with any kind of speed in DBPro because of how inefficient loops can become when you start doing algorythmic stuff.

I'd personally rather do it in C and make a plugin as calcyman was doing (infact, I plan on taking the C code from our planet generator and doing just that). I just want to figure out how to turn the data on the planet into a texture first.

Also, you might try exagerating the resulting height. Also keep in mind that on a real planet, you're not likely to see the hills and valleys very well from orbit. But then realistic is not always as impressive. So exagerating the height on generation can help a lot.

Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.
Lucy
18
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 26th Sep 2007 21:09
We're opening up the old code my husband and I did. We're going to look into making our code into a plugin. Of course ripping out the old glut code.

Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 26th Sep 2007 21:55
Sounds good. If you can, try making it with a geosphere. The DBP spheres dont get pole issues much, but they are a little different at the ends because it's many triangles joining at the same point, unlike the rest of the sphere, so it looks quite.. odd...

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Lord Einstein
19
Years of Service
User Offline
Joined: 22nd Oct 2005
Location: Well here, of course...
Posted: 26th Sep 2007 23:37
are you using a plug in or one of the DBP expansions for my versions does not seem to recognise these commands:

Lock Vertexdata For Limb 1, 0
VX = Get Vertexdata Position X( v )
For v = 0 to Get Vertexdata Vertex Count() - 1

And all of the other ones about vertex's. Is there a command which is simular to these?
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Sep 2007 00:11
Try upgrading

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Lord Einstein
19
Years of Service
User Offline
Joined: 22nd Oct 2005
Location: Well here, of course...
Posted: 27th Sep 2007 23:58
Thanks. It works now and well done that looks really good.
Agent Dink
21
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 30th Sep 2007 18:46
That's really cool Zotoaster.

Burnman
18
Years of Service
User Offline
Joined: 4th Mar 2007
Location: New England
Posted: 2nd Oct 2007 18:13 Edited at: 2nd Oct 2007 18:13
Quote: "Zotoaster wrote:

Spheres aren't even spherical with 1024x768 res

Everything gets too squished :/"


Actually... you can increase the sphere's spherishness (it's a real word in my mind) by using the column/row attributes:

make object sphere ObjectNumber, ObjectSize, ObjectColumns, ObjectRows

The more columns and rows you add, the better the resolution... of course, the more memory it uses. At a screen resolution of 1024x768x32, a sphere 1000 units big with 10 columns & 10 rows looks pretty decent. I haven't done any tests with performance with this yet... I was playing around with it last night before bed.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 2nd Oct 2007 18:29 Edited at: 2nd Oct 2007 18:30
I dont mean by the sphere's resolution. Atleast with my monitor, when I have a 1024x768 res, the spheres are wider than they are tall. When I set it at 1440x900, it looks perfectly spherical.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Burnman
18
Years of Service
User Offline
Joined: 4th Mar 2007
Location: New England
Posted: 2nd Oct 2007 18:35
Ahhhh, gotchya.
Lucy
18
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 3rd Oct 2007 09:20
It's a matter of aspect ratio.

Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.

Login to post a reply

Server time is: 2025-08-08 15:40:08
Your offset time is: 2025-08-08 15:40:08