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


C# Vessel.GetTransform方法代码示例

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


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

示例1: GetHeading

        public static float GetHeading(Vessel vessel)
        {
            var up = vessel.upAxis;
            var north = GetNorthVector(vessel);
            var headingQ = Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(vessel.GetTransform().rotation) * Quaternion.LookRotation(north, up));

            return headingQ.eulerAngles.y;
        }
开发者ID:kendrome,项目名称:KOS,代码行数:8,代码来源:VesselUtils.cs

示例2: updateHeadingPitchRollField

        //Borrowed from MechJeb2 & Telemachus
        public static Quaternion updateHeadingPitchRollField(Vessel v)
        {
            Vector3d CoM, north, up;
            Quaternion rotationSurface;

            CoM = v.findWorldCenterOfMass();
            up = (CoM - v.mainBody.position).normalized;

            north = Vector3d.Exclude(up, (v.mainBody.position + v.mainBody.transform.up * (float)v.mainBody.Radius) - CoM).normalized;

            rotationSurface = Quaternion.LookRotation(north, up);
            return Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(v.GetTransform().rotation) * rotationSurface);
        }
开发者ID:pcwilcox,项目名称:GoAtThrottleUp,代码行数:14,代码来源:helpers.cs

示例3: GetTorque

        /// <summary>
        /// Returns the torque the ship can exert around its center of mass
        /// </summary>
        /// <returns>The torque in N m, around the (pitch, roll, yaw) axes.</returns>
        /// <param name="vessel">The ship whose torque should be measured.</param>
        /// <param name="thrust">The ship's throttle setting, on a scale of 0 to 1.</param>
        public static Vector3d GetTorque(Vessel vessel, float thrust)
        {
            // Do everything in vessel coordinates
            var centerOfMass = vessel.findLocalCenterOfMass();

            // Don't assume any particular symmetry for the vessel
            double pitch = 0, roll = 0, yaw = 0;

            foreach (Part part in vessel.parts)
            {
                foreach (PartModule module in part.Modules)
                {
                    if (!module.isEnabled)
                        continue;

                    var reactionWheelModule = module as ModuleReactionWheel;
                    var rcsModule = module as ModuleRCS;
                    if (reactionWheelModule != null && reactionWheelModule.wheelState == ModuleReactionWheel.WheelState.Active)
                    {
                        pitch += reactionWheelModule.PitchTorque;
                        roll += reactionWheelModule.RollTorque;
                        yaw += reactionWheelModule.YawTorque;
                    }
                        // Is there a more direct way to see if RCS is enabled? module.isEnabled doesn't work...
                    else if (rcsModule != null && vessel.ActionGroups[KSPActionGroup.RCS])
                    {
                        var vesselTransform = vessel.GetTransform();
                        foreach (Transform thruster in rcsModule.thrusterTransforms)
                        {
                            // Avoids problems with part.Rigidbody.centerOfMass; should also give better
                            //  support for RCS units integrated into larger parts
                            Vector3d thrusterOffset = vesselTransform.InverseTransformPoint(thruster.position) - centerOfMass;
                            /* Code by sarbian, shamelessly copied from MechJeb */
                            Vector3d thrusterThrust = vesselTransform.InverseTransformDirection(-thruster.up.normalized) * rcsModule.thrusterPower;
                            Vector3d thrusterTorque = Vector3.Cross(thrusterOffset, thrusterThrust);
                            /* end sarbian's code */

                            // This overestimates the usable torque, but that doesn't change the final behavior much
                            pitch += (float)Math.Abs(thrusterTorque.x);
                            roll += (float)Math.Abs(thrusterTorque.y);
                            yaw += (float)Math.Abs(thrusterTorque.z);
                        }
                    }
                }

                Vector3d gimbal = GetThrustTorque(part, vessel) * thrust;
                pitch += gimbal.x;
                roll += gimbal.y;
                yaw += gimbal.z;
            }

            return new Vector3d(pitch, roll, yaw);
        }
