Esempio n. 1
0
 public void MouseMoved(int mx, int my, AirPlane ap, SimulatorInterface simIF, GraphicsGenerator gd)
 {
     if ((simIF.mode == 0) && (simIF.pause_sw == 0) && (ap.cif.stick_mode == 1))
     {
         ap.cif.Set_stick_pos_x((double)(mx - gd.stick_center_x) / (double)gd.stick_x_width);
         ap.cif.Set_stick_pos_y((double)(my - gd.stick_center_y) / (double)gd.stick_y_width);
     }
 }
 public void DrawSimInterfase(Graphics g, SimulatorInterface simif)
 {
     //  g.SetFont(bigFont);
     //  g.SetColor(simInterfaceColor);
     if (simif.pause_sw == 1)
     {
         //  g.DrawString("PAUSE", pause_x, pause_y);
     }
     // if (simif.slow_mode == 1)
     //g.DrawString("SLOW MOTION", slowMoton_x, slowMoton_y);
 }
Esempio n. 3
0
        public void MouseClicked(int mx, int my, AirPlane ap, SimulatorInterface simIF, GraphicsGenerator gd, ConfigMenu cMenu)
        {
            if ((simIF.mode == 0) && (simIF.pause_sw == 0) && (Math.Abs(mx - gd.stick_center_x) <= gd.stick_x_width) && (Math.Abs(my - gd.stick_center_y) <= gd.stick_y_width))
            {
                ap.cif.Change_stick_mode();
            }

            if (simIF.mode == 2)
            {
                cMenu.Click(mx, my, simIF);
            }
        }
Esempio n. 4
0
        public FlightSimulator()
            : base()
        {
            //ダブルバッファリング設定
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);


            version  = "Ver.1.1 2003.11.04";
            eh       = new EventHandler();
            tp       = new TimeParam();
            simIF    = new SimulatorInterface();
            recorder = new Recorder();
            fps      = new FPS();
        }
Esempio n. 5
0
 public void Click(int mx, int my, SimulatorInterface simif)
 {
     if (airplaneNext.Test(mx, my))
     {
         displayAirPlane += 1;
         if (displayAirPlane >= apl.NItem())
         {
             displayAirPlane = 0;
         }
     }
     if (airplanePrev.Test(mx, my))
     {
         displayAirPlane -= 1;
         if (displayAirPlane < 0)
         {
             displayAirPlane = (apl.NItem() - 1);
         }
     }
     if (setting_normal.Test(mx, my))
     {
         displaySetting = 0;
     }
     if (setting_lowlevel.Test(mx, my))
     {
         displaySetting = 1;
     }
     if (cancel.Test(mx, my))
     {
         displayAirPlane = selectedAirPlane;
         displaySetting  = selectedSetting;
         simif.mode      = 0;
     }
     if (ok.Test(mx, my))
     {
         if (displayAirPlane != selectedAirPlane)
         {
             selectedAirPlane  = displayAirPlane;
             simif.changePlane = 1;
         }
         if (displaySetting != selectedSetting)
         {
             selectedSetting      = displaySetting;
             simif.changePSetting = 1;
         }
         simif.mode = 0;
     }
 }
        public void CreateImage(Graphics g, AirPlane ap, SimulatorInterface simif, double dt)
        {
            CreateView(g, ap.pMotion.wpos, ap.pMotion.wom.MultMat(ap.plane.opm).MultMat(ap.pilot.ViewMatrix()));

            DrawPadLock(g, ap);

            DrawInterfase(g, ap);

            DrawInstrument(g, ap, simif, dt);

            if (simif.dispDynamicsSw == 1)
            {
                DrawDynamics(g, ap, dt);
            }

            DrawSimInterfase(g, simif);

            // g.SetFont(stdFont);
        }
