# drawing solar systems

This topic is 1288 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i've started working on SIMSpace v8.0 when i need a break from working on Caveman 3.0, but still have energy to work.

the game is a starship flight sim.

the game world is a cube which is 14E17 meters across = 1.4*10 to the 18th meters = 1.4 million trillion meters.

the game world will have 1000 star systems in it. the world size is chosen such that the distribution density of the 1000 stars is the same as the milky way. IE same volume of space per star on average.

for rendering, the "twice as close, half as big" approach will be used.

to keep it simple to start with, all stars will be the size of our sun - 700 million meters radius.

a rules of thumb of max visual range of an object = 200*radius = 100* diameter will be used.

so a star will have a radius of 700M m for drawing and collision, an will be visible out to 1.4B m. with a unit size sphere mesh (1 unit dia), the scale factor will always be 1.4B.

all this fits fine in ints, but not floats.

a world coordinate system is used, with quadrants, sectors, and meters as units. 1 quadrant is 1M sectors across. 1 sectors is 1M meters across.

stars can have up to 20 planets each, and planets can have up to 20 moons each.

i've come up with the following algo for drawing:

1. turn off zbuf

2. draw skybox

3. draw background galaxies

4. sort stars in vis range from farthest to nearest.

5. for each star:

5a. determine biggest power of 10 to divide by that leaves the range of a star > 1.  for stars like our sun, this divisor is 100M.

5b. divide range and scale by the divisor.

5c draw it

6. turn on zbuf

7. draw small visible targets as usual.

ships are 100m dia, and starports are 200m dia. so max viz rng of a starport would be 20Km.  even the smallest moon would be bigger than 20Km radius, so any ship or starport partly behind a moon, planet, or star will be too far to be visible.  so its ok to draw visible ships and starports normally in a second pass with zbuf on after drawing the nearby stars, planets and moons,

applying the 100M divisor to the sun gives a radius of 7, a range of 7 to 1400, and a scale of 14. all quite reasonable numbers to deal with in floats in d3d.

to divide range:

1 determine displacement vector from camera to star

2. divide each component by the divisor.

dividing the scale is trivial.

questions:

1. will this algo work?

2. am i dividing range correctly?

3. is my assumption about partly obscured ships/starports being too far to draw correct?

4. is there a better/simpler way?

5. anything i forgot?

##### Share on other sites

Nobody's going to take a stab at this one huh?

wow.

guess i'll try it and find out.

##### Share on other sites

postmortem:

just got it working.

turns out you have to lerp the scale of the model based on the true range to the camera. this makes sense. perspective foreshortening is dealing with a mesh that is drawn 100 million times closer to the camera than its real distance. so the divide by z is off by 100 million, so to speak.

so a simple lerp of range: (collision range -> max visual range) to (max scale -> 0.0f) is all that's needed

all the rest of it worked just fine.   especially once i added the call to render_queue.submit! <g>.  (they say it helps).

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 11
• 24
• 42
• 75