Esempio n. 1
0
        protected override void content()
        {
            MarkerForces    comv = RCSBuildAid.VesselForces;
            MomentOfInertia moi  = comv.MoI;

            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label("MoI:");
                    GUILayout.Label("Ang Acc:");
                    GUILayout.Label("Ang Acc:");
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                {
                    GUILayout.Label(moi.value.ToString("0.## tm²"));
                    float angAcc = comv.Torque().magnitude / moi.value;
                    GUILayout.Label(angAcc.ToString("0.## r/s²"));
                    GUILayout.Label((angAcc * Mathf.Rad2Deg).ToString("0.## °/s²"));
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
            DebugSettings.labelMagnitudes =
                GUILayout.Toggle(DebugSettings.labelMagnitudes, "Show vector magnitudes");
            DebugSettings.inFlightAngularInfo =
                GUILayout.Toggle(DebugSettings.inFlightAngularInfo, "In flight angular data");
            DebugSettings.startInOrbit =
                GUILayout.Toggle(DebugSettings.startInOrbit, "Launch in orbit");
        }
Esempio n. 2
0
        void Awake()
        {
            if (toolbarControl == null)
            {
                Log.Info("RCSBuildaid creating toolbar");
                InitToolbar();
            }

            rcsList    = new List <PartModule>();
            engineList = new List <PartModule>();

            events = new Events();
            events.HookEvents();
            PluginKeys.Setup();

            gameObject.AddComponent <MarkerManager>();
            gameObject.AddComponent <MainWindow>();
            gameObject.AddComponent <DeltaV>();

            var obj = new GameObject("Vessel Forces Object");

            obj.layer    = 2;
            vesselForces = obj.AddComponent <MarkerForces>();

            Events.EditorScreenChanged += onEditorScreenChanged;
        }
Esempio n. 3
0
        static void DrawContent()
        {
            MarkerForces comv = RCSBuildAid.VesselForces;

            GUILayout.BeginHorizontal();
            {
                if (hasAttitudeControl())
                {
                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label("Reference");
                        GUILayout.Label("Direction");
                        GUILayout.Label("Torque");
                        GUILayout.Label("Thrust");
                    }
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                    {
                        MainWindow.referenceButton();
                        MainWindow.directionButton();
                        GUILayout.Label(comv.Torque().magnitude.ToString("0.### kNm"));
                        GUILayout.Label(comv.Thrust().magnitude.ToString("0.## kN"));
                    }
                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.Label("No attitude control elements attached", MainWindow.style.centerText);
                }
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 4
0
        public static void DrawContent()
        {
            MarkerForces     comv = RCSBuildAid.VesselForces;
            MassEditorMarker comm = RCSBuildAid.ReferenceMarker.GetComponent <MassEditorMarker> ();

            GUILayout.BeginHorizontal();
            {
                if (RCSBuildAid.EngineList.Count != 0)
                {
                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label("Reference");
                        GUILayout.Label("Torque");
                        GUILayout.Label("Thrust");
                        GUILayout.Label("TWR");
                    }
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                    {
                        MainWindow.referenceButton();
                        GUILayout.Label(comv.Torque().magnitude.ToString("0.### kNm"));
                        GUILayout.Label(comv.Thrust().magnitude.ToString("0.## kN"));
                        GUILayout.Label((comv.Thrust().magnitude / (comm.mass * 9.81)).ToString("0.##"));
                    }
                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.Label("No engines attached", MainWindow.style.centerText);
                }
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 5
0
        void Awake()
        {
            if (!appLauncherCreated)
            {
                appLauncherCreated = true;
                Log.Info("RCSBuildaid creating AppLauncher");
                //var appLauncher = new AppLauncher(this.gameObject);
            }

            rcsList    = new List <PartModule> ();
            engineList = new List <PartModule> ();

            events = new Events();
            events.HookEvents();
            PluginKeys.Setup();

            gameObject.AddComponent <MarkerManager> ();
            gameObject.AddComponent <MainWindow> ();
            gameObject.AddComponent <DeltaV> ();

            var obj = new GameObject("Vessel Forces Object");

            obj.layer    = 2;
            vesselForces = obj.AddComponent <MarkerForces> ();

            Events.EditorScreenChanged += onEditorScreenChanged;
        }
Esempio n. 6
0
        void Awake()
        {
#if DEBUG
            Debug.Log("[RCSBA]: Awake");
#endif

            rcsList       = new List <PartModule> ();
            engineList    = new List <PartModule> ();
            chutesList    = new List <PartModule>();
            selectionList = new List <PartModule>();

            events = new Events();
            events.HookEvents();
            PluginKeys.Setup();

            gameObject.AddComponent <MarkerManager> ();
            gameObject.AddComponent <MainWindow> ();
            gameObject.AddComponent <DeltaV> ();

            var obj = new GameObject("Vessel Forces Object");
            obj.layer    = 2;
            vesselForces = obj.AddComponent <MarkerForces> ();

            /* We need these here and not in Start for catch some editor events */
            Events.EditorScreenChanged += onEditorScreenChanged;
            Events.VesselPartChanged   += onVesselPartChanged;
            Events.SelectionChanged    += onSelectionChange;
            Events.PartDrag            += onPartDrag;
            Events.LeavingEditor       += onLeavingEditor;
        }
Esempio n. 7
0
        protected override void DrawContent()
        {
            MarkerForces comv = RCSBuildAid.VesselForces;

            GUILayout.BeginVertical();
            {
                if (RCSBuildAid.RCS.Count != 0)
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Reference", MainWindow.style.readoutName);
                        MainWindow.ReferenceButton();
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Direction", MainWindow.style.readoutName);
                        MainWindow.TranslationButton();
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Torque", MainWindow.style.readoutName);
                        GUILayout.Label(comv.Torque().magnitude.ToString("0.### kNm"));
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Thrust", MainWindow.style.readoutName);
                        GUILayout.Label(comv.Thrust().magnitude.ToString("0.## kN"));
                    }
                    GUILayout.EndHorizontal();
                    if (DeltaV.sanity)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Delta V", MainWindow.style.readoutName);
                            GUILayout.Label(DeltaV.dV.ToString("0.# m/s"));
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Burn time", MainWindow.style.readoutName);
                            GUILayout.Label(MainWindow.TimeFormat(DeltaV.burnTime));
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    GUILayout.Label("No RCS thrusters attached", MainWindow.style.centerText);
                }
            }
            GUILayout.EndVertical();
        }
Esempio n. 8
0
        protected override void DrawContent()
        {
            MarkerForces comv = RCSBuildAid.VesselForces;

            GUILayout.BeginVertical();
            {
                if (RCSBuildAid.Engines.Count != 0)
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Reference", MainWindow.style.readoutName);
                        MainWindow.ReferenceButton();
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Torque", MainWindow.style.readoutName);
                        GUILayout.Label(comv.Torque().magnitude.ToString("0.### kNm"));
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Thrust", MainWindow.style.readoutName, GUILayout.Width(40));
                        if (GUILayout.Button(Settings.engines_vac ? "Vac" : "ASL", MainWindow.style.clickLabel, GUILayout.Width(36)))
                        {
                            Settings.engines_vac = !Settings.engines_vac;
                        }
                        GUILayout.Label(comv.Thrust().magnitude.ToString("0.## kN"));
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Body", MainWindow.style.readoutName);
                        if (GUILayout.Button(Settings.selected_body.name, MainWindow.style.clickLabel))
                        {
                            MainWindow.cBodyListEnabled = !MainWindow.cBodyListEnabled;
                            MainWindow.cBodyListMode    = RCSBuildAid.Mode;
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("TWR", MainWindow.style.readoutName);
                        GUILayout.Label(comv.TWR.ToString("0.##"));
                    }
                    GUILayout.EndHorizontal();
                    gimbals.DrawContent();
                }
                else
                {
                    GUILayout.Label("No engines attached", MainWindow.style.centerText);
                }
            }
            GUILayout.EndVertical();
        }
