Page 1 of 2

Display planets in magnified size.

Posted: 06.07.2007, 20:26
by Vincent
Hi,

The following script maps the [D] key to a function that toggles the display of planets
between their real size and a magnified size Mode (works with any solar system).

Image Image

----------------------------------------------------
This script works with Celestia 1.5 or later.
----------------------------------------------------

Code: Select all

-- Map the togglePlanetSize function to the [D] key.
-- (Toggle the size of planets between Real and Magnified Modes)

radius = {}
iradius = {}
mag_coeff = 2e3

function getRadius(obj_table)
   for k, obj in pairs(obj_table) do
      radius[k] = obj:radius()
   end
   return radius
end

function getSolsysElements()
   planets = {}
   parent = sel;
   while parent:type() ~= "star" do
      parent = parent:getinfo().parent
   end
   if parent then
      starname = parent:name()
   end
   children = parent:getchildren()
   for k, v in pairs(children) do
      if v:type() == "planet" then
         planets[k] = v
      end
   end
   return starname, planets
end

function togglePlanetSize()
   sel = celestia:getselection()
   if sel and sel:name() ~= "?" then
      starname, planets = getSolsysElements()
      radius = getRadius(planets)
      iradius[starname] = not(iradius[starname])
      for k, planet in pairs(planets) do
         if iradius[starname] then
            planet:setradius(radius[k] * mag_coeff)
            celestia:print("Magnification:\n  Planets: "..string.format("%gx", mag_coeff).."\n  Other bodies: 1x", 10, -1, -1, 1, 10)
         else
            planet:setradius(radius[k] / mag_coeff)
            celestia:print("Real size", 10, -1, -1, 1, 10)
         end
      end
   end
end


keyhandlers =
{
   d = togglePlanetSize,
}

function handlekey(k)
    handler = keyhandlers[k.char]
    if (handler ~= nil) then
        handler()
        return true
    else
        return false
    end
end

celestia:registereventhandler("key", handlekey)

-----------------------------------------------------------------------
-- Use the following code if you wish to merge
-- the planet mag script with your start.cel script.
-----------------------------------------------------------------------
function CEL(source)
   local script = celestia:createcelscript(source)
   while script:tick() do
      wait(0)
   end
end

CEL([[
{

# ... Beginning of start.cel script

# PASTE ALL YOUR STANDARD START SCRIPT HERE

# End of start.cel script...
}


]])

-- end

Posted: 06.07.2007, 21:21
by Cham
With Vincent's permission, I'm publishing here a small addon (not a script) which compares the planets and our moon.

Image Image

Since it's just a set of STC and SSC files, every user could easily edit them to fit his/her needs (language, etc), and it should also run with any version of Celestia. The main difference with Vincent's script (appart not being a script !) is that all the planets are stationary and aligned. A small advantage is the inclusion of our Moon, and the names are displaying the scale factor.

Download link :

http://nho.ohn.free.fr/celestia/Cham/Pl ... raison.zip (4 KB zip file)

I'm also interested in a similar addon showing the size of several "typical" stars (Jupiter, brown dwarf, our Sun, Antares, Aldebaran, etc...)

Posted: 06.07.2007, 21:41
by t00fri
Sorry Vincent,

+++++++++++++++++++++++++
but I think somewhere in your magnification code there is a bug:
+++++++++++++++++++++++++

In the OpenGL 2.0 render path and ONLY there the Earth rendering is now buggy if D is pushed for magnification:

The Earth appears essentially black but exhibits some glittering lights on its surface that also move. All other planets are fine. So the effect may be related to some extra textures being overlaid for Earth or due to the VT's, I don't know.

Here is a screendump. Note I just enhanced the brightness in a circle around the Earth to make the effect better visible. Don't worry about the visible boundary artefact. It's due to the brightness enhancement.

Image

Bye Fridger

Posted: 06.07.2007, 21:44
by Cham
I confirm Fridger's bug (I already reported it to Vincent by email, this morning). But apparently, it's related to the atmosphere code in OGL2.

By the way, here are two sites which shows the same thing as us :

http://www.rense.com/general72/size.htm

http://www.youtube.com/watch?v=tL6E8mn-H2c

Posted: 06.07.2007, 21:52
by neo albireo
t00fri wrote:Sorry Vincent,

+++++++++++++++++++++++++
but I think somewhere in your magnification code there is a bug:
+++++++++++++++++++++++++


