Tuesday, November 6, 2007

Added 302,400 individual Asteroids!

Woke up on Sunday morning, about 8am I think. While lying in bed I thought of a great way to generate thousands of individual asteroids, each with it`s own size and orientation etc etc


Each of the current 302,400 asteroids have their own unique position and orientation in space. If you where to mark one asteroid, fly away, and then come back to the same location later you would see that same asteroid. ie they do not randomly re-generate each time you aproach them, they are constant entities.

In this photo you can see just some of the 302,400 asteroids. Some of them are rotating about X,Y,Z axis (or any combination of) .

The problem was that an asteroid belt can contain hundreds of thousands of individual asteroids and I can not store that many coords and their respective orientations and size! (not to mention their chemical compositions! and ore contents)









The soluton...


As I lay in bed it became obvious how to solve this problem. The key is that asteroids form Asteroid BELTS and Not asteroid FIELDS! ah-ha, A belt being a simple sin & cos 2d circle formula!
1. Break asteroid Belt into segments, I decided on 0.1 degree per part. ie 0-360degree circle = 360 degrees at 0.1 degree increments = 3600 centre points!
2. check if this centre point is visible? If no then, just display the location by way of a text name in the distance to the player every 1 degree increase.
3. if the centre point is in visible range then, loop through 84 asteroids, placing each one at a generated offset from centre point. Also generate starting oriention and size, then rotate in real time based on Game time.

All this runs at an amazingly fast speed and so doesn`t even slow the game down.
Expect a blog statement at somepoint, when I fully intent to increase the asteroids count by ten fold at least.
ie expect it to go to 3,024,000 asteroids per Belt and expect upto 5 belts per system,
giving an amazing 15,120,000 (15 million) individual asteroids in on solarsystem.

Each of the 15 million asteroids will have its own fixed position,size and orientation. Also its own unique chemical composition (to be mined by player if they wish to!).

2 comments:

Anonymous said...

might it be even better if the asteroids rotated around the belt?

Robert said...

I sent you a message through xbox live. I wish to help you.