当前位置: 首页>>代码示例>>C#>>正文


C# Orbit.UpdateFromUT方法代码示例

本文整理汇总了C#中Orbit.UpdateFromUT方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.UpdateFromUT方法的具体用法?C# Orbit.UpdateFromUT怎么用?C# Orbit.UpdateFromUT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Orbit的用法示例。


在下文中一共展示了Orbit.UpdateFromUT方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HardsetOrbit

 static void HardsetOrbit(Orbit orbit, Orbit newOrbit)
 {
     orbit.inclination = newOrbit.inclination;
     orbit.eccentricity = newOrbit.eccentricity;
     orbit.semiMajorAxis = newOrbit.semiMajorAxis;
     orbit.LAN = newOrbit.LAN;
     orbit.argumentOfPeriapsis = newOrbit.argumentOfPeriapsis;
     orbit.meanAnomalyAtEpoch = newOrbit.meanAnomalyAtEpoch;
     orbit.epoch = newOrbit.epoch;
     orbit.referenceBody = newOrbit.referenceBody;
     orbit.Init ();
     orbit.UpdateFromUT (Planetarium.GetUniversalTime ());
 }
开发者ID:602p,项目名称:krpc,代码行数:13,代码来源:OrbitTools.cs

示例2: CopyOrbit

 //Credit where credit is due, Thanks hyperedit.
 public static void CopyOrbit(Orbit sourceOrbit, Orbit destinationOrbit)
 {
     destinationOrbit.inclination = sourceOrbit.inclination;
     destinationOrbit.eccentricity = sourceOrbit.eccentricity;
     destinationOrbit.semiMajorAxis = sourceOrbit.semiMajorAxis;
     destinationOrbit.LAN = sourceOrbit.LAN;
     destinationOrbit.argumentOfPeriapsis = sourceOrbit.argumentOfPeriapsis;
     destinationOrbit.meanAnomalyAtEpoch = sourceOrbit.meanAnomalyAtEpoch;
     destinationOrbit.epoch = sourceOrbit.epoch;
     destinationOrbit.referenceBody = sourceOrbit.referenceBody;
     destinationOrbit.Init();
     destinationOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
 }
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:14,代码来源:VesselUtil.cs