Esempio n. 9
0
        void Awake()
        {
            rcsList    = new List <PartModule> ();
            engineList = new List <PartModule> ();

            events = new Events();
            events.HookEvents();
            PluginKeys.Setup();

            gameObject.AddComponent <MarkerManager> ();
            gameObject.AddComponent <MainWindow> ();
            gameObject.AddComponent <DeltaV> ();

            var obj = new GameObject("Vessel Forces Object");

            obj.layer    = 2;
            vesselForces = obj.AddComponent <MarkerForces> ();

            Events.EditorScreenChanged += onEditorScreenChanged;
        }
Esempio n. 10
0
        void setupMarker()
        {
            /* get CoM */
            if (vesselOverlays.CoMmarker == null)
            {
                gameObject.SetActive(false);
                throw new Exception("CoM marker is null, this shouldn't happen.");
            }
            CoM = vesselOverlays.CoMmarker.gameObject;

            /* init DCoM */
            DCoM = (GameObject)UnityEngine.Object.Instantiate(CoM);
            Destroy(DCoM.GetComponent <EditorMarker_CoM> ());           /* we don't need this */
            DCoM.name = "DCoM Marker";
            if (DCoM.transform.childCount > 0)
            {
                /* Stock CoM doesn't have any attached objects, if there's some it means
                 * there's a plugin doing the same thing as us. We don't want extra
                 * objects */
                for (int i = 0; i < DCoM.transform.childCount; i++)
                {
                    Destroy(DCoM.transform.GetChild(i).gameObject);
                }
            }

            /* init ACoM */
            ACoM      = (GameObject)UnityEngine.Object.Instantiate(DCoM);
            ACoM.name = "ACoM Marker";

            referenceDict[MarkerType.CoM]  = CoM;
            referenceDict[MarkerType.DCoM] = DCoM;
            referenceDict[MarkerType.ACoM] = ACoM;

            /* CoM setup, replace stock component with our own */
            CoM_Marker comMarker = CoM.AddComponent <CoM_Marker> ();

            comMarker.posMarkerObject = vesselOverlays.CoMmarker.posMarkerObject;
            Destroy(vesselOverlays.CoMmarker);
            vesselOverlays.CoMmarker = comMarker;

            /* setup DCoM */
            DCoM_Marker dcomMarker = DCoM.AddComponent <DCoM_Marker> (); /* we do need this    */

            dcomMarker.posMarkerObject = DCoM;

            /* setup ACoM */
            var acomMarker = ACoM.AddComponent <Average_Marker> ();

            acomMarker.posMarkerObject = ACoM;
            acomMarker.CoM1            = comMarker;
            acomMarker.CoM2            = dcomMarker;

            GameObject obj = new GameObject("Vessel Forces Object");

            obj.layer    = CoM.layer;
            vesselForces = obj.AddComponent <MarkerForces> ();
            SetReferenceMarker(referenceMarker);

            /* scaling for CoL and CoT markers */
            vesselOverlays.CoLmarker.gameObject.AddComponent <MarkerScaler> ();
            vesselOverlays.CoTmarker.gameObject.AddComponent <MarkerScaler> ();

            /* attach our method to the CoM toggle button */
            vesselOverlays.toggleCoMbtn.AddValueChangedDelegate(delegate { CoMButtonClick(); });
        }