I confirm this. Also for Mars.

Posted: 06.07.2007, 22:11
by Vincent
t00fri wrote:The Earth appears essentially black but exhibits some glittering lights on its surface that also move. All other planets are fine. So the effect may be related to some extra textures being overlaid for Earth or due to the VT's, I don't know.


Actually, Cham is getting the same bug in his addon which doesn't use my magnification code.
So the bug is not related to my script nor to my magnification code in CVS.

The atmosphere code seems to be buggy for bodies with a large radius.

Posted: 06.07.2007, 22:15
by Cham
I'm very confident the bug is related to the diffusion parameters in the new atmosphere code. The bug can be reproduced with my addon, if I use those parameters set to ON (by default, they are set to OFF). I can kill the bug with Vincent's script, if these parameters are set to OFF. Of course, I'm using OGL2.

Posted: 06.07.2007, 22:45
by t00fri
Vincent,

whatever the reason for that rendering bug, I think your script is still quite "raw".


For instance if I select Titan and then hit D then Saturn's surface is "everywhere".

Image

Have a look! It should be obvious why this happens... Since you did not blow up the distances, Saturn has become bigger than the Saturn-Titan distance...

So in the script it must be taken care of that such things don't happen. There are many moons close by to big planets.

Bye Fridger

Posted: 07.07.2007, 00:10
by Cham
This is probably not the place to publish this, but here it is anyway since it's about size comparison.

Here's a small addon showing a comparison between some famous stars. I placed Jupiter and Earth also to show their relative size, close to our sun.
I'm not really satisfied with this addon, so any comments are welcome.

Download link (unfinished addon) :
http://nho.ohn.free.fr/celestia/Cham/St ... arison.zip (4 KB zip file)

EDIT : Here's a preview of that last addon. I may add a model to add some star labels, since they are too small to be seen.

Image

Our Sun is really tiny, down there (right part of the picture). 8O

Posted: 07.07.2007, 04:30
by Cham
My previous addon could be generalized pretty easily, adding brown, red and white dwarfs around Jupiter. Maybe I should start a new topic on this ?

Image

Posted: 07.07.2007, 09:33
by Vincent
t00fri wrote:Vincent,

whatever the reason for that rendering bug, I think your script is still quite "raw".

For instance if I select Titan and then hit D then Saturn's surface is "everywhere".

Have a look! It should be obvious why this happens... Since you did not blow up the distances, Saturn has become bigger than the Saturn-Titan distance...

So in the script it must be taken care of that such things don't happen. There are many moons close by to big planets.

Bye Fridger

Fridger,

This script can be used to give a first representation about the position and the movement of planets in a solar system.
It also provides a comparative view of the size of planets. So the magnification of planets should be enabled exclusively
when the observer is at a certain distance of a planet, viewing the solar system at a quite large scale.
Moreover, it is not possible yet to set the distance of orbits in a celx script. Otherwise, I would have taken care of this.
Then, to avoid this kind of confusion, I've modified the script so that it now displays the magnification coefficient:
http://vincent.gian.club.fr/celestia/planets_mag.celx
Image

As an example, the following script can be used to provide a comparative view of Saturn's moons (or any Planet-moons system):
http://vincent.gian.club.fr/celestia/moons_mag.celx
Image

Sorry Fridger, but you already know that educational visualizations often require some small adjustments with reality... :wink:

Posted: 07.07.2007, 11:35
by Vincent
Fridger,

I've just had a look at the magnification option in Mitaka: as soon as the first level of magnification is enabled,
Saturn's moons disappear. That confirms that we can't provide a view of our Solar System with both all Planets
and Moons
magnified. Then if we change the distance proportionally to the magnification coefficient,
we won't be able to have a magnified view of our Solar System anymore, since we'll have to zoom out the view,
and that will take us back to the same view as in real size mode...

In Mitaka, the only moon that is also magnified is the Moon. The distance Earth-Moon is slightly increased.
Unfortunately, that can't be done with a Celestia script yet. To do so, one would have to build a whole addon with
a new solar system, just as Cham did. But we would loose the "one simple key" magnification feature that
my script offers. The possibility to toggle between the magnified and the real size Modes with one simple key is
indeed really interesting from an educational point of view.

Finally, here's a last script that provides a magnification option for the Earth-Moon system only:
http://vincent.gian.club.fr/celestia/ea ... n_mag.celx
Image

