More Planet/Star Information

The place to discuss creating, porting and modifying Celestia's source code.
Guest

More Planet/Star Information

Post #1by Guest » 20.12.2003, 01:58

Hi!
Let me first off say that Celestia is a fantastic product, and being open source is even more fun.

I know a little bit about Astronomy and a little bit about programming and I'd like to try and add more information about the stars/planets when they are selected. Currently it displays distance, length of day, etc. I want to add elements like Mass, Escape Velocity, Gravitational Pull etc. I know how to compute all those elements, but my question is; how to I implement this into celestia? Are there any structures that must be extended to allow this new information to be recorded and how to I modify the source to display these new variables? Also is there any intialization phase or any phase during rendering when such variables must be recomputed (mass and escape velocity will always be fixed) such as Gravitational Pull, and other variables that may change during the course of the simulation.

Again, thank you all for a wonderful program and for great addons. My hats off to those who dedicate their time to this.

Sincerely,
Ken V. Nordberg
elevator@encasa.org

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Post #2by selden » 20.12.2003, 03:29

Ken,

I'm not one of the code developers and I'm not sure if you've looked at it yet, but the source code for Celestia is all on SourceForge at http://sourceforge.net/projects/celestia

However, you do need to understand that Celestia is not a simulation program, despite the use of that term occasionally. Rather, it's a display program. The objects in Celestia do not interact with one another as they would in a simulation. They are drawn as specified in Celestia's catalog and database files. Celestia does not actually implement gravity, for example. Instead it knows how to draw objects that follow Keplerian orbits.

The topic of how much information Celestia should draw on the screen (as opposed to it displaying appropriate Web pages) has been discussed in the past. You might want to do a search of the forum, although I'm having problems finding the appropriate topics myself.

However, in the process I did find one fascinating thread that was posted almost two years ago in January, 2002. It discusses some of the early goals for the program. See http://63.224.48.65/forum/viewtopic.php?p=661

I hope this helps a little.
Selden

HankR

Post #3by HankR » 20.12.2003, 05:08

Ken,

Celestia is written in C++. It's been a while since I looked at the code for the information display overlay, but if I recall correctly I believe it is basically hard-coded inside the rendering loop. If you have the necessary programming skills you can download the source code from SourceForge and build a custom version of Celestia with the addition of whatever code is required to display the information you're interested in seeing.

Eventually I think it might be worthwhile to build into Celestia support for an additional information display level which would provide a user-defined information display, where the information to be displayed would be generated by a user-supplied Lua function.

- Hank

Guest

Post #4by Guest » 20.12.2003, 07:34

Hank,
Thanks for your reply. I have looked at the code and it's a bit overwhelming right now. I have compiled it with no problem in Windows 2000 with Visual C++ 5.0. I am certainly not interested in extending the functionality of Celestia in any way or making it into something it is not. I do not have the necessary programming skills to do that, but I do want to extend it to fit my personal preference, and that is to display more detailed information about the bodies I am looking at. I realize that must involve some modification to the data structures of the bodies and perhaps modification of the rendering loop that takes care of displaying that specific data on the screen.

My intention then with the last post was to get in contact with someone who know the code well enough or perhaps has had similar thoughts to help me out with a few pointers on where to look and what code to modify.

Thanks again for your input.

Ken.

HankR

Post #5by HankR » 20.12.2003, 17:30

Ken,

Here's a little more specific information for you, based on a quick look at the code to correct my recollection:

The current overlay information is displayed in the method 'CelestiaCore::renderOverlay' found in the source file 'celestiacore.cpp' around line 2600. It uses an 'Overlay' class object, as defined in 'overlay.cpp'.

The 'Overlay' class is derived from 'std::streambuf', so you just write to it using the standard C++ stream IO approach (as if you were writing to a file).

For the object information displayed at upper left, the 'CelestiaCore::renderOverlay' method uses methods 'CelestiaCore::displayPlanetInfo', 'CelestiaCore::displayStarInfo', etc. These methods are also in 'celestiacore.cpp', around line 2400.

Here's how the planet radius is displayed, for example:

Code: Select all

    overlay << "Radius: ";
    distance = astro::kilometersToLightYears(body.getRadius());
    displayDistance(overlay, distance);
    overlay << '\n';