开发者ID:icedown,项目名称:RemoteTech,代码行数:59,代码来源:FlightCore.cs

示例4: GetTrueMoI

        /// <summary>
        /// Returns a more accurate moment of inertia than Vessel.findLocalMOI()
        /// </summary>
        // Copied from MechJeb master on June 27, 2014
        // TODO: cache moment if inertia and update only when ship mass changes?
        private static Vector3d GetTrueMoI(Vessel vessel)
        {
            var inertiaTensor = new Matrix3x3();
            var centerOfMass = vessel.findWorldCenterOfMass();

            foreach (Part p in vessel.parts)
            {
                if (p.Rigidbody == null) continue;

                //Compute the contributions to the vessel inertia tensor due to the part inertia tensor
                Vector3d principalMoments = p.Rigidbody.inertiaTensor;
                Quaternion princAxesRot = Quaternion.Inverse(vessel.GetTransform().rotation) * p.transform.rotation * p.Rigidbody.inertiaTensorRotation;
                Quaternion invPrincAxesRot = Quaternion.Inverse(princAxesRot);

                for (int i = 0; i < 3; i++)
                {
                    Vector3d iHat = Vector3d.zero;
                    iHat[i] = 1;
                    for (int j = 0; j < 3; j++)
                    {
                        Vector3d jHat = Vector3d.zero;
                        jHat[j] = 1;
                        inertiaTensor[i, j] += Vector3d.Dot(iHat, princAxesRot * Vector3d.Scale(principalMoments, invPrincAxesRot * jHat));
                    }
                }

                //Compute the contributions to the vessel inertia tensor due to the part mass and position
                double partMass = p.mass + p.GetResourceMass();
                Vector3 partPosition = vessel.GetTransform().InverseTransformDirection(p.Rigidbody.worldCenterOfMass - centerOfMass);

                for (int i = 0; i < 3; i++)
                {
                    inertiaTensor[i, i] += partMass * partPosition.sqrMagnitude;

                    for (int j = 0; j < 3; j++)
                    {
                        inertiaTensor[i, j] += -partMass * partPosition[i] * partPosition[j];
                    }
                }
            }

            return new Vector3d(inertiaTensor[0, 0], inertiaTensor[1, 1], inertiaTensor[2, 2]);
        }
开发者ID:icedown,项目名称:RemoteTech,代码行数:48,代码来源:FlightCore.cs

示例5: CheckVessel