Esempio n. 11
0
        protected override void content()
        {
            MarkerForces    comv = RCSBuildAid.VesselForces;
            MomentOfInertia moi  = comv.MoI;

            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label("Mouse");
                    GUILayout.Label("MoI");
                    GUILayout.Label("Ang Acc");
                    GUILayout.Label("Ang Acc");
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                {
                    GUILayout.Label($"{Input.mousePosition.x}, {Input.mousePosition.y}");
                    GUILayout.Label(moi.value.ToString("0.## tm²"));
                    float angAcc = comv.Torque().magnitude / moi.value;
                    GUILayout.Label(angAcc.ToString("0.## r/s²"));
                    GUILayout.Label((angAcc * Mathf.Rad2Deg).ToString("0.## °/s²"));
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            Part part = null;

            if (massInfo)
            {
                foreach (var p in EditorLogic.fetch.ship.parts)
                {
                    if (p.stackIcon.Highlighted)
                    {
                        part = p;
                        break;
                    }
                }
            }
            if (massInfo)
            {
                if (part != null)
                {
                    GUILayout.BeginVertical(GUI.skin.box);
                    {
                        printMassInfo(part);
                    }
                    GUILayout.EndVertical();
                }
                else
                {
                    if (GUILayout.Button("mouseover a part"))
                    {
                        massInfo = !massInfo;
                    }
                }
            }
            else
            {
                if (GUILayout.Button("mass info"))
                {
                    massInfo = !massInfo;
                }
            }
            DebugSettings.labelMagnitudes =
                GUILayout.Toggle(DebugSettings.labelMagnitudes, "Show vector magnitudes");
            DebugSettings.inFlightAngularInfo =
                GUILayout.Toggle(DebugSettings.inFlightAngularInfo, "In flight angular data");
            DebugSettings.inFlightPartInfo =
                GUILayout.Toggle(DebugSettings.inFlightPartInfo, "In flight vessel tree");
            DebugSettings.startInOrbit =
                GUILayout.Toggle(DebugSettings.startInOrbit, "Launch in orbit");
            if (GUILayout.Button("Toggle vessel tree window"))
            {
                if (vesselTreeWindow == null)
                {
                    vesselTreeWindow = gameObject.AddComponent <DebugVesselTree> ();
                }
                else
                {
                    Destroy(vesselTreeWindow);
                }
            }
            if (GUILayout.Button("Toggle part list window"))
            {
                if (partListWindow == null)
                {
                    partListWindow = gameObject.AddComponent <DebugPartList> ();
                }
                else
                {
                    Destroy(partListWindow);
                }
            }
            if (GUILayout.Button("More info"))
            {
                if (debugMiscInfo == null)
                {
                    debugMiscInfo = gameObject.AddComponent <DebugMiscInfo> ();
                }
                else
                {
                    Destroy(debugMiscInfo);
                }
            }
        }
Esempio n. 12
0
        protected override void DrawContent()
        {
            MarkerForces vesselForces = RCSBuildAid.VesselForces;

            GUILayout.BeginVertical();
            {
                if (RCSBuildAid.HasRCS)
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Reference", MainWindow.style.readoutName);
                        MainWindow.ReferenceButton();
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Direction", MainWindow.style.readoutName);
                        MainWindow.TranslationButton();
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Torque", MainWindow.style.readoutName);
                        GUILayout.Label(vesselForces.Torque().magnitude.ToString("0.### kNm"));
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Thrust", MainWindow.style.readoutName);
                        GUILayout.Label(vesselForces.Thrust().magnitude.ToString("0.## kN"));
                    }
                    GUILayout.EndHorizontal();
                    if (DeltaV.sanity)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("ΔV", MainWindow.style.readoutName);
                            GUILayout.Label(DeltaV.dV.ToString("0.# m/s"));
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Burn time", MainWindow.style.readoutName);
                            GUILayout.Label(MainWindow.TimeFormat(DeltaV.burnTime));
                        }
                        GUILayout.EndHorizontal();
                    }
                    if (Settings.show_rcs_twr)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Body", MainWindow.style.readoutName);
                            if (GUILayout.Button(Settings.selected_body.name, MainWindow.style.clickLabel))
                            {
                                MainWindow.cBodyListEnabled = !MainWindow.cBodyListEnabled;
                                MainWindow.cBodyListMode    = RCSBuildAid.Mode;
                            }
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("TWR", MainWindow.style.readoutName);
                            GUILayout.Label(!Settings.selected_body.atmosphere
                                ? vesselForces.TWR.ToString("0.##")
                                : "--");
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    GUILayout.Label("No RCS thrusters attached", MainWindow.style.centerText);
                }
            }
            GUILayout.EndVertical();
        }