where 'CelestiaCore::displayDistance' does the following:

Code: Select all

    if (abs(distance) >= astro::AUtoLightYears(1000.0f))
    {
        units = "ly";
    }
    else if (abs(distance) >= astro::kilometersToLightYears(10000000.0))
    {
        units = "au";
        distance = astro::lightYearsToAU(distance);
    }
    else if (abs(distance) > astro::kilometersToLightYears(1.0f))
    {
        units = "km";
        distance = astro::lightYearsToKilometers(distance);
    }
    else
    {
        units = "m";
        distance = astro::lightYearsToKilometers(distance) * 1000.0f;
    }

    overlay << SigDigitNum(distance, 5) << ' ' << units;


I hope this helps.

- Hank

Guest

Post #6by Guest » 21.12.2003, 01:39

Hank,
Thanks a lot for your help. That was exactly what I needed. I don't know how I could have missed it going through the code. I guess I expected the overlay/HUD to be part of the celengine project rather than the celestia project. I was able to display the text I want to display (although I currently just hardcoded a few lines of text in there to make sure it actually works). What remains now is to find and modify the actual data structures and being able to populate these structures... but I'll try and search for that myself. Any tips about the data structures, loading of body data from files, etc. are still greatly appreciated though.

Thanks again Hank for pointing the overlay part out to me.

Ken V. Nordberg

DSF
Posts: 1
Joined: 29.12.2003
With us: 20 years 9 months

Post #7by DSF » 29.12.2003, 15:44

Ken,

If this may help you, I have implemented a little bit more information on the screen tampering with Celestia code, but it was not forthright.

The code I entered, mainly, allows me to see the Body mass, Gravity, Orbital Radius and Density, though more information is easily inserted if you put this into it.

First, I created a nw entry in the ssc files for bodies listing their Mass whigh goes like this:

Mass 5.98E+24

That's earth's mass.
Then, to make Celestia read this information, I added a new private property to the Body class in "body.h":

double mass;

and the following new methods:

double getMass() const;
void setMass(double);
float getDensity() const;
float getGravity() const;

which were defined in "body.cpp" like this:

double Body::getMass() const
{
return mass;
}


void Body::setMass(double _mass)
{
mass = _mass;
}

float Body::getGravity() const
{
return GRAVITATIONAL_CONSTANT * mass / pow(radius*1000, 2);
}

float Body::getDensity() const
{
return mass*1000 / (4 * PI * pow(radius*100000, 3) / 3);
}


Thus, the "CreatePlanet" function in "Solarsys.cpp" had to be altered to actually make Celestia read the information in the ssc files. This was easily done with the following lines:

double mass = 0.0;
planetData->getNumber("Mass", mass);
body->setMass(mass);

inserted at about line 377 of solarsys.cpp (right after the code loads the oblateness data).

Lastly, I modified "celestiacore.cpp" to allow it to display the new extra information, altering the "displayPlanetInfo" method by adding:

if (detail > 2)
{
overlay << "Period: " << body.getOrbit()->getPeriod() << " Earth days\n";
if (body.getMass() > 0)
{
overlay.printf("Mass: %.2E Kg\n", body.getMass());
overlay.printf("Gravity: %.2f m/s2\n", body.getGravity());
overlay.printf("Orbital Radius: %.2E km\n", body.getOrbit()->getBoundingRadius());
overlay.printf("Density: %.2f g/cm3\n", body.getDensity());
}
}

You may notice that the condition "if (detail > 2)" refers to a detail lever which will never be properly selected in Celestia, since its detail levels are 0, 1 or 2. I added a new detail level in the render options menu called "astro" with code 3 that allows for the selection of this new information.

The result:

Image

kikinho
Posts: 330
Joined: 18.09.2004
With us: 20 years
Location: Eden, a planet in Etheral Universe

Post #8by kikinho » 19.10.2004, 21:59

Chris, will the next release of Celestia have more informations of bodies like that are in this post?
It is sad in this post that you have to modify some files of the source code, but this is very difficult for me and I think also for the majority people in this community.
I think this is a good idea. No, not only a good idea, but a GREAT because it seems to me that EVERYBODY here will like to see more informations of a planet and star.