//.........这里部分代码省略.........
        if (rootPartBody != null)
        {
            // But how much is "too much"? Well, it probably has something to do
            // with the ship's moment of inertia (MoI). Let's say the distance
            // 'd' that the CoM is allowed to shift without a reset is:
            //
            //      d = moi * x + c
            //
            // where 'moi' is the magnitude of the ship's moment of inertia and
            // 'x' and 'c' are tuning parameters to be determined.
            //
            // Using a few actual KSP ships, I burned RCS fuel (or moved fuel
            // from one tank to another) to see how far the CoM could shift
            // before the the rotation error on translation became annoying.
            // I came up with roughly:
            //
            //      d         moi
            //      0.005    2.34
            //      0.04    11.90
            //      0.07    19.96
            //
            // I then halved each 'd' value, because we'd like to address this
            // problem -before- it becomes annoying. Least-squares linear
            // regression on the (moi, d/2) pairs gives the following (with
            // adjusted R^2 = 0.999966):
            //
            //      moi = 542.268 d + 1.00654
            //      d = (moi - 1) / 542
            //
            // So the numbers below have some basis in reality. =)

            // Assume MoI magnitude is always >=2.34, since that's all I tested.
            comErrorThreshold = (Math.Max(state.MoI.magnitude, 2.34) - 1) / 542;

            Vector3 comState = state.CoM;
            Vector3 rootPos = state.rootPartPos;
            Vector3 com = WorldToVessel(vessel, comState - rootPos);
            double thisComErr = (lastCoM - com).magnitude;
            maxComError = Math.Max(maxComError, thisComErr);
            _comError.value = thisComErr;
            if (_comError > comErrorThreshold)
            {
                lastCoM = com;
                changed = true;
            }
        }

        if (!changed) return;

        // Something about the vessel has changed. We need to reset everything.

        lastDisabled.Clear();

        // ModuleRCS has no originalThrusterPower attribute, so we have
        // to explicitly reset it.
        ResetThrusterForces();

        // Rebuild the list of thrusters.
        var ts = new List<RCSSolver.Thruster>();
        foreach (Part p in vessel.parts)
        {
            foreach (ModuleRCS pm in p.Modules.OfType<ModuleRCS>())
            {
                if (!pm.isEnabled)
                {
                    // Keep track of this module so we'll know if it's enabled.
                    lastDisabled.Add(pm);
                }
                else if (p.Rigidbody != null && !pm.isJustForShow)
                {
                    Vector3 pos = VesselRelativePos(state.CoM, vessel, p);

                    // Create a single RCSSolver.Thruster for this part. This
                    // requires some assumptions about how the game's RCS code will
                    // drive the individual thrusters (which we can't control).

                    Vector3[] thrustDirs = new Vector3[pm.thrusterTransforms.Count];
                    Quaternion rotationQuat = Quaternion.Inverse(vessel.GetTransform().rotation);
                    for (int i = 0; i < pm.thrusterTransforms.Count; i++)
                    {
                        thrustDirs[i] = (rotationQuat * -pm.thrusterTransforms[i].up).normalized;
                    }

                    ts.Add(new RCSSolver.Thruster(pos, thrustDirs, p, pm));
                }
            }
        }
        callerThrusters.Clear();
        originalThrottles = new double[ts.Count];
        zeroThrottles = new double[ts.Count];
        for (int i = 0; i < ts.Count; i++)
        {
            originalThrottles[i] = ts[i].originalForce;
            zeroThrottles[i] = 0;
            callerThrusters.Add(ts[i]);
        }

        thrusters = ts;
        ClearResults();
    }
开发者ID:kext,项目名称:MechJeb2,代码行数:101,代码来源:RCSSolver.cs

示例6: WorldToVessel

 private static Vector3 WorldToVessel(Vessel vessel, Vector3 pos)
 {
     // Translate to the vessel's reference frame.
     return Quaternion.Inverse(vessel.GetTransform().rotation) * pos;
 }
开发者ID:kext,项目名称:MechJeb2,代码行数:5,代码来源:RCSSolver.cs