-------------------------------------------------------------------------------------------------------------------------------------------------
Please note that my 3 scripts now provides a more comprehensive set of magnified visualizations than Mitaka does... :wink:
http://vincent.gian.club.fr/celestia/planets_mag.celx
http://vincent.gian.club.fr/celestia/moons_mag.celx
http://vincent.gian.club.fr/celestia/ea ... n_mag.celx
-------------------------------------------------------------------------------------------------------------------------------------------------

Posted: 07.07.2007, 13:09
by neo albireo
Vincent wrote:That confirms that we can't provide a view of our Solar System with both all Planets
and Moons
magnified. Then if we change the distance proportionally to the magnification coefficient,
we won't be able to have a magnified view of our Solar System anymore, since we'll have to zoom out the view,
and that will take us back to the same view as in real size mode...


The trick of course would be to just count the radius from the surface of the parent body instead of the center. This of course is not really scientifically correct, but giant planets are not really about exact science.

I then would also like to see the sun blown up.

Posted: 07.07.2007, 13:14
by Vincent
neo albireo wrote:The trick of course would be to just count the radius from the surface of the parent body instead of the center. This of course is not really scientifically correct, but giant planets are not really about exact science.
That would require some important change in the Celestia code.

neo albireo wrote:I then would also like to see the sun blown up.

Ha ha, I've been working on this for a few days now... :wink:
I'll let you know when I'm done with it... Just a few days before a test-version, I think...

Posted: 07.07.2007, 21:49
by ANDREA
Cham wrote:With Vincent's permission, I'm publishing here a small addon (not a script) which compares the planets and our moon.
Since it's just a set of STC and SSC files, every user could easily edit them to fit his/her needs (language, etc), and it should also run with any version of Celestia. The main difference with Vincent's script (appart not being a script !) is that all the planets are stationary and aligned. A small advantage is the inclusion of our Moon, and the names are displaying the scale factor.

Cham, this addon is very interesting for educational purposes, but IMHO an important component for this comparation, i.e. the Sun size, is missing there.
So I have modified your addon in order to show this, and here is the result:

Image

But I don't like the excessive glare from the Sun, that washes the aesthetic result (BTW, I increased the contrast in this image, in the original it was lower.
I doin't remember how to reduce it, can you help me? :oops:
And, just a suggestion, don't you think to move these posts in another dedicated thread?
Thanks a lot.
Bye

Andrea :D

Posted: 07.07.2007, 21:53
by Cham
Andrea,

I'm aware of the glare problem with a large Sun. That's why I didn't made it this way in this addon. However, you should check my second addon about the stars themselves (I'm still working on this one). See the addons section on the forum.

Posted: 07.07.2007, 22:11
by ANDREA
Cham wrote: Andrea, I'm aware of the glare problem with a large Sun. That's why I didn't made it this way in this addon.
Yes, now I understand the reason.
But using an "emissive true" planet instead of a star? 8O
Have you tried that?
Cham wrote: However, you should check my second addon about the stars themselves (I'm still working on this one). See the addons section on the forum.

Cham, I'm following that thread and the improvements you are adding there, even if I've not yet tried it.
I'm very interested to the final result so, go on this way, please. :wink:
Bye

Andrea :D

Posted: 07.07.2007, 22:20
by Cham
The stars comparison addon is becoming very nice. However, I'm experiencing a new bug and I'm trying to move around it. I'll have to make some sacrifices, I guess. Also, the star textures are giving me some problems too (polar pitch deformation, color graduation depending on temperature, etc).

The stars addon will probably be very imperfect. At least, it's a good start and some other players could improve it a bit if they wish.

Posted: 08.07.2007, 03:22
by LordFerret
I like the samples you've posted thusfar. :D

Posted: 08.07.2007, 17:46
by ANDREA
Cham wrote:Andrea, I'm aware of the glare problem with a large Sun. That's why I didn't made it this way in this addon. However, you should check my second addon about the stars themselves (I'm still working on this one). See the addons section on the forum.

Cham, I used a different approach to solve the glare problem, and I solved it, or at least in a way that's satisfactory for me.
I just modified with PhotoShop the flare.jpg image, making it black, and this is the result:

Image

It's perfect for my educational needs. :wink:
BTW, I never liked the Celestia flare around stars, IMHO too much evident.
Thank you for starting it.
Bye

Andrea :D