Esempio n. 7
0
        public void KeyReleased(Keys keyCode, AirPlane ap, SimulatorInterface simIF)
        {
            if (keyCode == simIF.key_ctrl)
            {
                simIF.ctrl_sw = 0;
            }

            if ((simIF.mode == 0) && (simIF.pause_sw == 0))
            {
                if ((keyCode == ap.cif.key_rudder_left) ||
                    (keyCode == ap.cif.key_rudder_right))
                {
                    ap.cif.rudder_sw = 0;
                }

                if ((keyCode == ap.cif.key_throttle_up) || (keyCode == ap.cif.key_throttle_down))
                {
                    ap.cif.throttle_sw = 0;
                }

                if ((keyCode == ap.cif.key_mixture_lean) || (keyCode == ap.cif.key_mixture_rich))
                {
                    ap.cif.mixture_sw = 0;
                }

                if ((keyCode == ap.cif.key_prop_pitch_high) || (keyCode == ap.cif.key_prop_pitch_low))
                {
                    ap.cif.prop_pitch_sw = 0;
                }

                if (keyCode == ap.cif.key_brake_right)
                {
                    ap.cif.brakeRight_sw = -1;
                }
                if (keyCode == ap.cif.key_brake_left)
                {
                    ap.cif.brakeLeft_sw = -1;
                }

                if ((keyCode == ap.cif.key_flap_down) || (keyCode == ap.cif.key_flap_up))
                {
                    ap.cif.flap_sw = 0;
                }

                if ((keyCode == ap.cif.key_front) || (keyCode == ap.cif.key_front_left) || (keyCode == ap.cif.key_left) || (keyCode == ap.cif.key_rear_left) || (keyCode == ap.cif.key_rear) || (keyCode == ap.cif.key_rear_right) || (keyCode == ap.cif.key_right) || (keyCode == ap.cif.key_front_right))
                {
                    ap.cif.view_direction = 0;
                }
                if (keyCode == ap.cif.key_upper)
                {
                    ap.cif.view_upper = 0;
                }
            }

            if (simIF.mode == 1)
            {
                for (int i = 0; i < simIF.key_locus_action.Length; i++)
                {
                    if (keyCode == simIF.key_locus_action[i])
                    {
                        simIF.locus_action_sw[i] = 0;
                        if (simIF.Check_locus_action_sw() == 0)
                        {
                            simIF.locusImageMake = 1;
                        }
                        else
                        {
                            simIF.locusImageMake = 0;
                        }
                    }
                }

                if (keyCode == simIF.key_data_foword)
                {
                    simIF.data_foword_sw = 0;
                }
                if (keyCode == simIF.key_data_back)
                {
                    simIF.data_back_sw = 0;
                }
            }
        }