示例7: Update

        public void Update(Vessel vessel)
        {
            if (vessel.rigidbody == null) return; //if we try to update before rigidbodies exist we spam the console with NullPointerExceptions.
            //if (vessel.packed) return;

            time = Planetarium.GetUniversalTime();
            deltaT = TimeWarp.fixedDeltaTime;

            CoM = vessel.findWorldCenterOfMass();
            MoI = vessel.findLocalMOI(CoM);
            up = (CoM - vessel.mainBody.position).normalized;

            Rigidbody rigidBody = vessel.rootPart.rigidbody;
            if (rigidBody != null) rootPartPos = rigidBody.position;

            north = Vector3d.Exclude(up, (vessel.mainBody.position + vessel.mainBody.transform.up * (float)vessel.mainBody.Radius) - CoM).normalized;
            east = vessel.mainBody.getRFrmVel(CoM).normalized;
            forward = vessel.GetTransform().up;
            rotationSurface = Quaternion.LookRotation(north, up);
            rotationVesselSurface = Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(vessel.GetTransform().rotation) * rotationSurface);

            velocityVesselOrbit = vessel.orbit.GetVel();
            velocityVesselOrbitUnit = velocityVesselOrbit.normalized;
            velocityVesselSurface = velocityVesselOrbit - vessel.mainBody.getRFrmVel(CoM);
            velocityVesselSurfaceUnit = velocityVesselSurface.normalized;
            velocityMainBodySurface = rotationSurface * velocityVesselSurface;

            horizontalOrbit = Vector3d.Exclude(up, velocityVesselOrbit).normalized;
            horizontalSurface = Vector3d.Exclude(up, velocityVesselSurface).normalized;

            angularVelocity = Quaternion.Inverse(vessel.GetTransform().rotation) * vessel.rigidbody.angularVelocity;

            radialPlusSurface = Vector3d.Exclude(velocityVesselSurface, up).normalized;
            radialPlus = Vector3d.Exclude(velocityVesselOrbit, up).normalized;
            normalPlusSurface = -Vector3d.Cross(radialPlusSurface, velocityVesselSurfaceUnit);
            normalPlus = -Vector3d.Cross(radialPlus, velocityVesselOrbitUnit);

            gravityForce = FlightGlobals.getGeeForceAtPosition(CoM);
            localg = gravityForce.magnitude;

            speedOrbital.value = velocityVesselOrbit.magnitude;
            speedSurface.value = velocityVesselSurface.magnitude;
            speedVertical.value = Vector3d.Dot(velocityVesselSurface, up);
            speedSurfaceHorizontal.value = (velocityVesselSurface - (speedVertical * up)).magnitude;
            speedOrbitHorizontal = (velocityVesselOrbit - (speedVertical * up)).magnitude;

            vesselHeading.value = rotationVesselSurface.eulerAngles.y;
            vesselPitch.value = (rotationVesselSurface.eulerAngles.x > 180) ? (360.0 - rotationVesselSurface.eulerAngles.x) : -rotationVesselSurface.eulerAngles.x;
            vesselRoll.value = (rotationVesselSurface.eulerAngles.z > 180) ? (rotationVesselSurface.eulerAngles.z - 360.0) : rotationVesselSurface.eulerAngles.z;

            altitudeASL.value = vessel.mainBody.GetAltitude(CoM);
            RaycastHit sfc;
            if (Physics.Raycast(CoM, -up, out sfc, (float)altitudeASL + 10000.0F, 1 << 15))
            {
                altitudeTrue.value = sfc.distance;
            }
            else if (vessel.mainBody.pqsController != null)
            {
                // from here: http://kerbalspaceprogram.com/forum/index.php?topic=10324.msg161923#msg161923
                altitudeTrue.value = vessel.mainBody.GetAltitude(CoM) - (vessel.mainBody.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(vessel.mainBody.GetLongitude(CoM), Vector3d.down) * QuaternionD.AngleAxis(vessel.mainBody.GetLatitude(CoM), Vector3d.forward) * Vector3d.right) - vessel.mainBody.pqsController.radius);
            }
            else
            {
                altitudeTrue.value = vessel.mainBody.GetAltitude(CoM);
            }

            double surfaceAltitudeASL = altitudeASL - altitudeTrue;
            altitudeBottom = altitudeTrue;
            foreach (Part p in vessel.parts)
            {
                if (p.collider != null)
                {
                    Vector3d bottomPoint = p.collider.ClosestPointOnBounds(vessel.mainBody.position);
                    double partBottomAlt = vessel.mainBody.GetAltitude(bottomPoint) - surfaceAltitudeASL;
                    altitudeBottom = Math.Max(0, Math.Min(altitudeBottom, partBottomAlt));
                }
            }

            double atmosphericPressure = FlightGlobals.getStaticPressure(altitudeASL, vessel.mainBody);
            if (atmosphericPressure < vessel.mainBody.atmosphereMultiplier * 1e-6) atmosphericPressure = 0;
            atmosphericDensity = FlightGlobals.getAtmDensity(atmosphericPressure);
            atmosphericDensityGrams = atmosphericDensity * 1000;

            orbitApA.value = vessel.orbit.ApA;
            orbitPeA.value = vessel.orbit.PeA;
            orbitPeriod.value = vessel.orbit.period;
            orbitTimeToAp.value = vessel.orbit.timeToAp;
            if (vessel.orbit.eccentricity < 1) orbitTimeToPe.value = vessel.orbit.timeToPe;
            else orbitTimeToPe.value = -vessel.orbit.meanAnomaly / (2 * Math.PI / vessel.orbit.period);
            orbitLAN.value = vessel.orbit.LAN;
            orbitArgumentOfPeriapsis.value = vessel.orbit.argumentOfPeriapsis;
            orbitInclination.value = vessel.orbit.inclination;
            orbitEccentricity.value = vessel.orbit.eccentricity;
            orbitSemiMajorAxis.value = vessel.orbit.semiMajorAxis;
            latitude.value = vessel.mainBody.GetLatitude(CoM);
            longitude.value = MuUtils.ClampDegrees180(vessel.mainBody.GetLongitude(CoM));

            if (vessel.mainBody != Planetarium.fetch.Sun)
            {
                Vector3d delta = vessel.mainBody.getPositionAtUT(Planetarium.GetUniversalTime() + 1) - vessel.mainBody.getPositionAtUT(Planetarium.GetUniversalTime() - 1);
//.........这里部分代码省略.........
开发者ID:ramfreak04,项目名称:MechJeb2,代码行数:101,代码来源:VesselState.cs

示例8: Update

        public void Update(Vessel vessel)
        {
            if (vessel.rigidbody == null) return; //if we try to update before rigidbodies exist we spam the console with NullPointerExceptions.
            //if (vessel.packed) return;

            time = Planetarium.GetUniversalTime();
            deltaT = TimeWarp.fixedDeltaTime;

            CoM = vessel.findWorldCenterOfMass();
            up = (CoM - vessel.mainBody.position).normalized;

            Rigidbody rigidBody = vessel.rootPart.rigidbody;
            if (rigidBody != null) rootPartPos = rigidBody.position;

            north = Vector3d.Exclude(up, (vessel.mainBody.position + vessel.mainBody.transform.up * (float)vessel.mainBody.Radius) - CoM).normalized;
            east = vessel.mainBody.getRFrmVel(CoM).normalized;
            forward = vessel.GetTransform().up;
            rotationSurface = Quaternion.LookRotation(north, up);
            rotationVesselSurface = Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(vessel.GetTransform().rotation) * rotationSurface);

            velocityVesselOrbit = vessel.orbit.GetVel();
            velocityVesselOrbitUnit = velocityVesselOrbit.normalized;
            velocityVesselSurface = velocityVesselOrbit - vessel.mainBody.getRFrmVel(CoM);
            velocityVesselSurfaceUnit = velocityVesselSurface.normalized;
            velocityMainBodySurface = rotationSurface * velocityVesselSurface;

            horizontalOrbit = Vector3d.Exclude(up, velocityVesselOrbit).normalized;
            horizontalSurface = Vector3d.Exclude(up, velocityVesselSurface).normalized;

            angularVelocity = Quaternion.Inverse(vessel.GetTransform().rotation) * vessel.rigidbody.angularVelocity;

            radialPlusSurface = Vector3d.Exclude(velocityVesselSurface, up).normalized;
            radialPlus = Vector3d.Exclude(velocityVesselOrbit, up).normalized;
            normalPlusSurface = -Vector3d.Cross(radialPlusSurface, velocityVesselSurfaceUnit);
            normalPlus = -Vector3d.Cross(radialPlus, velocityVesselOrbitUnit);

            gravityForce = FlightGlobals.getGeeForceAtPosition(CoM);
            localg = gravityForce.magnitude;

            speedOrbital.value = velocityVesselOrbit.magnitude;
            speedSurface.value = velocityVesselSurface.magnitude;
            speedVertical.value = Vector3d.Dot(velocityVesselSurface, up);
            speedSurfaceHorizontal.value = (velocityVesselSurface - (speedVertical * up)).magnitude;
            speedOrbitHorizontal = (velocityVesselOrbit - (speedVertical * up)).magnitude;

            vesselHeading.value = rotationVesselSurface.eulerAngles.y;
            vesselPitch.value = (rotationVesselSurface.eulerAngles.x > 180) ? (360.0 - rotationVesselSurface.eulerAngles.x) : -rotationVesselSurface.eulerAngles.x;
            vesselRoll.value = (rotationVesselSurface.eulerAngles.z > 180) ? (rotationVesselSurface.eulerAngles.z - 360.0) : rotationVesselSurface.eulerAngles.z;

            altitudeASL.value = vessel.mainBody.GetAltitude(CoM);
            RaycastHit sfc;
            if (Physics.Raycast(CoM, -up, out sfc, (float)altitudeASL + 10000.0F, 1 << 15))
            {
                altitudeTrue.value = sfc.distance;
            }
            else if (vessel.mainBody.pqsController != null)
            {
                // from here: http://kerbalspaceprogram.com/forum/index.php?topic=10324.msg161923#msg161923
                altitudeTrue.value = vessel.mainBody.GetAltitude(CoM) - (vessel.mainBody.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(vessel.mainBody.GetLongitude(CoM), Vector3d.down) * QuaternionD.AngleAxis(vessel.mainBody.GetLatitude(CoM), Vector3d.forward) * Vector3d.right) - vessel.mainBody.pqsController.radius);
            }
            else
            {
                altitudeTrue.value = vessel.mainBody.GetAltitude(CoM);
            }

            double surfaceAltitudeASL = altitudeASL - altitudeTrue;
            altitudeBottom = altitudeTrue;
            foreach (Part p in vessel.parts)
            {
                if (p.collider != null)
                {
                    Vector3d bottomPoint = p.collider.ClosestPointOnBounds(vessel.mainBody.position);
                    double partBottomAlt = vessel.mainBody.GetAltitude(bottomPoint) - surfaceAltitudeASL;
                    altitudeBottom = Math.Max(0, Math.Min(altitudeBottom, partBottomAlt));
                }
            }

            double atmosphericPressure = FlightGlobals.getStaticPressure(altitudeASL, vessel.mainBody);
            if (atmosphericPressure < vessel.mainBody.atmosphereMultiplier * 1e-6) atmosphericPressure = 0;
            atmosphericDensity = FlightGlobals.getAtmDensity(atmosphericPressure);
            atmosphericDensityGrams = atmosphericDensity * 1000;

            orbitApA.value = vessel.orbit.ApA;
            orbitPeA.value = vessel.orbit.PeA;
            orbitPeriod.value = vessel.orbit.period;
            orbitTimeToAp.value = vessel.orbit.timeToAp;
            if (vessel.orbit.eccentricity < 1) orbitTimeToPe.value = vessel.orbit.timeToPe;
            else orbitTimeToPe.value = -vessel.orbit.meanAnomaly / (2 * Math.PI / vessel.orbit.period);
            orbitLAN.value = vessel.orbit.LAN;
            orbitArgumentOfPeriapsis.value = vessel.orbit.argumentOfPeriapsis;
            orbitInclination.value = vessel.orbit.inclination;
            orbitEccentricity.value = vessel.orbit.eccentricity;
            orbitSemiMajorAxis.value = vessel.orbit.semiMajorAxis;
            latitude.value = vessel.mainBody.GetLatitude(CoM);
            longitude.value = MuUtils.ClampDegrees180(vessel.mainBody.GetLongitude(CoM));

            if (vessel.mainBody != Planetarium.fetch.Sun)
            {
                Vector3d delta = vessel.mainBody.getPositionAtUT(Planetarium.GetUniversalTime() + 1) - vessel.mainBody.getPositionAtUT(Planetarium.GetUniversalTime() - 1);
                Vector3d plUp = Vector3d.Cross(vessel.mainBody.getPositionAtUT(Planetarium.GetUniversalTime()) - vessel.mainBody.referenceBody.getPositionAtUT(Planetarium.GetUniversalTime()), vessel.mainBody.getPositionAtUT(Planetarium.GetUniversalTime() + vessel.mainBody.orbit.period / 4) - vessel.mainBody.referenceBody.getPositionAtUT(Planetarium.GetUniversalTime() + vessel.mainBody.orbit.period / 4)).normalized;
//.........这里部分代码省略.........
开发者ID:KaiSforza,项目名称:MechJeb2,代码行数:101,代码来源:VesselState.cs

示例9: getVesselState


//.........这里部分代码省略.........
            // TODO explain the coordinate system further
            RV.Add(r.y);
            RV.Add(r.x);
               	RV.Add(r.z);

               	RV.Add(v.y);
               	RV.Add(v.x);
               	RV.Add(v.z);

            buffer.Add ("rv", RV);	// # 8

            Vector3d forward = vessel.ReferenceTransform.forward;
            Vector3d up = vessel.ReferenceTransform.up;
            List<double> fwup = new List<double> ();
            fwup.Add (forward.y);
            fwup.Add (forward.x);
            fwup.Add (forward.z);
            fwup.Add (up.y);
            fwup.Add (up.x);
            fwup.Add (up.z);
            Debug.Log ("STEP_XXX_4");
            buffer.Add ("fwup", fwup);
            //Debug.Log ("SPEED1: " + orbit.getOrbitalVelocityAtUT (Planetarium.GetUniversalTime ()).ToString ()); // Tis is currently used velocity
            //Debug.Log ("SPEED2: " + orbit.GetFrameVelAtUT (Planetarium.GetUniversalTime ()).ToString ());
            //Debug.Log ("SPEED3: " + orbit.GetRelativeVel ().ToString () );
            // GetRelativeVel seems to be OK to get the correct position

            //Debug.Log ("SPEED4: " + orbit.GetRotFrameVel ( ().ToString () );

            //Debug.Log ("POSIT1: " + orbit.getPositionAtUT(Planetarium.GetUniversalTime ()).ToString ());
            //Debug.Log ("POSIT2: " + orbit.getRelativePositionAtUT(Planetarium.GetUniversalTime ()).ToString ()); // Tis is currently used pos
            //Debug.Log ("POSIT3: " + orbit.getTruePositionAtUT (Planetarium.GetUniversalTime ()).ToString ());
            //Debug.Log ("POSIT4: " + orbit.pos.xzy.ToString ());

            //Debug.Log ("FRAMEROT: " + Planetarium.FrameIsRotating ().ToString ());
            //Debug.Log ("FRAMEROT: " + Planetarium.ZupRotation.ToString ());
            //Debug.Log ("FRAMEROT: " + Planetarium.Rotation.ToString ());

            //Debug.Log ("Framerot: " + Planetarium.InverseRotAngle.ToString ());

            //buffer.Add (orbit.epoch.ToString ());
            List<double> elements = new List<double> ();

            elements.Add (orbit.semiMajorAxis);
            elements.Add (orbit.eccentricity);
            elements.Add (orbit.inclination);
            elements.Add (orbit.LAN);
            elements.Add (orbit.argumentOfPeriapsis); // # 9

            //buffer.Add (orbit.meanAnomalyAtEpoch.ToString ());

            buffer.Add ("elements", elements);

            buffer.Add ("mt", vessel.missionTime); // # 10
            buffer.Add ("atm_density", vessel.atmDensity); // # 11
            buffer.Add ("geeforce", vessel.geeForce); // # 12
            buffer.Add ("obt_v", vessel.obt_velocity.magnitude); // # 13
            buffer.Add ("srf_v", vessel.srf_velocity.magnitude); // # 14
            buffer.Add ("vrt_v", vessel.verticalSpeed);   // # 15
            buffer.Add ("pressure_s", vessel.staticPressure); // # 16
            Debug.Log ("STEP_XXX_5");
            if (vessel.Parts.Count () > 0) {
                Part part = vessel.Parts [0];
                buffer.Add ("pressure_d", part.dynamicPressureAtm); // # 17
                buffer.Add ("temperature", part.temperature); // #  18
            } else {
                buffer.Add ("pressure_d", 0);
                buffer.Add ("temperature", 0);
            }

            buffer.Add ("alt", vessel.altitude); // # 19
            buffer.Add ("alt_srf", vessel.heightFromSurface); // # 20
            buffer.Add ("alt_ter", vessel.heightFromTerrain); // # 21

            buffer.Add ("alt_per", orbit.PeA);
            buffer.Add ("alt_apo", orbit.ApA);
            //vessel.GetTransform().rotation
            Vector3 roteul = vessel.GetTransform ().rotation.eulerAngles;
            Vector3 rotinv = Quaternion.Inverse(vessel.GetTransform ().rotation).eulerAngles;
            List<double> rot = new List<double> ();
            rot.Add (roteul.y);
            rot.Add (roteul.x);
            rot.Add (roteul.z);
            rot.Add (rotinv.y);
            rot.Add (rotinv.x);
            rot.Add (rotinv.z);
            buffer.Add ("rot", rot);
            //buffer.Add (vessel.acceleration.magnitude.ToString ());
            //buffer.Add (vessel.angularMomentum.magnitude.ToString ());
            //buffer.Add (vessel.angularVelocity.magnitude.ToString ());
            //buffer.Add (vessel.geeForce_immediate.ToString ());
            //buffer.Add (vessel.horizontalSrfSpeed.ToString ());
            //buffer.Add (vessel.pqsAltitude.ToString ());
            //buffer.Add (vessel.rb_velocity.magnitude.ToString ());
            //buffer.Add (vessel.specificAcceleration.ToString ());
            //buffer.Add (vessel.terrainAltitude.ToString ());

            Debug.Log ("STEP_XXX_6");
            return buffer;
        }
