Jump to content

  • Log In with Google      Sign In   
  • Create Account






World in 7 days, Days 2, 3 and 4: Stars and planetary systems

Posted by ManTis, in worldin7days 27 February 2014 · 413 views

worldin7days programming unity fun c#
I haven't updated in long time but this doesn't mean I haven't worked. In fact, I am splitting my work hours between this project and GAMIFICATOR™ ;) and I'm now on day 4 of making world.

Currently my galaxy can hold up to 5.4 * 10^13 stars (that's a lot). You can check out the most current version HERE (click me), the seed is set so no voice-created universes for you. The interface is clunky, sometimes it gets stuck (reload if that happens), and sometimes it generates gas giants next to the sun, with couple dozen earth sizes in diameter, and a fraction of its mass. But we're not here to nitpick, are we? We're here to generate UNIVERSES Posted Image.

So, let's do a writeup of what has happened so far (with sprinkle of pretty pictures):

What I had previously was looking pretty, but ultimately doomed to fail, as it had no level of detail progression. Which means I was limited by the amount of stars in the galaxy. Bad thing. I've started working on it, and had some pretty funky results:

Posted Image

Finally I have created really nifty looking galaxy:

Posted Image

That's more like it, but still not good enough. I needed to walk away from prettyfying, and move back towards optimisation, to allow the amount of stars that I wanted (granted, this galaxy would be more than enough for what one person can experience). So I've started implementing octree. It took me majority of Day 2, and I was left with something that visualised to this:

Posted Image

Ooh, pretty colours. Still, it didn't feel right. On third day I sat with my good friend Theo, and implemented non-persistent node implementation, that created node ID based on its location and depth, and created seed out of that. This allowed for repeatable generation of data without the need to store the data structure. The seed code looks like this:
    void FillOutNode(int x, int y, int z, int depth)
    {
        ulong mask = 0xffffffffful << (nodeDepth - depth);

        float minX = (float)((ulong)x & mask);
        float minY = (float)((ulong)y & mask);
	float minZ = (float)((ulong)z & mask);

	float length = 1 << (nodeDepth - depth);
        ulong nodeID = FindNodeIDBin (x, y, z, depth);
        int currentSeed = nodeID.GetHashCode() + universeSeed.GetHashCode();
        Random.seed = currentSeed;
                
        // STUFF HAPPENS HERE
    }
      
    ulong FindNodeIDBin(int x, int y, int z, int depth)
	{
		ulong mask = 0xffffffffful << (nodeDepth - depth);
		return ((ulong)depth << 36) | (((ulong)x & mask) << 24) | (((ulong)y & mask) << 12) | (((ulong)z & mask) << 0);
	}
Neat, eh? Well, this gave me neat spatial partitioning:

Posted Image

Rest of the day was spent on adding space navigation (ooh sexy starjump code) and starting to add proper star data generation, which continued into day four:

Posted Image

And on day four I've added planet generation:

Posted Image

Well, that's what I have so far, going into day 5, on which I'll focus on moving into planetary system mode. So far the problem is following: To allow for enough precision, I had to position the stars at pretty close locations. Going into planetary system will mean that the precision will need to be insanely higher (if we're to allow, say, visiting planets, which is the goal of this whole exercise). Smooth transitioning between different speeds will be interesting, but I think I can make it. That means also displaying of the planets and sun, which will also be fun ;).

I'll also want to do an update on GAMIFICATOR© some time before the end of the week, but don't know if I'll have time to do it. I reserved time on Sunday and Tuesday evenings for it, so that progression doesn't stop. So far so good Posted Image. The GAMIFICATOR (patent pending) started as a tool to help me become productive, and I've spent more time polishing it and being productive on it than with any other recent projects. I guess it's serving its purpose even before it's finished ;).

So, again, I hope I'll find some time to develop some more.

See you then!

===========================================================================================
Story so far:

Days 2, 3 and 4: Stars and planetary systems
Day 1: Galaxies




PARTNERS