Esempio n. 8
0
        public void KeyPressed(Keys keyCode, AirPlane ap, SimulatorInterface simIF, Recorder recorder, PadlockObjectList pobj)
        {
            if (keyCode == simIF.key_ctrl)
            {
                simIF.ctrl_sw = 1;
            }

            if ((keyCode == simIF.key_pause) && (simIF.mode == 0))
            {
                if (simIF.pause_sw == 0)
                {
                    simIF.pause_sw = 1;
                }
                else
                {
                    simIF.pause_sw       = 0;
                    simIF.locusMake      = 1;
                    simIF.locusImageMake = 1;
                }
            }

            if (keyCode == simIF.key_locus_disp)
            {
                simIF.pause_sw = 1;
                if (simIF.mode == 0)
                {
                    simIF.mode = 1;
                }
                else if (simIF.mode == 1)
                {
                    simIF.mode = 0;
                }
            }

            if (keyCode == simIF.key_menu)
            {
                simIF.pause_sw = 1;
                if (simIF.mode == 0)
                {
                    simIF.mode = 2;
                }
            }

            if (keyCode == simIF.key_locus_reset)
            {
                recorder.Reset();
                simIF.locusMake      = 1;
                simIF.locusImageMake = 1;
                Jp.Maker1.Util.Gui.Caption.SetCaption("RECORDER RESET", 2.0D);
            }

            if (simIF.mode == 0)
            {
                if (keyCode == simIF.key_slow)
                {
                    if (simIF.slow_mode == 0)
                    {
                        simIF.slow_mode = 1;
                    }
                    else
                    {
                        simIF.slow_mode = 0;
                    }
                }

                if (keyCode == simIF.key_dispDynamics)
                {
                    if (simIF.dispDynamicsSw == 0)
                    {
                        simIF.dispDynamicsSw = 1;
                    }
                    else
                    {
                        simIF.dispDynamicsSw = 0;
                    }
                }

                if (keyCode == simIF.key_dispInformation)
                {
                    if (simIF.dispInformationSw == 0)
                    {
                        simIF.dispInformationSw = 1;
                    }
                    else
                    {
                        simIF.dispInformationSw = 0;
                    }
                }
            }

            if ((simIF.mode == 0) && (simIF.pause_sw == 0))
            {
                if (keyCode == ap.cif.key_rudder_center)
                {
                    ap.cif.rudder_sw = 3;
                }

                if (keyCode == ap.cif.key_rudder_left)
                {
                    ap.cif.rudder_sw = -1;
                }
                if (keyCode == ap.cif.key_rudder_right)
                {
                    ap.cif.rudder_sw = 1;
                }

                if (keyCode == ap.cif.key_throttle_0p)
                {
                    ap.cif.throttle_pos = 0.0D;
                }
                if (keyCode == ap.cif.key_throttle_10p)
                {
                    ap.cif.throttle_pos = 0.1D;
                }
                if (keyCode == ap.cif.key_throttle_20p)
                {
                    ap.cif.throttle_pos = 0.2D;
                }
                if (keyCode == ap.cif.key_throttle_30p)
                {
                    ap.cif.throttle_pos = 0.3D;
                }
                if (keyCode == ap.cif.key_throttle_40p)
                {
                    ap.cif.throttle_pos = 0.4D;
                }
                if (keyCode == ap.cif.key_throttle_50p)
                {
                    ap.cif.throttle_pos = 0.5D;
                }
                if (keyCode == ap.cif.key_throttle_60p)
                {
                    ap.cif.throttle_pos = 0.6D;
                }
                if (keyCode == ap.cif.key_throttle_70p)
                {
                    ap.cif.throttle_pos = 0.7D;
                }
                if (keyCode == ap.cif.key_throttle_80p)
                {
                    ap.cif.throttle_pos = 0.8D;
                }
                if (keyCode == ap.cif.key_throttle_90p)
                {
                    ap.cif.throttle_pos = 0.9D;
                }
                if (keyCode == ap.cif.key_throttle_100p)
                {
                    ap.cif.throttle_pos = 1.0D;
                }
                if (keyCode == ap.cif.key_throttle_full)
                {
                    ap.cif.throttle_pos = 1.0D;
                }

                if (keyCode == ap.cif.key_throttle_up)
                {
                    ap.cif.throttle_sw = 1;
                }
                if (keyCode == ap.cif.key_throttle_down)
                {
                    ap.cif.throttle_sw = -1;
                }

                if (keyCode == ap.cif.key_mixture_full_rich)
                {
                    ap.cif.mixture_pos = 1.0D;
                }

                if (keyCode == ap.cif.key_mixture_rich)
                {
                    ap.cif.mixture_sw = 1;
                }
                if (keyCode == ap.cif.key_mixture_lean)
                {
                    ap.cif.mixture_sw = -1;
                }

                if (keyCode == ap.cif.key_prop_pitch_max_low)
                {
                    ap.cif.prop_pitch_pos = 1.0D;
                }

                if (keyCode == ap.cif.key_prop_pitch_low)
                {
                    ap.cif.prop_pitch_sw = 1;
                }
                if (keyCode == ap.cif.key_prop_pitch_high)
                {
                    ap.cif.prop_pitch_sw = -1;
                }

                if (keyCode == ap.cif.key_brake_right)
                {
                    ap.cif.brakeRight_sw = 1;
                }
                if (keyCode == ap.cif.key_brake_left)
                {
                    ap.cif.brakeLeft_sw = 1;
                }

                if (keyCode == ap.cif.key_landing_gear_sw)
                {
                    ap.cif.landing_gear_counter = 0.0D;
                    if (ap.cif.landing_gear_sw == 1)
                    {
                        ap.cif.landing_gear_sw = -1;
                    }
                    else
                    {
                        ap.cif.landing_gear_sw = 1;
                    }
                }

                if (keyCode == ap.cif.key_flap_down)
                {
                    ap.cif.flap_sw = -1;
                }
                if (keyCode == ap.cif.key_flap_up)
                {
                    ap.cif.flap_sw = 1;
                }

                if (keyCode == ap.cif.key_front)
                {
                    ap.cif.view_direction = 1;
                }
                if (keyCode == ap.cif.key_front_left)
                {
                    ap.cif.view_direction = 2;
                }
                if (keyCode == ap.cif.key_left)
                {
                    ap.cif.view_direction = 3;
                }
                if (keyCode == ap.cif.key_rear_left)
                {
                    ap.cif.view_direction = 4;
                }
                if (keyCode == ap.cif.key_rear)
                {
                    ap.cif.view_direction = 5;
                }
                if (keyCode == ap.cif.key_rear_right)
                {
                    ap.cif.view_direction = 6;
                }
                if (keyCode == ap.cif.key_right)
                {
                    ap.cif.view_direction = 7;
                }
                if (keyCode == ap.cif.key_front_right)
                {
                    ap.cif.view_direction = 8;
                }
                if (keyCode == ap.cif.key_upper)
                {
                    ap.cif.view_upper = 1;
                }

                if (keyCode == ap.cif.key_padLock)
                {
                    if (ap.cif.padLock_sw == 0)
                    {
                        ap.cif.padLock_sw = 1;
                    }
                    else
                    {
                        ap.cif.padLock_sw = 0;
                    }
                }

                if (keyCode == ap.cif.key_padLock_next)
                {
                    pobj.PadLockNext(ap);
                }

                if (keyCode == ap.cif.key_padLock_prev)
                {
                    pobj.PadLockPrev(ap);
                }
            }

            if (simIF.mode == 1)
            {
                if (keyCode == simIF.key_record_output)
                {
                    simIF.record_output_sw = 1;
                }

                if (keyCode == simIF.key_dispData)
                {
                    if (simIF.dispDataSw == 0)
                    {
                        simIF.dispDataSw = 1;
                    }
                    else
                    {
                        simIF.dispDataSw = 0;
                    }
                }

                for (int i = 0; i < simIF.key_locus_action.Length; i++)
                {
                    if (keyCode == simIF.key_locus_action[i])
                    {
                        simIF.locus_action_sw[i] = 1;
                    }
                }

                if (keyCode == simIF.key_param_reset)
                {
                    simIF.param_reset_sw = 1;
                }

                if (keyCode == simIF.key_data_foword)
                {
                    simIF.data_foword_sw = 1;
                }
                if (keyCode == simIF.key_data_back)
                {
                    simIF.data_back_sw = 1;
                }
            }
        }
        public void DrawInstrument(Graphics g, AirPlane ap, SimulatorInterface simif, double dt)
        {
            Matrix44 tmat  = new Matrix44();
            Matrix44 smat  = new Matrix44();
            Matrix44 rmat  = new Matrix44();
            Matrix44 rzmat = new Matrix44();
            Matrix44 rxmat = new Matrix44();
            Matrix44 mat   = new Matrix44();
            Scine    scine = new Scine();

            //g.SetColor(informationColor);
            //g.SetFont(stdFont);

            SolidBrush informationBrush = new SolidBrush(informationColor);
            Pen        informationPen   = new Pen(informationColor);

            g.DrawString(ap.plane.name, stdFont, informationBrush, 300 - ap.plane.name.Length * 3, 365);

            if (simif.dispInformationSw == 1)
            {
                double x = ap.pMotion.ov.Length();
                //g.DrawString("V: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x, 3, 1) + " m/s", v_true_x, v_true_y);
                //g.DrawString("V: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.Mps2kmph(x), 3, 1) + " km/h", v_true_x, v_true_y + 12);
                //g.DrawString("V: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.Mps2kt(x), 3, 1) + " kt", v_true_x, v_true_y + 24);

                x = ap.pMotion.wpos.y;
                //g.DrawString("ALT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x, 5, 1) + " m", alt_x, alt_y);
                //g.DrawString("ALT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(x), 5, 1) + " ft", alt_x, alt_y + 12);
            }

            double pitch = ap.pMotion.pitch.GetValue();
            double roll  = ap.pMotion.roll.GetValue();

            g.DrawString("PIT: " + DispFormat.DoubleFormat(MathTool.RadToDeg(pitch), 5, 1) + " deg", stdFont, informationBrush, 515, 12);
            g.DrawString("ROL: " + DispFormat.DoubleFormat(MathTool.RadToDeg(roll), 5, 1) + " deg", stdFont, informationBrush, 512, 89);
            tmat.SetTMat(550.0D, 45.0D, 0.0D);
            smat.SetSMat(30.0D, -30.0D, 0.0D);
            if ((roll > 1.570796326794897D) || (roll < -1.570796326794897D))
            {
                rmat.SetRzMat(Math.PI - pitch);
            }
            else
            {
                rmat.SetRzMat(pitch);
            }
            mat = smat.MultMat(rmat).MultMat(tmat);
            scine.Add(pitch_miniature_aircraft.Transform(mat));
            g.DrawEllipse(informationPen, 520, 15, 60, 60);
            tmat.SetTMat(550.0D, 121.0D, 0.0D);
            smat.SetSMat(30.0D, -30.0D, 0.0D);
            rmat.SetRzMat(-roll);
            mat = smat.MultMat(rmat).MultMat(tmat);
            scine.Add(roll_miniature_aircraft.Transform(mat));
            g.DrawEllipse(informationPen, 520, 91, 60, 60);

            if (simif.dispInformationSw == 1)
            {
                double x_0 = ap.atmos.h;
                //g.DrawString("H': " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 5, 1) + " m'", atmo_x, atmo_y);
                x_0 = ap.atmos.tc;
                //g.DrawString("t: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 4, 1) + " ��", atmo_x, atmo_y + 12);
                x_0 = ap.atmos.t;
                //g.DrawString("T: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 4, 1) + " K", atmo_x, atmo_y + 24);
                x_0 = ap.atmos.p;
                //g.DrawString("p: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0 / 100.0D, 4, 1) + " hPa", atmo_x + 90, atmo_y);
                x_0 = ap.atmos.rho;
                //g.DrawString("��: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 1, 3) + " kg/m3", atmo_x + 90, atmo_y + 12);
                x_0 = ap.atmos.a;
                // g.DrawString("a: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 3, 1) + " m/sec", atmo_x + 90, atmo_y + 24);
            }

            double alpha = ap.pMotion.alpha;
            double beta  = ap.pMotion.beta;

            if (simif.dispInformationSw == 1)
            {
                //g.DrawString("��: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(alpha), 3, 1) + " deg", 2, 60);
                // g.DrawString("��: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(beta), 3, 1) + " deg", 2, 72);
            }

            Vector3D vec = ap.pMotion.ov.SclProd(60000000.0D).MultMat(ap.pilot.ViewMatrix());

            if ((vec != null) && (vec.z > 0.0D))
            {
                vec = proj.Project(vec);
                tmat.SetTMat(vec.x, vec.y, vec.z);
                scine.Add(velocity_vector.Transform(tmat));
            }

            vec.SetVec(0.0D, 0.0D, 60000000.0D);
            vec = vec.MultMat(ap.pilot.ViewMatrix());
            if ((vec != null) && (vec.z > 0.0D))
            {
                vec = proj.Project(vec);
                tmat.SetTMat(vec.x, vec.y, vec.z);
                scine.Add(front_point.Transform(tmat));
            }

            vec   = ap.pMotion.force.R2l().SclProd(-1.0D / ap.inp.m);
            vec.z = 0.0D;
            double   x_1  = vec.Length();
            Vector3D vec2 = vec.NmlVec().SclProd(50.0D);

            vec = vec.NmlVec().SclProd(100.0D);
            Vector3D vec3 = vec.NmlVec().SclProd(113.0D);

            Jp.Maker1.Util.Symbol.DrawArrow(g, 300 + (int)vec2.x, 200 - (int)vec2.y, 300 + (int)vec.x, 200 - (int)vec.y, 50.0D, x_1 * 4.0D);
            //g.DrawString(Jp.Maker1.Util.DispFormat.DoubleFormat(x_1 / 9.80655D, 2) + "G", 286 + (int)vec3.x, 200 - (int)vec3.y);

            vec = ap.pMotion.force.R2l().SclProd(-1.0D / ap.inp.m);
            x_1 = vec.z;
            //  g.DrawString(Jp.Maker1.Util.DispFormat.DoubleFormat(x_1 / 9.80655D, 2) + "G", 120, 192);
            if (Math.Abs((int)(x_1 * 10.0D)) >= 1)
            {
                Jp.Maker1.Util.Symbol.DrawArrow(g, 150, 200, 150 + (int)(x_1 * 10.0D), 200, (int)(Math.Abs(x_1) * 10.0D), 10.0D);
                Jp.Maker1.Util.Symbol.DrawArrow(g, 450, 200, 450 - (int)(x_1 * 10.0D), 200, (int)(Math.Abs(x_1) * 10.0D), 10.0D);
            }

            int xx = 2;
            int yy = 100;

            vec = ap.pMotion.force.SclProd(-1.0D / ap.inp.m / 9.80655D);
            if (simif.dispInformationSw == 1)
            {
                //g.DrawString("Gx: " + Jp.Maker1.Util.DispFormat.DoubleFormat(vec.x, 2, 4) + " [G]", xx, yy);
                yy += 11;
                // g.DrawString("Gy: " + Jp.Maker1.Util.DispFormat.DoubleFormat(vec.y, 2, 4) + " [G]", xx, yy);
                yy += 11;
                //g.DrawString("Gz: " + Jp.Maker1.Util.DispFormat.DoubleFormat(vec.z, 2, 4) + " [G]", xx, yy);
                yy += 11;
            }

            if (ap.max_k_stall_wing > 1.0D)
            {
                //g.DrawString("STALL", stallAlert_x + 25, stallAlert_y);
            }
            else if (ap.max_k_stall_wing > 0.95D)
            {
                //g.DrawString("STALL WARNING", stallAlert_x, stallAlert_y);
            }

            //g.SetColor(instrumentColor);

            double yaw = ap.pMotion.yaw.GetValue();

            //g.DrawString("HDG: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(yaw), 5, 1) + " deg", 512, 165);
            tmat.SetTMat(550.0D, 197.0D, 0.0D);
            smat.SetSMat(30.0D, 30.0D, 0.0D);
            rmat.SetRzMat(yaw);
            mat = smat.MultMat(rmat).MultMat(tmat);
            scine.Add(heading_miniature_aircraft.Transform(mat));
            // g.DrawOval(520, 167, 60, 60);

            rzmat.SetRzMat(-ap.pMotion.roll.GetValue());
            rxmat.SetRxMat(-ap.pMotion.pitch.GetValue());
            mat = rxmat.MultMat(rzmat);
            Scine scine2 = new Scine();

            scine2.Add(artificial_horizon.Transform(mat.MultMat(ap.pilot.ViewMatrix())));
            Scine view = new Scine();

            view = scine2.MakeView(clip, proj, false);
            view.Draw(g);

            // g.SetFont(bigFont);
            x_1 = ap.pMotion.vc.Length() * Math.Sqrt(ap.atmos.rho / 1.225D);
            // g.DrawString("ASI: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.Mps2kt(x_1), 3, 0) + " kt", 190, 380);

            x_1 = ap.pMotion.wpos.y;
            //g.DrawString("ALT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(x_1), 5, 0) + " ft", 190, 396);

            x_1 = ap.pMotion.wv.y;
            //g.DrawString("VSI: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(x_1) * 60.0D, 5, 0) + " fpm", 305, 380);

            x_1 = ap.pMotion.omega.z;
            //           g.DrawString("YRT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(x_1) * 60.0D, 3, 0) + " deg/m", 305, 396);

            for (int i = 0; i < ap.n_LandingGear; i++)
            {
                if (ap.landing_gear[i, 1].flag == 1)
                {
                    xx = gear_x;
                }
                else
                {
                    xx = gear_x - gear_box_maegine / 2;
                }
                yy = gear_y + i * gear_box_maegine * 3;
                for (int lr = 0; lr <= 1; lr++)
                {
                    if (ap.landing_gear[i, lr].flag == 1)
                    {
                        int xx1;

                        if (lr == 0)
                        {
                            xx1 = xx + gear_box_maegine;
                        }
                        else
                        {
                            xx1 = xx;
                        }
                        x_1 = ap.landing_gear[i, lr].delta;
                        if (x_1 == 0.0D)
                        {
                            //g.SetColor(instrumentRed);
                            //g.FillRect(xx1 + 2, yy + 2, gear_box_size - 3, gear_box_size - 3);
                        }
                        else if (x_1 == 1.0D)
                        {
                            //g.SetColor(instrumentGreen);
                            //g.FillRect(xx1 + 2, yy + 2 + gear_box_maegine * 2, gear_box_size - 3, gear_box_size - 3);
                        }
                        else
                        {
                            // g.SetColor(instrumentYellow);
                            // g.FillRect(xx1 + 2, yy + 2 + gear_box_maegine, gear_box_size - 3, gear_box_size - 3);
                        }
                        //g.SetColor(instrumentColor);
                        //g.DrawRect(xx1, yy, gear_box_size, gear_box_size);
                        //g.DrawRect(xx1, yy + gear_box_maegine, gear_box_size, gear_box_size);
                        //g.DrawRect(xx1, yy + gear_box_maegine * 2, gear_box_size, gear_box_size);
                    }
                }
            }

            //g.SetFont(smallFont);
            ControlPlane flap = ap.t_flap[0, 0];

            if (ap.t_flap[0, 0].type != 0)
            {
                xx = flap_x;
                yy = flap_y;
                // g.DrawRect(xx, yy - flap_width, 10, flap_width);
                for (double ang = 0.0D; ang < MathTool.RadToDeg(flap.delta_max) + 0.1D; ang += 10.0D)
                {
                    x_1 = (MathTool.DegToRad(ang) - flap.delta_min) / (flap.delta_max - flap.delta_min);
                    int yy1 = yy - flap_width + (int)(flap_width * x_1 + 0.5D);
                    // g.DrawLine(xx + 10, yy1, xx + 13, yy1);
                    // g.DrawString("" + (int)ang, xx + 14, yy1);
                }
                x_1 = (flap.delta - flap.delta_min) / (flap.delta_max - flap.delta_min);
                int yy1_2 = (int)(flap_width * x_1 + 0.5D);
                // g.FillRect(xx + 2, yy - flap_width, 7, yy1_2);
            }
            //g.SetFont(stdFont);

            scine.Draw(g);
            //g.SetFont(stdFont);
        }
