void SolarSystemCreator::makeSatellite(Planet& planet, double &dSatDistance, double currentDistance)
{
    Planet sat = this->createPlanet( currentDistance, true, planet, &dSatDistance);
    sat.setStar(_star.data());
    this->setPlanetType(sat, currentDistance);
    if (sat.massEarth() < 0.6)
        sat.setTidalForce(1.1);
    else
        sat.setTidalForce(0.2);
    planet.appendSatellite(sat);
}
Esempio n. 2
0
void SolarSystemCreator::createWorlds()
{
    double currentDistance;
    _star->numDesert(0);
    _star->numGasGiant(0);


    _star->calcStarValue();
    for (int h = 0; h < _orbits; h++) {
        bool advanceNextPlanet = true;
        do {
            Planet px;
            if (h == 0) {
                double dModifier = 0.1;
                if (_star->starType() == NSStar::stM)
                    dModifier *= .33;
                if (_star->starType() == NSStar::stK)
                    dModifier *= .66;
                if (_star->starType() == NSStar::stF)
                    dModifier *= 1.25;
                currentDistance = dModifier + SSGX::floatRand() * dModifier;
            }
            else
                currentDistance *= (1.2+ (double)(rand() % 900)/1000.0);
            int chance = SSGX::d10();
            if (chance < 8) {

                Planet planet = this->createPlanet(currentDistance, false,px);
                this->setPlanetType(planet, currentDistance);

                int numSat = 0;
                if (planet.planetType() == ptGasGiant)
                    numSat = SSGX::d6()+SSGX::d6()+SSGX::d6();
                else if (planet.planetType() != ptChunk)
                    numSat = SSGX::d6()-3;

                if (numSat > 0)
                {
                    double dSatDistance = 0;
                    for (int idxSat = 0; idxSat < numSat; idxSat++)
                    {
                        Planet sat = this->createPlanet( currentDistance, true, planet, &dSatDistance);
                        this->setPlanetType(sat, currentDistance);
                        if (sat.massEarth() < 0.6)
                            sat.setTidalForce(1.1);
                        else
                            sat.setTidalForce(0.2);
                        planet.appendSatellite(sat);

                    }
                }
                double T = (_star->mass()*266400.0 / pow((planet.orbitPtr()->distance() *400),3));
                double tf = (double)((0.83 + (double) SSGX::d10() *.03) *T * _star->solarAge() / 6.6);
                planet.setTidalForce(tf);
                //qDebug() << "Set Tidal Force. " << tf << planet.tidalForce();

                if (planet.planetType() == ptGasGiant && planet.tidalForce() > 1.0) {
                    advanceNextPlanet = false;
                }
                else  {
                    advanceNextPlanet = true;
                    _star->appendToPlanets(planet);
                }
            }
        } while (!advanceNextPlanet);

    }
    _star->calcStarValue();

}