Exemplo n.º 1
0
        // TODO : I should probably use an array and an enum to lower code dup ...
        public override void OnUpdate()
        {
            if (vessel != FlightGlobals.ActiveVessel)
            {
                return;
            }

            if (comSphere == null)
            {
                comSphere = new DebugIcoSphere(XKCDColors.BloodRed, true);

                colSphere = new DebugIcoSphere(XKCDColors.Teal, true);
                cotSphere = new DebugIcoSphere(XKCDColors.PurplePink, true);

                srfVelocityArrow = new DebugArrow(Color.green);
                obtVelocityArrow = new DebugArrow(Color.red);

                dotArrow = new DebugArrow(XKCDColors.PurplePink);

                forwardArrow = new DebugArrow(XKCDColors.ElectricBlue);
                //avgForwardArrow = new DebugArrow(Color.blue);

                requestedAttitudeArrow = new DebugArrow(Color.gray);

                debugArrow  = new DebugArrow(XKCDColors.Fuchsia);
                debugArrow2 = new DebugArrow(XKCDColors.LightBlue);
            }


            var      frameVel   = (vesselState.orbitalVelocity - Krakensbane.GetFrameVelocity() - vessel.orbit.GetRotFrameVel(vessel.orbit.referenceBody).xzy) * Time.fixedDeltaTime;
            Vector3d instantCoM = vesselState.CoM + frameVel;

            Vector3 arrowPos = displayAtCoM
                ? instantCoM
                : (Vector3d)vessel.ReferenceTransform.position;

            comSphere.State(comSphereActive && core.ShowGui);
            if (comSphereActive)
            {
                comSphere.Set(instantCoM);
                comSphere.SetRadius((float)comSphereRadius.val);
            }

            colSphere.State(colSphereActive && vesselState.CoLScalar > 0 && core.ShowGui);
            if (colSphereActive)
            {
                colSphere.Set(vesselState.CoL + frameVel);
                colSphere.SetRadius((float)comSphereRadius.val);
            }

            cotSphere.State(cotSphereActive && vesselState.CoTScalar > 0 && core.ShowGui);
            if (cotSphereActive)
            {
                cotSphere.Set(vesselState.CoT + frameVel);
                cotSphere.SetRadius((float)comSphereRadius.val);
            }

            srfVelocityArrow.State(srfVelocityArrowActive && core.ShowGui);
            if (srfVelocityArrowActive)
            {
                srfVelocityArrow.Set(arrowPos, vessel.srf_velocity);
                srfVelocityArrow.SetLength((float)arrowsLength.val);
                srfVelocityArrow.SeeThrough(seeThrough);
            }

            obtVelocityArrow.State(obtVelocityArrowActive && core.ShowGui);
            if (obtVelocityArrowActive)
            {
                obtVelocityArrow.Set(arrowPos, vessel.obt_velocity);
                obtVelocityArrow.SetLength((float)arrowsLength.val);
                obtVelocityArrow.SeeThrough(seeThrough);
            }

            dotArrow.State(dotArrowActive && vesselState.thrustCurrent > 0 && core.ShowGui);
            if (dotArrowActive)
            {
                dotArrow.Set(vesselState.CoT + frameVel, vesselState.DoT);
                dotArrow.SetLength((float)Math.Log10(vesselState.thrustCurrent + 1));
                dotArrow.SeeThrough(seeThrough);
            }

            forwardArrow.State(forwardArrowActive && core.ShowGui);
            if (forwardArrowActive)
            {
                forwardArrow.Set(arrowPos, vessel.GetTransform().up);
                forwardArrow.SetLength((float)arrowsLength.val);
                forwardArrow.SeeThrough(seeThrough);
            }

            /*
             * avgForwardArrow.State(avgForwardArrowActive && core.ShowGui);
             * if (avgForwardArrowActive)
             * {
             *  avgForwardArrow.Set(arrowPos, vesselState.forward);
             *  avgForwardArrow.SetLength((float)arrowsLength.val);
             *  avgForwardArrow.SeeThrough(seeThrough);
             * }
             */

            requestedAttitudeArrow.State(requestedAttitudeArrowActive && core.attitude.enabled && core.ShowGui);
            if (requestedAttitudeArrowActive && core.attitude.enabled)
            {
                requestedAttitudeArrow.Set(arrowPos, core.attitude.RequestedAttitude);
                requestedAttitudeArrow.SetLength((float)arrowsLength.val);
                requestedAttitudeArrow.SeeThrough(seeThrough);
            }

            debugArrow.State(debugArrowActive && core.ShowGui);
            if (debugArrowActive)
            {
                debugArrow.Set(vessel.ReferenceTransform.position, debugVector);
                debugArrow.SetLength((float)debugVector.magnitude);
                debugArrow.SeeThrough(seeThrough);
            }

            debugArrow2.State(debugArrow2Active && core.ShowGui);
            if (debugArrow2Active)
            {
                //debugArrow2.Set(vessel.ReferenceTransform.position, debugVector2);
                //
                //debugArrow2.SetLength((float)debugVector2.magnitude);
                //debugArrow2.SeeThrough(seeThrough);

                var vector3d = vesselState.CoL - instantCoM + frameVel;
                debugArrow2.Set(instantCoM, vector3d);

                debugArrow2.SetLength((float)vector3d.magnitude);
                debugArrow2.SeeThrough(seeThrough);
            }
        }