Esempio n. 10
0
        public void DrawData(Graphics g, SimulatorInterface simif)
        {
            if (recorder.N_record() == 0)
            {
                //g.SetColor(Java.Awt.Color.black);
                // g.SetFont(stdFont);
                // g.DrawString("No Data", 290, 180);
                return;
            }

            if (simif.record_output_sw == 1)
            {
                //  g.SetColor(Java.Awt.Color.red);
                //  g.SetFont(stdFont);
                //  g.DrawString("Writing Data", 270, 100);
                return;
            }

            RecordData data = recorder.GetData(currentDataIndex);

            VsPoint pos = new VsPoint(new Vector3D(data.wpos), Color.White);

            pos = (VsPoint)pos.Transform(mat);
            pos = (VsPoint)pos.Clip3DF(clip);
            pos = (VsPoint)pos.Project(proj);
            VsSegment seg = new VsSegment(new Vector3D(data.wpos), new Vector3D(
                                              data.wpos), suisenCol);

            seg.seg.p1.y = grid.ys;
            seg          = (VsSegment)seg.Transform(mat);
            seg          = (VsSegment)seg.Clip3DF(clip);
            seg          = (VsSegment)seg.Project(proj);
            seg.Draw(g);
            pos.Draw(g);
            if (pos.pos != null)
            {
                int px = (int)(pos.pos.x + 0.5D);
                int py = (int)(pos.pos.y + 0.5D);
                //g.SetColor(cursolCol);
                //g.DrawRect(px - 10, py - 10, 21, 21);
            }

            //g.SetColor(infoCol);
            //g.SetFont(stdFont);
            String str = "GRID SCALE:" + DispFormat.DoubleFormat(grid.grid_scale, 0) + "m";

            str = str + "   BASE ALT:" + DispFormat.DoubleFormat(LocusGrid.Y_base(locus.locusBBox), 0) + "m";
            // g.DrawString(str, 3, (int)(proj.screenYOffset + proj.screenYSize) - 4);

            str = "DATA No." + (currentDataIndex + 1) + " TIME:" + Jp.Maker1.Sim.Tools.Tool.TimeStr1(data.t);
            // g.DrawString(str, 300, 13);

            // g.SetFont(smallFont);

            int datax = 3;
            int datay = 30;
            int dy    = 10;

            if (simif.dispDataSw == 1)
            {
                double h = data.wpos.y;
                datay += 2;
                //g.DrawString("XE [m] : " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.wpos.x, 4, 1), datax, datay);
                datay += dy;
                //g.DrawString("YE [m] : " + Jp.Maker1.Util.DispFormat.DoubleFormat(h, 4, 1), datax, datay);
                datay += dy;
                //g.DrawString("ZE [m] : " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.wpos.z, 4, 1), datax, datay);
                datay += dy;
                //g.DrawString("YE [ft]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(h), 4, 1), datax, datay);
                datay += dy;
                datay += 2;
                double v = data.vcDash.Length();
                //g.DrawString("VC [m/s]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(v, 3, 1), datax, datay);
                datay += dy;
                double ias = Jp.Maker1.Sim.Tools.UnitConvert.Mps2kt(v) * Math.Sqrt(Isa.Density(h) / Isa.Density(0.0D));
                //g.DrawString("IAS [kt]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(ias, 3, 1), datax, datay);
                datay += dy;
                double alpha = MathTool.RadToDeg(Jp.Maker1.Sim.Tools.Tool.CalcAlpha(data.vcDash));
                datay += 2;
                //g.DrawString("ƒ¿ [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(alpha, 3, 1), datax, datay);
                datay += dy;
                double beta = MathTool.RadToDeg(Jp.Maker1.Sim.Tools.Tool.CalcBeta(data.vcDash));
                //g.DrawString("ƒÀ [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(beta, 3, 1), datax, datay);
                datay += dy;
                datay += 2;
                //  g.DrawString("ƒ³ [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.roll.GetValue()), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("ƒ¦ [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.pitch.GetValue()), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("ĵ [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.yaw.GetValue()), 3, 1), datax, datay);
                datay += dy;
                datay += 2;
                // g.DrawString("P [deg/s]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.omega.x), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("Q [deg/s]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.omega.y), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("R [deg/s]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.omega.z), 3, 1), datax, datay);
                datay += dy;
                datay += 2;
                // g.DrawString("dU/dt [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.d_vc.x, 2, 1), datax, datay);
                datay += dy;
                // g.DrawString("dV/dt [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.d_vc.y, 2, 1), datax, datay);
                datay += dy;
                // g.DrawString("dW/dt [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.d_vc.z, 2, 1), datax, datay);
                datay += dy;
                datay += 2;
                // g.DrawString("dP/dt [deg/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.d_omega.x), 3, 1), datax, datay);
                datay += dy;
                //g.DrawString("dQ/dt [deg/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.d_omega.y), 3, 1), datax, datay);
                datay += dy;
                //  g.DrawString("dR/dt [deg/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.d_omega.z), 3, 1), datax, datay);
                datay += dy;
                datay += 2;
                //g.DrawString("Į [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.theta), 3, 1), datax, datay);
                datay += dy;
                datay += 2;
                //g.DrawString("Fx/m [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.f_m.x, 3, 1), datax, datay);
                datay += dy;
                //g.DrawString("Fy/m [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.f_m.y, 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("Fz/m [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.f_m.z, 3, 1), datax, datay);
                datay += dy;
                datay += 2;
                // g.DrawString("ƒÂe [deg] : " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.delta_e), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("ƒÂaR [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.delta_a_r), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("ƒÂaL [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.delta_a_l), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("ƒÂr [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.delta_r), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("ƒÂf [deg]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(data.delta_t_flap), 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("L.GEAR: " + data.flag_gear, datax, datay);
                datay += dy;
                // g.DrawString("LAND: " + data.flag_land, datax, datay);
                datay += dy;
                datay += 2;
                // g.DrawString("Thrust/m [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.thrust_m, 3, 1), datax, datay);
                datay += dy;
                // g.DrawString("THR-POS [m/s2]: " + Jp.Maker1.Util.DispFormat.DoubleFormat(data.throttle_pos, 3, 2), datax, datay);
                datay += dy;
            }
        }