示例3: ApplyVesselUpdate

        private void ApplyVesselUpdate(VesselUpdate update)
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING)
            {
                return;
            }
            //Get updating player
            string updatePlayer = LockSystem.fetch.LockExists(update.vesselID) ? LockSystem.fetch.LockOwner(update.vesselID) : "Unknown";
            //Ignore updates to our own vessel if we are in flight and we aren't spectating
            if (!isSpectating && (FlightGlobals.fetch.activeVessel != null ? FlightGlobals.fetch.activeVessel.id.ToString() == update.vesselID : false) && HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                DarkLog.Debug("ApplyVesselUpdate - Ignoring update for active vessel from " + updatePlayer);
                return;
            }
            Vessel updateVessel = FlightGlobals.fetch.vessels.FindLast(v => v.id.ToString() == update.vesselID);
            if (updateVessel == null)
            {
                //DarkLog.Debug("ApplyVesselUpdate - Got vessel update for " + update.vesselID + " but vessel does not exist");
                return;
            }
            CelestialBody updateBody = FlightGlobals.Bodies.Find(b => b.bodyName == update.bodyName);
            if (updateBody == null)
            {
                DarkLog.Debug("ApplyVesselUpdate - updateBody not found");
                return;
            }

            //Rotation
            Quaternion updateRotation = new Quaternion(update.rotation[0], update.rotation[1], update.rotation[2], update.rotation[3]);
            updateVessel.SetRotation(updateVessel.mainBody.bodyTransform.rotation * updateRotation);

            //Position/Velocity
            if (update.isSurfaceUpdate)
            {
                //Get the new position/velocity
                Vector3d updatePostion = updateBody.GetWorldSurfacePosition(update.position[0], update.position[1], update.position[2]);
                Vector3d updateVelocity = updateBody.bodyTransform.rotation * new Vector3d(update.velocity[0], update.velocity[1], update.velocity[2]);
                //Figure out how far away we are if we can
                double updateDistance = Double.PositiveInfinity;
                if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (FlightGlobals.fetch.activeVessel != null))
                {
                    if (FlightGlobals.fetch.activeVessel.mainBody == updateVessel.mainBody)
                    {
                        Vector3d ourPos = FlightGlobals.fetch.activeVessel.mainBody.GetWorldSurfacePosition(FlightGlobals.fetch.activeVessel.latitude, FlightGlobals.fetch.activeVessel.longitude, FlightGlobals.fetch.activeVessel.altitude);
                        Vector3d theirPos = updateVessel.mainBody.GetWorldSurfacePosition(updateVessel.latitude, updateVessel.longitude, updateVessel.altitude);
                        updateDistance = Vector3.Distance(ourPos, theirPos);
                    }
                }
                bool isLoading = (updateDistance < Vessel.loadDistance) && !updateVessel.loaded;
                bool isUnpacking = (updateDistance < updateVessel.distanceUnpackThreshold) && updateVessel.packed && updateVessel.loaded;
                if (updateVessel.HoldPhysics)
                {
                    //DarkLog.Debug("Skipping update, physics held");
                    return;
                }
                //Don't set the position while the vessel is unpacking / loading - It doesn't apply properly.
                if (isUnpacking || isLoading)
                {
                    //DarkLog.Debug("Skipping update, isUnpacking: " + isUnpacking + " isLoading: " + isLoading);
                    return;
                }
                if (updateVessel.packed)
                {
                    updateVessel.latitude = update.position[0];
                    updateVessel.longitude = update.position[1];
                    updateVessel.altitude = update.position[2];
                    if (!updateVessel.LandedOrSplashed)
                    {
                        //Not landed but under 10km.
                        Vector3d orbitalPos = updatePostion - updateBody.position;
                        Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
                        Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
                        updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, Planetarium.GetUniversalTime());
                        updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
                        updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
                        /*
                        DarkLog.Debug("updateVelocity: " + (Vector3)updateVelocity + ", |vel| " + updateVelocity.magnitude);
                        DarkLog.Debug("surfaceOrbitVelDiff: " + (Vector3)surfaceOrbitVelDiff + ", |vel| " + surfaceOrbitVelDiff.magnitude);
                        */
                        /*
                        if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.fetch.activeVessel != null)
                        {
                            DarkLog.Debug("ourVel: " + (Vector3)FlightGlobals.fetch.activeVessel.orbitDriver.vel + ", |vel| " + updateVessel.orbitDriver.vel.magnitude);
                        }
                        DarkLog.Debug("theirVel: " + (Vector3)updateVessel.orbitDriver.vel + ", |vel| " + updateVessel.orbitDriver.vel.magnitude);
                        */
                    }
                }
                else
                {
                    Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
                    updateVessel.SetPosition(updatePostion, true);
                    updateVessel.ChangeWorldVelocity(velocityOffset);
                }
            }
            else
            {
                Orbit updateOrbit = new Orbit(update.orbit[0], update.orbit[1], update.orbit[2], update.orbit[3], update.orbit[4], update.orbit[5], update.orbit[6], updateBody);
                updateOrbit.Init();
                updateOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
//.........这里部分代码省略.........
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:101,代码来源:VesselWorker.cs

示例4: Apply


//.........这里部分代码省略.........
                double longitude = updateBody.GetLongitude(updatePostion);
                double altitude = updateBody.GetAltitude(updatePostion);
                updateVessel.latitude = latitude;
                updateVessel.longitude = longitude;
                updateVessel.altitude = altitude;
                updateVessel.protoVessel.latitude = latitude;
                updateVessel.protoVessel.longitude = longitude;
                updateVessel.protoVessel.altitude = altitude;

                if (updateVessel.packed)
                {
                    if (!updateVessel.LandedOrSplashed)
                    {
                        //Not landed but under 10km.
                        Vector3d orbitalPos = updatePostion - updateBody.position;
                        Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
                        Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
                        updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, Planetarium.GetUniversalTime());
                        updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
                        updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
                    }
                }
                else
                {
                    Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
                    updateVessel.SetPosition(updatePostion, true);
                    updateVessel.ChangeWorldVelocity(velocityOffset);
                }
            }
            else
            {
                Orbit updateOrbit = new Orbit(orbit[0], orbit[1], orbit[2], orbit[3], orbit[4], orbit[5], orbit[6], updateBody);
                updateOrbit.Init();
                updateOrbit.UpdateFromUT(Planetarium.GetUniversalTime());

                double latitude = updateBody.GetLatitude(updateOrbit.pos);
                double longitude = updateBody.GetLongitude(updateOrbit.pos);
                double altitude = updateBody.GetAltitude(updateOrbit.pos);
                updateVessel.latitude = latitude;
                updateVessel.longitude = longitude;
                updateVessel.altitude = altitude;
                updateVessel.protoVessel.latitude = latitude;
                updateVessel.protoVessel.longitude = longitude;
                updateVessel.protoVessel.altitude = altitude;

                if (updateVessel.packed)
                {
                    //The OrbitDriver update call will set the vessel position on the next fixed update
                    VesselUtil.CopyOrbit(updateOrbit, updateVessel.orbitDriver.orbit);
                    updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
                    updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
                }
                else
                {
                    //Vessel.SetPosition is full of fun and games. Avoid at all costs.
                    //Also, It's quite difficult to figure out the world velocity due to Krakensbane, and the reference frame.
                    Vector3d posDelta = updateOrbit.getPositionAtUT(Planetarium.GetUniversalTime()) - updateVessel.orbitDriver.orbit.getPositionAtUT(Planetarium.GetUniversalTime());
                    Vector3d velDelta = updateOrbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy - updateVessel.orbitDriver.orbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy;
                    //Vector3d velDelta = updateOrbit.vel.xzy - updateVessel.orbitDriver.orbit.vel.xzy;
                    updateVessel.Translate(posDelta);
                    updateVessel.ChangeWorldVelocity(velDelta);
                }
            }

            //Rotation
            Quaternion unfudgedRotation = new Quaternion(rotation[0], rotation[1], rotation[2], rotation[3]);
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:67,代码来源:VesselUpdate.cs