Ah, and I also starting to do a new system that will orbit two stars with a third little red star farther than Pluto to Sun.

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

Post #9by t00fri » 19.10.2004, 23:09

I don't think such huge overlays are a good idea at all. They destroy the beautiful impression of the displayed image.

In Celestia-KDE (Linux) this is solved elegantly: By pushing the right mouse button, an info popup comes up the content of which could be much extended without destroying the visual image impression...

However, by clicking 'info' on the popup, the KDE-browser will display a professional-quality info page about the selected object (star, planet, asteroid,...) from the Strassbourg astronomical data base or related sources.

The advantage is the the displayed information from Strassbourg corresponds to the professional 'state of the art', i.e. it is as correct as it can be...

Why inventing the wheel twice??

Bye Fridger

kikinho
Posts: 330
Joined: 18.09.2004
With us: 20 years
Location: Eden, a planet in Etheral Universe

Post #10by kikinho » 19.10.2004, 23:37

But in Celestia you can simply press V button for turn on/off the informations.

Evil Dr Ganymede
Posts: 1386
Joined: 06.06.2003
With us: 21 years 3 months

Post #11by Evil Dr Ganymede » 19.10.2004, 23:51

However, by clicking 'info' on the popup, the KDE-browser will display a professional-quality info page about the selected object (star, planet, asteroid,...) from the Strassbourg astronomical data base or related sources.

I'd say the "visual impression" si pretty much annihilated by a webpage popping up over the image ;).


The advantage is the the displayed information from Strassbourg corresponds to the professional 'state of the art', i.e. it is as correct as it can be...


I'd like to see how they do that for fictional worlds ;).

kikinho
Posts: 330
Joined: 18.09.2004
With us: 20 years
Location: Eden, a planet in Etheral Universe

Post #12by kikinho » 20.10.2004, 01:13

It's because I'm starting to do my next system add-on and I want to put something more, like a script with sounds and text in pop up windows based on "Pulsar Sounds". The pop up window will show the body information in a script.
When I go to a planetary, I see great videos inside it and I'm thinking of doing the same thing with my add-on.
Ah, and one more thing. Why did you choose the name Ganymede, Evil dr. Ganymede? It can be for some reason.

Evil Dr Ganymede
Posts: 1386
Joined: 06.06.2003
With us: 21 years 3 months

Post #13by Evil Dr Ganymede » 20.10.2004, 01:18

kikinho wrote:Ah, and one more thing. Why did you choose the name Ganymede, Evil dr. Ganymede? It can be for some reason.


I did part of my PhD on it :), and I always figured it was under-rated as Galilean satellites went. I mean, it's the biggest satellite in the solar system, and what gets the attention? That little upstart Europa! 8) :lol:

maxim
Posts: 1036
Joined: 13.11.2003
With us: 20 years 10 months
Location: N?rnberg, Germany

Post #14by maxim » 20.10.2004, 07:30

t00fri wrote:However, by clicking 'info' on the popup, the KDE-browser will display a professional-quality info page about the selected object (star, planet, asteroid,...) from the Strassbourg astronomical data base or related sources.

The advantage is the the displayed information from Strassbourg corresponds to the professional 'state of the art', i.e. it is as correct as it can be...

Why inventing the wheel twice??

Because this takes a lot of time and interaction which would destroy visual impression more likely.

I'm sure I'm not the only one not having a DSL flat. So connecting to external sources requires establishing a connection by hand (I don't allow automatic connecting) by going through some desktop menues, then entering the password (I don't allow for storing of passwords), waiting for the dialing, connection and http-request. It's only then when the site comes up and displays the information. I'll be half through the galaxy before getting the info for the first star.

Alternatively downloading the Strassbourg data base for storing it local also has some minor disadvantages.

I can't see why a user definable overlay display can't be invented. Let it be guided by a config file, where everyone can define what he likes to be displayed at what verbosity level, and we all can be happy.

maxim

Empty86
Posts: 10
Joined: 16.10.2004
With us: 19 years 11 months
Location: Holland

Post #15by Empty86 » 20.10.2004, 11:01

kikinho wrote:But in Celestia you can simply press V button for turn on/off the informations.