Esempio n. 11
0
        public void UpdateDispParam(SimulatorInterface simif, double dt)
        {
            Matrix44 mtemp   = new Matrix44();
            Matrix44 mat_aft = new Matrix44();

            BoundingBox bbx = locus.locusBBox;
            double      v   = bbx.DiagonalSize() / moveingTime;
            double      w   = 6.283185307179586D / rotationTime;

            double acc = 1.0D;

            if (simif.ctrl_sw == 1)
            {
                acc = 0.1D;
            }
            if (simif.locus_action_sw[0] == 1)
            {
                mtemp.SetRzMat(-w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[1] == 1)
            {
                mtemp.SetRzMat(w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[2] == 1)
            {
                mtemp.SetRxMat(w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[3] == 1)
            {
                mtemp.SetRxMat(-w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[4] == 1)
            {
                mtemp.SetRyMat(w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[5] == 1)
            {
                mtemp.SetRyMat(-w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[6] == 1)
            {
                dist -= v * dt * 3.0D * acc;
                mtemp.SetTMat(0.0D, 0.0D, -v * dt * 3.0D * acc);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[7] == 1)
            {
                dist += v * dt * 3.0D * acc;
                mtemp.SetTMat(0.0D, 0.0D, v * dt * 3.0D * acc);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[10] == 1)
            {
                mtemp.SetTMat(v * dt * acc, 0.0D, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[11] == 1)
            {
                mtemp.SetTMat(-v * dt * acc, 0.0D, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[8] == 1)
            {
                mtemp.SetTMat(0.0D, v * dt * acc, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[9] == 1)
            {
                mtemp.SetTMat(0.0D, -v * dt * acc, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }

            if (simif.param_reset_sw == 1)
            {
                InitDispParam();
                simif.locusImageMake = 1;
                simif.param_reset_sw = 0;
            }

            int flag_move_data = 0;

            if (simif.data_foword_sw == 1)
            {
                flag_move_data = 1;
                if (simif.ctrl_sw == 1)
                {
                    currentDataIndex += fastMoveStep;
                }
                else
                {
                    currentDataIndex += 1;
                }
                if (currentDataIndex >= recorder.N_record())
                {
                    currentDataIndex = (recorder.N_record() - 1);
                }
            }
            if (simif.data_back_sw == 1)
            {
                flag_move_data = 1;
                if (simif.ctrl_sw == 1)
                {
                    currentDataIndex -= fastMoveStep;
                }
                else
                {
                    currentDataIndex -= 1;
                }
                if (currentDataIndex < 0)
                {
                    currentDataIndex = 0;
                }
            }
            if (flag_move_data == 1)
            {
                RecordData data = recorder.GetData(currentDataIndex);
                mtemp.SetMat(mat_bef);
                mat_bef.SetTMat(-data.wpos.x, -data.wpos.y, -data.wpos.z);
                mat_aft = mat_bef.InvMat().MultMat(mtemp).MultMat(rmat).MultMat(tmat);
                rmat    = mat_aft.DtMat();
                tmat.SetTMat(mat_aft.element[3, 0], mat_aft.element[3, 1], mat_aft.element[3, 2]);
            }
        }