示例5: OnSerializeNetworkView

 public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     var vessel = GetComponent<Vessel>();
     if (stream.isWriting)
     {
         var eccentricity = (float)vessel.orbit.eccentricity;
         var semiMajorAxis = (float)vessel.orbit.semiMajorAxis;
         var inclination = (float)vessel.orbit.inclination;
         var lan = (float)vessel.orbit.LAN;
         var argumentOfPeriapsis = (float)vessel.orbit.argumentOfPeriapsis;
         var meanAnomalyAtEpoch = (float)vessel.orbit.meanAnomalyAtEpoch;
         var epoch = (float)vessel.orbit.epoch;
         var bodyId = FlightGlobals.Bodies.IndexOf(vessel.orbit.referenceBody);
         stream.Serialize(ref eccentricity, float.Epsilon);
         stream.Serialize(ref semiMajorAxis, float.Epsilon);
         stream.Serialize(ref inclination, float.Epsilon);
         stream.Serialize(ref lan, float.Epsilon);
         stream.Serialize(ref argumentOfPeriapsis, float.Epsilon);
         stream.Serialize(ref meanAnomalyAtEpoch, float.Epsilon);
         stream.Serialize(ref epoch, float.Epsilon);
         stream.Serialize(ref bodyId);
     }
     else
     {
         float eccentricity = 0f, semiMajorAxis = 0f, inclination = 0f, lan = 0f, argumentOfPeriapsis = 0f;
         var meanAnomalyAtEpoch = 0f;
         var epoch = 0f;
         var bodyId = 0;
         stream.Serialize(ref eccentricity, float.Epsilon);
         stream.Serialize(ref semiMajorAxis, float.Epsilon);
         stream.Serialize(ref inclination, float.Epsilon);
         stream.Serialize(ref lan, float.Epsilon);
         stream.Serialize(ref argumentOfPeriapsis, float.Epsilon);
         stream.Serialize(ref meanAnomalyAtEpoch, float.Epsilon);
         stream.Serialize(ref epoch, float.Epsilon);
         stream.Serialize(ref bodyId);
         var newOrbit = new Orbit(inclination, eccentricity, semiMajorAxis, lan, argumentOfPeriapsis, meanAnomalyAtEpoch, epoch, FlightGlobals.Bodies[bodyId]);
         newOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
         if (vessel.packed)
         {
             if (vessel.Landed)
                 vessel.Landed = false;
             if (vessel.Splashed)
                 vessel.Splashed = false;
             vessel.orbit.UpdateFromOrbitAtUT(newOrbit, Planetarium.GetUniversalTime(), newOrbit.referenceBody);
         }
         else
         {
             vessel.SetPosition(newOrbit.pos);
             vessel.SetWorldVelocity(newOrbit.vel);
         }
     }
 }
开发者ID:Arduinology,项目名称:Khylib,代码行数:53,代码来源:Kestrel.cs

示例6: DirectSet

 public static void DirectSet(this Orbit orbit, Orbit newOrbit, double time)
 {
     newOrbit.UpdateFromUT(time);
     orbit.inclination = newOrbit.inclination;
     orbit.eccentricity = newOrbit.eccentricity;
     orbit.semiMajorAxis = newOrbit.semiMajorAxis;
     orbit.LAN = newOrbit.LAN;
     orbit.argumentOfPeriapsis = newOrbit.argumentOfPeriapsis;
     orbit.meanAnomalyAtEpoch = newOrbit.meanAnomalyAtEpoch;
     orbit.epoch = newOrbit.epoch;
     orbit.referenceBody = newOrbit.referenceBody;
     orbit.UpdateFromUT(Planetarium.GetUniversalTime());
 }
开发者ID:Arduinology,项目名称:Khylib,代码行数:13,代码来源:HyperEdit.cs

示例7: IndirectSet

 public static void IndirectSet(this Orbit orbit, Orbit newOrbit, double time)
 {
     newOrbit.UpdateFromUT(time);
     orbit.UpdateFromOrbitAtUT(newOrbit, time, newOrbit.referenceBody);
 }
开发者ID:Arduinology,项目名称:Khylib,代码行数:5,代码来源:HyperEdit.cs


注:本文中的Orbit.UpdateFromUT方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。