Earth temperature = 257 K = -16.15 degree Celsius :?

Offstopic yea but er... 8O

granthutchison
Developer
Posts: 1863
Joined: 21.11.2002
With us: 21 years 10 months

Post #16by granthutchison » 20.10.2004, 11:47

Empty86 wrote:
kikinho wrote:But in Celestia you can simply press V button for turn on/off the informations.
Earth temperature = 257 K = -16.15 degree Celsius :?
It's a calculated black-body temperature, which is a pretty much correct for the temperature at the top of the clouds; same thing applies to Venus, and to all the gas giants.

Grant

Guest

Post #17by Guest » 20.10.2004, 15:35

Evil Dr Ganymede wrote:
However, by clicking 'info' on the popup, the KDE-browser will display a professional-quality info page about the selected object (star, planet, asteroid,...) from the Strassbourg astronomical data base or related sources.

I'd say the "visual impression" si pretty much annihilated by a webpage popping up over the image ;).

Unlike Windows, in Linux everyone works with a number of (virtual) desktops and assigns programs to start in appropriate ones.

My 4 desktops, for example, are called 'Login, Apps, Mail, WWW'. The Browser and Mozilla-mail are started in WWW and Mail already at Login. So nothing is in the way , the browser just displays the desired info from Strassbourg in desktop WWW.

With a key of your choice or with the mouse in a "pager" you may quickly switch between the desktops.
Evil Dr. Ganymede wrote:
The advantage is the the displayed information from Strassbourg corresponds to the professional 'state of the art', i.e. it is as correct as it can be...

I'd like to see how they do that for fictional worlds ;).
[/quote]

Indeed, this possibility was not resident in my brain ;-)


Bye Fridger

Guest

Post #18by Guest » 20.10.2004, 16:00

Anonymous wrote:
Evil Dr Ganymede wrote:
However, by clicking 'info' on the popup, the KDE-browser will display a professional-quality info page about the selected object (star, planet, asteroid,...) from the Strassbourg astronomical data base or related sources.

I'd say the "visual impression" si pretty much annihilated by a webpage popping up over the image ;).

Unlike Windows, in Linux virtually everyone works with a number of (virtual) desktops with programs assigned to start in appropriate ones.

My 4 desktops, for example, are called 'Login, Apps, Mail, WWW'. The Browser and Mozilla-mail are started in WWW and Mail, respectively, already at Login. So nothing is in the way , the browser just displays the desired info from Strassbourg in desktop WWW.

With a key of your choice or with the mouse in a "pager" you may quickly switch between the various desktops.

Evil Dr. Ganymede wrote:
The advantage is the the displayed information from Strassbourg corresponds to the professional 'state of the art', i.e. it is as correct as it can be...

I'd like to see how they do that for fictional worlds ;).


Indeed, this possibility was not resident in my brain ;-)


Bye Fridger

Evil Dr Ganymede
Posts: 1386
Joined: 06.06.2003
With us: 21 years 3 months

Post #19by Evil Dr Ganymede » 20.10.2004, 16:06

Anonymous wrote:
Evil Dr Ganymede wrote:I'd say the "visual impression" is pretty much annihilated by a webpage popping up over the image ;).

Unlike Windows, in Linux everyone works with a number of (virtual) desktops and assigns programs to start in appropriate ones.

My 4 desktops, for example, are called 'Login, Apps, Mail, WWW'. The Browser and Mozilla-mail are started in WWW and Mail already at Login. So nothing is in the way , the browser just displays the desired info from Strassbourg in desktop WWW.

With a key of your choice or with the mouse in a "pager" you may quickly switch between the desktops.


Same difference. You still have to go look on another desktop to see the webpage, which removes the image from the screen as effectively as covering it up with a WWW window. Sure, it's useful, but not exactly aesthetically satisfying...

Mikeydude750
Posts: 169
Joined: 31.01.2002
With us: 22 years 7 months
Location: Wisconsin

Post #20by Mikeydude750 » 20.10.2004, 21:09

How about parsing that database with a special function that would turn it into a text file that would then be transparently overlayed on the Celestia window itself?

You could make it look very nice and polished, maybe with even a function that displays the name of an object when you mouse over it.


Return to “Development”