예제 #1
0
        //Returns the current terminal velocity for vessel v in true m/s
        public static float getTerm(Vessel v)
        {
            //Use FAR data if installed
            SteamShip.InitFAR();
            if (SteamShip.far_GetTermVel != null && v == FlightGlobals.ActiveVessel)
            {
                return((float)SteamShip.far_GetTermVel());
            }

            double totalMass = 0d;
            double massDrag  = 0d;

            foreach (Part part in v.parts)
            {
                if (part.physicalSignificance != Part.PhysicalSignificance.NONE)
                {
                    double partMass = part.mass + part.GetResourceMass();
                    totalMass += partMass;
                    massDrag  += partMass * part.maximum_drag;
                }
            }
            double gravity          = FlightGlobals.getGeeForceAtPosition(v.CoM).magnitude;
            double atmosphere       = v.atmDensity;
            double terminalVelocity = 0d;

            if (atmosphere > 0)
            {
                terminalVelocity = Math.Sqrt((2 * totalMass * gravity) / (atmosphere * massDrag * 1));  //1 should be drag index, which doesn't exist any more
            }

            return((float)terminalVelocity);
        }
예제 #2
0
        //Returns true if vec is more than 2 degrees from the nose in either pitch or yaw
        private bool offTarget(Vector3 vec, float amount)
        {
            Transform self = FlightGlobals.ActiveVessel.ReferenceTransform;
            //Determine the number of degrees vec differs from vessel orientation
            Vector3 rVel = new Vector3();

            rVel.x = SteamShip.AngleAroundNormal(vec, self.up, self.forward);
            rVel.y = SteamShip.AngleAroundNormal(vec, self.up, self.right);
            if (Math.Abs(rVel.x) > amount)
            {
                return(true);
            }
            if (Math.Abs(rVel.y) > amount)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        //What to do when we are drawn
        private void OnDraw()
        {
            //SteamShip updating
            SteamShip.update();

            //Alpha blending
            Color tmpColor = GUI.color;

            GUI.color = new Color(1, 1, 1, Alpha);

            //Draw the main window, if not minimized
            if (!isMinimized)
            {
                //Check window off screen
                if ((_windowPosition.xMin + _windowPosition.width) < 20)
                {
                    _windowPosition.xMin = 20 - _windowPosition.width;                                                      //left limit
                }
                if (_windowPosition.yMin + _windowPosition.height < 20)
                {
                    _windowPosition.yMin = 20 - _windowPosition.height;                                                     //top limit
                }
                if (_windowPosition.xMin > Screen.width - 20)
                {
                    _windowPosition.xMin = Screen.width - 20;                                             //right limit
                }
                if (_windowPosition.yMin > Screen.height - 20)
                {
                    _windowPosition.yMin = Screen.height - 20;                                            //bottom limit
                }
                String title = "SteamGauges " + VersionString;
                if (!CompatibilityChecker.IsCompatible())
                {
                    title = title + " Incompatible Version!";
                }
                _windowPosition = GUILayout.Window(8901, _windowPosition, OnWindow, title, _windowStyle);
            }
            //Draw the advanced window, if not minimized
            if (!advMinimized)
            {
                //Check window off screen
                if ((_advwindowPosition.xMin + _advwindowPosition.width) < 20)
                {
                    _advwindowPosition.xMin = 20 - _advwindowPosition.width;                                                            //left limit
                }
                if (_advwindowPosition.yMin + _advwindowPosition.height < 20)
                {
                    _advwindowPosition.yMin = 20 - _advwindowPosition.height;                                                           //top limit
                }
                if (_advwindowPosition.xMin > Screen.width - 20)
                {
                    _advwindowPosition.xMin = Screen.width - 20;                                                //right limit
                }
                if (_advwindowPosition.yMin > Screen.height - 20)
                {
                    _advwindowPosition.yMin = Screen.height - 20;                                               //bottom limit
                }
                _advwindowPosition = GUILayout.Window(8902, _advwindowPosition, OnAdvanced, "SteamGauges" + VersionString + " Settings", _windowStyle);
            }

            //Reset alpha so we don't blend out stuff unintentionally
            GUI.color = tmpColor;
        }