public void CreateView(Graphics g, Vector3D pos, Matrix44 wem)
        {
            Scine scn = new Scine();

            scn.optamb = oa;
            scn.Add(MakeEarth(pos).Transform(wem));
            Scine view = scn.MakeView(clip, proj, false);

            // g.SetColor(bgColor);
            //g.FillRect((int)clip.vp_xmin, (int)clip.vp_ymin, (int)(clip.vp_xmax - clip.vp_xmin + 1.0D), (int)(clip.vp_ymax - clip.vp_ymin + 1.0D));
            g.FillRectangle(new SolidBrush(bgColor), (int)clip.vp_xmin, (int)clip.vp_ymin, (int)(clip.vp_xmax - clip.vp_xmin + 1.0D), (int)(clip.vp_ymax - clip.vp_ymin + 1.0D));
            view.Draw(g);
        }
        public void DrawLocus(Graphics g, int mode)
        {
            if (mode == 1)
            {
                // g.SetColor(Java.Awt.Color.white);
                //g.FillRect((int)clip.vp_xmin, (int)clip.vp_ymin, (int)(clip.vp_xmax - clip.vp_xmin + 1.0D), (int)(clip.vp_ymax - clip.vp_ymin + 1.0D));
            }

            mat = mat_bef.MultMat(rmat).MultMat(tmat);

            sc        = new Scine();
            sc.optamb = oa;
            sc.Add((VsElement)grid.MakeGrid(locus.locusBBox, dist, 25.0D).Transform(mat));
            Scine view = sc.MakeView(clip, proj, false);

            view.Draw(g);

            if (mode == 1)
            {
                sc        = new Scine();
                sc.optamb = oa;
                sc.Add((VsElement)locus.locus.Transform(mat));
                sc.Add((VsElement)locus.groundLocus.Transform(mat));
                sc.Add((VsElement)locus.ybaseLocus.Transform(mat));
                view = sc.MakeView(clip, proj, true);

                view.Draw(g, 1);

                if (recorder.N_record() > 0)
                {
                    //g.SetColor(infoCol);
                    //g.SetFont(stdFont);
                    //g.DrawString("REC. FROM " + Jp.Maker1.Sim.Tools.Tool.TimeStr1(recorder.GetData(0).t) + " TO " + Jp.Maker1.Sim.Tools.Tool.TimeStr1(recorder.GetData(recorder.N_record() - 1).t), 3, 13);
                }
            }
        }
        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);
        }