// Use this for initialization
    void Start()
    {
        ge     = GravityEngine.Instance();
        x_axis = new Vector3d(1, 0, 0);

        // mass scaling will cancel in this ratio
        soiRadius = OrbitUtils.SoiRadius(planet, moonBody);

        // TODO: allow moon to be OrbitUniversal as well.
        OrbitUniversal moonOrbit = moonBody.gameObject.GetComponent <OrbitUniversal>();

        if (moonOrbit == null)
        {
            Debug.LogError("Moon is required to have OrbitUniversal");
        }
        moonRadius = moonOrbit.GetMajorAxis();

        shipOrbit = spaceship.GetComponent <OrbitUniversal>();
        if (shipOrbit == null)
        {
            Debug.LogError("Require that the ship have an OrbitU");
        }
        if (shipOrbit.evolveMode != OrbitUniversal.EvolveMode.KEPLERS_EQN)
        {
            Debug.LogError("Controller requires ship on-rails but spaceship is off-rails");
        }

        // assuming circular orbit for ship
        shipRadius = shipOrbit.GetApogee();

        shipOrbitPredictor = spaceship.GetComponentInChildren <OrbitPredictor>();
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        soiRenderer = GetComponent <LineRenderer>();
        soiRadius   = OrbitUtils.SoiRadius(planetBody, moonBody);

        OrbitUniversal orbitU = moonBody.GetComponent <OrbitUniversal>();

        if (orbitU != null)
        {
            inclination = (float)orbitU.inclination;
        }
    }
    // Use this for initialization
    void Start()
    {
        ge = GravityEngine.Instance();

        shipAngle = shipAngleDeg * Mathf.Deg2Rad;
        soiAngle  = soiAngleDeg * Mathf.Deg2Rad;

        // disable maneuver predictor until things settle (can get Invalid local AABB otherwise)
        SetOrbitDisplays(false);

        // mass scaling will cancel in this ratio
        soiRadius = OrbitUtils.SoiRadius(planet, moonBody);
        toMoonOrbit.hyperDisplayRadius = soiRadius;

        // TODO: allow moon to be OrbitUniversal as well.
        OrbitEllipse moonEllipse = moonBody.gameObject.GetComponent <OrbitEllipse>();

        moonRadius  = moonEllipse.a_scaled;
        targetPoint = new Vector3d(moonRadius, soiRadius, 0);

        float        inclination = 0;
        OrbitEllipse shipEllipse = spaceship.gameObject.GetComponent <OrbitEllipse>();

        if (shipEllipse != null)
        {
            shipRadius  = shipEllipse.a_scaled;
            inclination = shipEllipse.inclination;
        }
        else
        {
            OrbitUniversal orbitU = spaceship.GetComponent <OrbitUniversal>();
            if (orbitU != null)
            {
                // assuming circular orbit
                shipRadius  = (float)orbitU.GetApogee();
                inclination = (float)orbitU.inclination;
            }
        }

        // check moon and ship orbit are co-planar
        if (Mathf.Abs(inclination - moonEllipse.inclination) > 1E-3)
        {
            Debug.LogWarning("Ship inclination and moon inclination are not equal.");
        }

        startPoint = new Vector3d(0, -shipRadius, 0);
        UpdateSoiPosition();
        UpdateStartPosition();
    }