Exemplo n.º 1
0
            public void CreatePrefab()
            {
                var templateBody = prefabBodies[templateName];

                var body = (PSystemBody)Instantiate(templateBody);

                body.celestialBody.bodyName = name;
                body.flightGlobalsIndex     = flightGlobalsIndex;

                //load from config (if any)
                orbit.Load(name);

                var parentBody = prefabBodies[orbit.referenceBody];

                if (body.celestialBody.orbitDriver != null)
                {
                    body.celestialBody.orbitDriver.orbit = new Orbit(orbit.inclination, orbit.eccentricity,
                                                                     orbit.semiMajorAxis, orbit.LAN,
                                                                     orbit.argumentOfPeriapsis, orbit.meanAnomalyAtEpoch, orbit.epoch, parentBody.celestialBody);

                    body.celestialBody.orbitDriver.UpdateOrbit();
                }


                LoadCB(body.celestialBody);


                body.children.Clear();
                parentBody.children.Add(body);
                body.enabled = false;

                prefabBodies[name] = body;
            }
Exemplo n.º 2
0
        public static void LoadOrbit(CelestialBody body)
        {
            var orbit = new PFOrbit();

            if (!orbit.Load(body.name))
            {
                return;
            }

            var parentBody = PFUtil.FindCB(body.name);

            if (body.orbitDriver != null)
            {
                body.orbitDriver.orbit = new Orbit(orbit.inclination, orbit.eccentricity,
                                                   orbit.semiMajorAxis, orbit.LAN,
                                                   orbit.argumentOfPeriapsis, orbit.meanAnomalyAtEpoch, orbit.epoch, body.orbit.referenceBody);// parentBody);

                body.orbitDriver.UpdateOrbit();
            }
        }
        public static void LoadOrbit(CelestialBody body)
        {
            var orbit = new PFOrbit();
            if(!orbit.Load(body.name))
                return;

            var parentBody = PFUtil.FindCB(body.name);
            if (body.orbitDriver != null)
            {
                body.orbitDriver.orbit = new Orbit(orbit.inclination, orbit.eccentricity,
                    orbit.semiMajorAxis, orbit.LAN,
                    orbit.argumentOfPeriapsis, orbit.meanAnomalyAtEpoch, orbit.epoch,body.orbit.referenceBody);// parentBody);

                body.orbitDriver.UpdateOrbit();
            }
        }