开发者ID:voneiden,项目名称:ksp-missioncontrol,代码行数:101,代码来源:Utilities.cs

示例10: UpdateFromVessel

        public void UpdateFromVessel(Vessel vessel)
        {
            VesselName = vessel.vesselName;
            var vesselMiddle = vessel.findWorldCenterOfMass();
            var up = (vesselMiddle - vessel.mainBody.position).normalized;
            var north = Vector3d.Exclude(up, (vessel.mainBody.position + vessel.mainBody.transform.up * (float)vessel.mainBody.Radius) - vesselMiddle).normalized;

            var rotSurface = Quaternion.LookRotation(north, up);
            var rotVesselToSurface = Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(vessel.GetTransform().rotation) * rotSurface);

            var heading = rotVesselToSurface.eulerAngles.y;
            var pitch = (rotVesselToSurface.eulerAngles.x > 180) ? (360.0 - rotVesselToSurface.eulerAngles.x) : -rotVesselToSurface.eulerAngles.x;
            var roll = (rotVesselToSurface.eulerAngles.z > 180) ? (rotVesselToSurface.eulerAngles.z - 360.0) : rotVesselToSurface.eulerAngles.z;

            Heading = heading;
            Pitch = pitch;
            Roll = roll;
            Altitude = vessel.altitude;
            TerrainAltitude = vessel.terrainAltitude;

            CurrentStage = vessel.currentStage;
            SurfaceVelocity = vessel.rb_velocity.magnitude;

            GearDown = FlightInputHandler.state.gearDown;
        }
开发者ID:jbwagner,项目名称:KInstruments,代码行数:25,代码来源:InstrumentData.cs


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