Display planets in magnified size.

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Display planets in magnified size.

Post #1by Vincent » 06.07.2007, 20:26

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
Last edited by Vincent on 16.04.2008, 08:33, edited 4 times in total.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #2by Cham » 06.07.2007, 21:21

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...)
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 7 months
Location: Hamburg, Germany

Post #3by t00fri » 06.07.2007, 21:41

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
Image

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #4by Cham » 06.07.2007, 21:44

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
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

neo albireo
Posts: 68
Joined: 03.02.2005
With us: 19 years 9 months
Location: Switzerland

Post #5by neo albireo » 06.07.2007, 21:52

t00fri wrote:Sorry Vincent,

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


I confirm this. Also for Mars.

Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #6by Vincent » 06.07.2007, 22:11

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.
Last edited by Vincent on 06.07.2007, 22:42, edited 2 times in total.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #7by Cham » 06.07.2007, 22:15

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.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 7 months
Location: Hamburg, Germany

Post #8by t00fri » 06.07.2007, 22:45

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
Image

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #9by Cham » 07.07.2007, 00:10

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
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #10by Cham » 07.07.2007, 04:30

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
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #11by Vincent » 07.07.2007, 09:33

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:
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #12by Vincent » 07.07.2007, 11:35

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
-------------------------------------------------------------------------------------------------------------------------------------------------
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

neo albireo
Posts: 68
Joined: 03.02.2005
With us: 19 years 9 months
Location: Switzerland

Post #13by neo albireo » 07.07.2007, 13:09

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.

Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #14by Vincent » 07.07.2007, 13:14

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...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

ANDREA
Posts: 1543
Joined: 01.06.2002
With us: 22 years 5 months
Location: Rome, ITALY

Post #15by ANDREA » 07.07.2007, 21:49

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
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #16by Cham » 07.07.2007, 21:53

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.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

ANDREA
Posts: 1543
Joined: 01.06.2002
With us: 22 years 5 months
Location: Rome, ITALY

Post #17by ANDREA » 07.07.2007, 22:11

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
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO

Avatar
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

Post #18by Cham » 07.07.2007, 22:20

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.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Avatar
LordFerret M
Posts: 737
Joined: 24.08.2006
Age: 68
With us: 18 years 3 months
Location: NJ USA

Post #19by LordFerret » 08.07.2007, 03:22

I like the samples you've posted thusfar. :D

ANDREA
Posts: 1543
Joined: 01.06.2002
With us: 22 years 5 months
Location: Rome, ITALY

Post #20by ANDREA » 08.07.2007, 17:46

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
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO


Return to “Scripting”