Exemplo n.º 2
0
        // TODO : I should probably use an array and an enum to lower code dup ...
        public override void OnUpdate()
        {
            if (vessel != FlightGlobals.ActiveVessel)
            {
                return;
            }

            if (comSphere == null)
            {
                comSphere = new DebugIcoSphere(XKCDColors.BloodRed, true);

                podSrfVelocityArrow = new DebugArrow(Color.yellow);
                comSrfVelocityArrow = new DebugArrow(Color.green);

                podObtVelocityArrow = new DebugArrow(Color.red);
                comObtVelocityArrow = new DebugArrow(XKCDColors.Orange);

                forwardArrow    = new DebugArrow(XKCDColors.NavyBlue);
                avgForwardArrow = new DebugArrow(Color.blue);

                requestedAttitudeArrow = new DebugArrow(Color.gray);

                debugArrow = new DebugArrow(XKCDColors.Fuchsia);
            }


            Vector3d instantCoM = vessel.CoM + (vesselState.orbitalVelocity - Krakensbane.GetFrameVelocity() - vessel.orbit.GetRotFrameVel(vessel.orbit.referenceBody).xzy) * Time.fixedDeltaTime;

            Vector3 arrowPos = displayAtCoM
                ? instantCoM
                : (Vector3d)vessel.ReferenceTransform.position;

            comSphere.State(comSphereActive);
            if (comSphereActive)
            {
                comSphere.Set(instantCoM);
                comSphere.SetRadius((float)comSphereRadius.val);
            }

            podSrfVelocityArrow.State(podSrfVelocityArrowActive);
            if (podSrfVelocityArrowActive)
            {
                podSrfVelocityArrow.Set(arrowPos, vessel.srf_velocity);
                podSrfVelocityArrow.SetLength((float)arrowsLength.val);
                podSrfVelocityArrow.SeeThrough(seeThrough);
            }

            comSrfVelocityArrow.State(comSrfVelocityArrowActive && MechJebModuleAttitudeController.useCoMVelocity);
            if (comSrfVelocityArrowActive)
            {
                comSrfVelocityArrow.Set(arrowPos, vesselState.surfaceVelocity);
                comSrfVelocityArrow.SetLength((float)arrowsLength.val);
                comSrfVelocityArrow.SeeThrough(seeThrough);
            }

            podObtVelocityArrow.State(podObtVelocityArrowActive);
            if (podObtVelocityArrowActive)
            {
                podObtVelocityArrow.Set(arrowPos, vessel.obt_velocity);
                podObtVelocityArrow.SetLength((float)arrowsLength.val);
                podObtVelocityArrow.SeeThrough(seeThrough);
            }

            comObtVelocityArrow.State(comObtVelocityArrowActive && MechJebModuleAttitudeController.useCoMVelocity);
            if (comObtVelocityArrowActive)
            {
                comObtVelocityArrow.Set(arrowPos, vesselState.orbitalVelocity);
                comObtVelocityArrow.SetLength((float)arrowsLength.val);
                comObtVelocityArrow.SeeThrough(seeThrough);
            }

            forwardArrow.State(forwardArrowActive);
            if (forwardArrowActive)
            {
                forwardArrow.Set(arrowPos, vessel.GetTransform().up);
                forwardArrow.SetLength((float)arrowsLength.val);
                forwardArrow.SeeThrough(seeThrough);
            }

            avgForwardArrow.State(avgForwardArrowActive);
            if (avgForwardArrowActive)
            {
                avgForwardArrow.Set(arrowPos, vesselState.forward);
                avgForwardArrow.SetLength((float)arrowsLength.val);
                avgForwardArrow.SeeThrough(seeThrough);
            }

            requestedAttitudeArrow.State(requestedAttitudeArrowActive && core.attitude.enabled);
            if (requestedAttitudeArrowActive && core.attitude.enabled)
            {
                requestedAttitudeArrow.Set(arrowPos, core.attitude.RequestedAttitude);
                requestedAttitudeArrow.SetLength((float)arrowsLength.val);
                requestedAttitudeArrow.SeeThrough(seeThrough);
            }

            debugArrow.State(debugArrowActive);
            if (debugArrowActive)
            {
                debugArrow.Set((Vector3d)vessel.ReferenceTransform.position, debugVector);
                debugArrow.SetLength((float)debugVector.magnitude);
                debugArrow.SeeThrough(seeThrough);
            }
        }