Exemplo n.º 1
0
 /// <summary>
 /// Construct from a KSP celestial body object.
 /// </summary>
 public CelestialBody(global::CelestialBody body)
 {
     InternalBody = body;
     if (body.name != Planetarium.fetch.Sun.name)
     {
         orbit = new Orbit(body);
     }
 }
Exemplo n.º 2
0
 internal static ReferenceFrame Orbital(global::CelestialBody body)
 {
     if (body == body.referenceBody || body.orbit == null)
     {
         throw new ArgumentException("CelestialBody '" + body.name + "' does not orbit anything");
     }
     return(new ReferenceFrame(ReferenceFrameType.CelestialBodyOrbital, body));
 }
Exemplo n.º 3
0
 internal Orbit(global::CelestialBody body)
 {
     if (body == body.referenceBody)
     {
         throw new ArgumentException("Body does not orbit anything");
     }
     InternalOrbit = body.GetOrbit();
 }
Exemplo n.º 4
0
        private void _pushBody(global::CelestialBody body)
        {
            celestialBodies.Add(new game.CelestialBody(this, body));

            foreach (var subbody in body.orbitingBodies)
            {
                _pushBody(subbody);
            }
        }
Exemplo n.º 5
0
        public void update(global::CelestialBody body)
        {
            name = body.GetName();

            position = new Vector3(body.position);
            rotation = new Quaternion(body.rotation);

            radius = body.Radius;

            mass          = body.Mass;
            gravParameter = body.gravParameter;
        }
Exemplo n.º 6
0
 ReferenceFrame(
     Type type, global::CelestialBody body = null, global::Vessel vessel = null,
     ManeuverNode node = null, Part part = null, ModuleDockingNode dockingPort = null)
 {
     this.type     = type;
     this.body     = body;
     this.vesselId = vessel != null ? vessel.id : Guid.Empty;
     this.node     = node;
     //TODO: is it safe to use a part id of 0 to mean no part?
     this.partId      = part != null ? part.flightID : 0;
     this.dockingPort = dockingPort;
 }
Exemplo n.º 7
0
 public static Vector3d GetWorldVelocity(this global::CelestialBody body)
 {
     if (body != body.referenceBody)
     {
         // Body orbits something
         return(body.GetOrbit().GetVel());
     }
     else
     {
         // Body does not orbit anything
         // Get a body that orbits the sun
         var orbitingBody = FlightGlobals.Bodies.Find(b => b.name != "Sun" && b.GetOrbit().referenceBody == body);
         var orbit        = orbitingBody.GetOrbit();
         // Compute the velocity of the sun in world space from this body
         // Can't be done for from the sun object as it has no orbit object
         return(orbit.GetVel() - orbit.GetRelativeVel());
     }
 }
Exemplo n.º 8
0
 ReferenceFrame(
     ReferenceFrameType type, global::CelestialBody body = null, global::Vessel vessel = null,
     ManeuverNode node             = null, Part part             = null, ModuleDockingNode dockingPort = null,
     Thruster thruster             = null, ReferenceFrame parent = null,
     ReferenceFrame hybridPosition = null, ReferenceFrame hybridRotation        = null,
     ReferenceFrame hybridVelocity = null, ReferenceFrame hybridAngularVelocity = null)
 {
     this.type = type;
     this.body = body;
     vesselId  = vessel != null ? vessel.id : Guid.Empty;
     this.node = node;
     //TODO: is it safe to use a part id of 0 to mean no part?
     if (part != null)
     {
         partId = part.flightID;
     }
     this.dockingPort           = dockingPort;
     this.thruster              = thruster;
     this.parent                = parent;
     this.hybridPosition        = hybridPosition;
     this.hybridRotation        = hybridRotation;
     this.hybridVelocity        = hybridVelocity;
     this.hybridAngularVelocity = hybridAngularVelocity;
 }
Exemplo n.º 9
0
 internal static ReferenceFrame NonRotating(global::CelestialBody body)
 {
     return(new ReferenceFrame(ReferenceFrameType.CelestialBodyNonRotating, body, null, null));
 }
Exemplo n.º 10
0
 internal static ReferenceFrame Object(global::CelestialBody body)
 {
     return(new ReferenceFrame(ReferenceFrameType.CelestialBody, body));
 }
Exemplo n.º 11
0
 public CelestialBody(Universe universe, global::CelestialBody body) : this(universe)
 {
     update(body);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Vector from center of given body to north pole of body being orbited, in world space.
        /// </summary>
        static Vector3d ToNorthPole(global::CelestialBody body)
        {
            var parent = body.referenceBody;

            return(parent.position + (((Vector3d)parent.transform.up) * parent.Radius) - body.position);
        }