Page 1 of 1

Moon orbits do not appear unless planet selected

Posted: 01.05.2004, 06:29
by don
Windows version (1.3.1+, not sure about earlier versions).

Want to display only moon orbits but it seems that I cannot do this, without first selecting the parent body of the moon. Then, the parent body orbit is displayed, even though this option (planet orbits) is NOT checked, and also appears as red, since it is the selected object <sigh>.

With Moon Orbits selected, Planet Orbits NOT selected, and Show Orbits active, NO moon orbits are displayed.

Here is the relevant (I think) code from render.cpp. If someone could direct me to a fix, I would be happy to apply it...

Code: Select all

void Renderer::renderOrbits(PlanetarySystem* planets,
                            const Selection& sel,
                            double t,
                            const Point3d& observerPos,
                            const Point3d& center)
{
    if (planets == NULL)
        return;

    double distance = (center - observerPos).length();

    // At the solar system scale, we'll handle all calculations in AU
    // Not used anymore
    // Vec3d opos = (center - Point3d(0.0, 0.0, 0.0)) * astro::kilometersToAU(1.0);

    int nBodies = planets->getSystemSize();
    for (int i = 0; i < nBodies; i++)
    {
        Body* body = planets->getBody(i);
           
        // Only show orbits for major bodies or selected objects
        if ( (body->getClassification() & orbitMask) != 0 || body == sel.body() )
        {
            if (body == sel.body())
            {
                // Highlight the orbit of the selected object in red
                glColor4f(1, 0, 0, 1);
            }
            else
            {
                switch (body->getClassification())
                {
                case Body::Moon:
                    glColor4f(0.0f, 0.2f, 0.5f, 1.0f);
                    break;
                case Body::Asteroid:
                    glColor4f(0.35f, 0.2f, 0.0f, 1.0f);
                    break;
                case Body::Comet:
                    glColor4f(0.0f, 0.5f, 0.5f, 1.0f);
                    break;
                case Body::Spacecraft:
                    glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
                    break;
                case Body::Planet:
                default:
                    glColor4f(0.0f, 0.4f, 1.0f, 1.0f);
                    break;
                }
            }
... other orbit drawing code ...

Thanks a bunch!

Posted: 01.05.2004, 12:12
by Bob Hegwood
Can confirm your posting, Mr. Goyette... I noticed this somewhere around 1.3.2 Pre 3
I think. Hell, I thought it was intentional. :wink:

Take care, Bob

Re: Moon orbits do not appear unless planet selected

Posted: 16.10.2004, 00:08
by rthorvald
don wrote:Want to display only moon orbits but it seems that I cannot do this, without first selecting the parent body of the moon [...] With Moon Orbits selected, Planet Orbits NOT selected, and Show Orbits active, NO moon orbits are displayed


Instead of making a new subject, i?m dragging this one out of Celestia?s remote history (well, it?s been six months...):
I have just discovered why moon orbits does not display if the parent is not selected - or rather, i have found a workaround for it:

If all elements in the SSC file have proper classes assigned, moon orbits WILL be displayed if checked - regardless of the parent, or any other circumstances. If classes are missing (if, say, a moon does not have a Class "moon" definition) it breaks, and the system behaves the way Don described here.

Happy. This has bugged me for a long time :idea:

-rthorvald

Posted: 16.10.2004, 17:00
by maxim
Taking Runars discovery into account, it seems that the lines

Code: Select all

        if ( (body->getClassification() & orbitMask) != 0 || body == sel.body() )
.
.
.
                switch (body->getClassification())

are responsible.
The call 'getClassification()' probably returns NULL then, if no proper class is assigned inside the ssc file, resulting in skipping the 'if' statement at all, or switching to the 'default' mark - which displays the planets orbit.

A workaround could be a try to detect the parents class.
Either while parsing the ssc file, where a missing class is replaced by a plausible one, depending on the objects definition code.
Or inside the given function by a construct similar to this pseudo-code:

Code: Select all

if (!body->getClassification()) {
  parent = body->getParentClass();
  if {parent==PLANET) {
    if (body->size > 200m) body->setClassification(MOON);
    else                   body->setClassification(SPACECRAFT);
  }
  else if (parent==STAR) {
    if (body->size > 200km) body->setClassification(PLANET);
    else                    body->setClassification(ASTEROID);
  }
}

if ( (body->getClassification() & orbitMask) != 0 || body == sel.body() )
.
.
.



maxim