public void InitDispParam() { BoundingBox bbx = locus.locusBBox; RecordData data = recorder.GetData(currentDataIndex); dist = (bbx.DiagonalSize() / 2.0D / System.Math.Tan(MathTool.DegToRad(25.0D) / 2.0D)); cx = ((bbx.GetMaxX() + bbx.GetMinX()) / 2.0D); cy = ((bbx.GetMaxY() + bbx.GetMinY()) / 2.0D); cz = ((bbx.GetMaxZ() + bbx.GetMinZ()) / 2.0D); mat_bef.SetTMat(-data.wpos.x, -data.wpos.y, -data.wpos.z); rmat.SetUMat(); tmat.SetTMat(-cx + data.wpos.x, -cy + data.wpos.y, -cz + data.wpos.z + dist); }
public LocusViewer(double sX0, double sY0, double sX1, double sY1, AirPlane ap, Recorder rec) { planeM = new Material(new LightColor(0.0D, 0.0D, 0.6D), new LightColor(0.5D, 0.5D, 0.5D), 10.0D, new LightColor(0.0D, 0.0D, 0.0D)); planeM2 = new Material(new LightColor(0.6D, 0.0D, 0.0D), new LightColor(0.5D, 0.5D, 0.5D), 10.0D, new LightColor(0.0D, 0.0D, 0.0D)); light = Jp.Maker1.Vsys3.Tools.Light.Parallel(new LightColor(255.0D, 255.0D, 255.0D), new Vector3D(0.5D, -0.5D, 1.0D)); amblight = Jp.Maker1.Vsys3.Tools.Light.Ambience(new LightColor(128.0D, 128.0D, 128.0D)); infoCol = Color.FromArgb(64, 64, 64); dataCol = Color.Gray; cursolCol = Color.FromArgb(255, 0, 0); suisenCol = Color.Gray; stdFont = new Font("SansSelif", 12); smallFont = new Font("SansSelif", 11); sc = new Scine(); oa = new OpticalAmbience(); viewAngle = 25.0D; grid = new LocusGrid(); rmat = new Matrix44(); tmat = new Matrix44(); mat_bef = new Matrix44(); mat = new Matrix44(); moveingTime = 5.0D; rotationTime = 7.0D; currentDataIndex = 0; proj = new Projector(sX1 - sX0 + 1.0D, sY1 - sY0 + 1.0D, MathTool.DegToRad(25.0D)); clip = new Clipper(sX0, sY0, sX1, sY1); oa.AddLight(light); oa.AddLight(amblight); recorder = rec; locus = new Locus(ap, rec, planeM, planeM2); InitDispParam(); fastMoveStep = (recorder.N_record() / 50); if (fastMoveStep <= 0) { fastMoveStep = 1; } }
private void ReadWing(Wing wg, int hv_arrangement, bool flagMessage) { double[] b2f_beta = { -90.0D, -80.0D, -70.0D, -60.0D, -50.0D, -40.0D, -30.0D, -20.0D, -10.0D, 0, 10.0D, 20.0D, 30.0D, 40.0D, 50.0D, 60.0D, 70.0D, 80.0D, 90.0D }; double[] b2f_b = new double[19]; int i; for (i = 0; i < b2f_beta.Length; i++) { b2f_beta[i] = MathTool.DegToRad(b2f_beta[i]); } wg.flag = 1; wg.name = ReadString("name", flagMessage); wg.n_lr = ReadIntValue("n", flagMessage); wg.hv_arrangement = hv_arrangement; wg.s2 = ReadDblValue("S/n", flagMessage); Pass("b/n = "); for (i = 0; i < 19; i++) { b2f_b[i] = ReadDouble(); } wg.b2_func = new Function2D(b2f_beta, b2f_b); wg.k_ar = ReadDblValue("k_Ar", flagMessage); wg.n_wing_block = ReadIntValue("wing_block", flagMessage); wg.wp = new WingPlane[wg.n_wing_block, 2]; for (i = 0; i < wg.n_wing_block; i++) { wg.wp[i, 0] = new WingPlane(); wg.wp[i, 1] = new WingPlane(); WingPlane wpR = wg.wp[i, 0]; WingPlane wpL = wg.wp[i, 1]; ReadWingPlane(wg, wpR, wpL, flagMessage); } }
public static VsObject Qube(int r, int g, int b, double shadeRate) { VsObject ret = new VsObject(); VsPolygon a = Square(r, g, b); Matrix44 m = new Matrix44(); m.SetTMat(0.0D, 0.0D, -0.5D); a = (VsPolygon)a.Transform(m); ret.Add(a); m.SetRyMat(MathTool.DegToRad(180.0D)); ret.Add(a.Transform(m)); double k = 1.0D - shadeRate; if (k < 0.0D) { k = 0.0D; } a.col = Color.FromArgb((int)(r * k), (int)(g * k), (int)(b * k)); m.SetRyMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRyMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); k = 1.0D - shadeRate * 2.0D; if (k < 0.0D) { k = 0.0D; } a.col = Color.FromArgb((int)(r * k), (int)(g * k), (int)(b * k)); m.SetRxMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRxMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); return(ret); }
public static VsPolygon RegularPolygon(int n, int r, int g, int b) { double[] x = new double[n]; double[] y = new double[n]; double[] z = new double[n]; double angleStep = 360.0D / n; double startAngle = 270.0D - angleStep / 2.0D; for (int i = 0; i < n; i++) { double angle = startAngle + angleStep * i; if (angle > 360.0D) { angle -= 360.0D; } x[i] = (Math.Cos(MathTool.DegToRad(angle)) / 2.0D); y[i] = (Math.Sin(MathTool.DegToRad(angle)) / 2.0D); z[i] = 0.0D; } VsPolygon ret = new VsPolygon(n, x, y, z, r, g, b); return(ret); }
public static VsPolygon4 RegularPolygonM2(int n, Material mate, Material mate2) { double[] x = new double[n]; double[] y = new double[n]; double[] z = new double[n]; double angleStep = 360.0D / n; double startAngle = 270.0D - angleStep / 2.0D; for (int i = 0; i < n; i++) { double angle = startAngle + angleStep * i; if (angle > 360.0D) { angle -= 360.0D; } x[i] = (Math.Cos(MathTool.DegToRad(angle)) / 2.0D); y[i] = (Math.Sin(MathTool.DegToRad(angle)) / 2.0D); z[i] = 0.0D; } VsPolygon4 ret = new VsPolygon4(n, x, y, z, mate, mate2); return(ret); }
public static VsObject QubeM(Material mate) { VsObject ret = new VsObject(); VsPolygon3 a = SquareM(mate); Matrix44 m = new Matrix44(); m.SetTMat(0.0D, 0.0D, -0.5D); a = (VsPolygon3)a.Transform(m); ret.Add(a); m.SetRyMat(MathTool.DegToRad(180.0D)); ret.Add(a.Transform(m)); m.SetRyMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRyMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); m.SetRxMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRxMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); return(ret); }
public VsObject MakeGrid(BoundingBox bbox, double dist, double viewAngle) { double range_base = bbox.XSize(); if (range_base < bbox.ZSize()) { range_base = bbox.ZSize(); } double k = dist / (bbox.DiagonalSize() / 2D / System.Math.Tan(MathTool.DegToRad(viewAngle) / 2D)); range_base *= k; grid_scale = Kizami(range_base); if (grid_scale < 50D) { grid_scale = 50D; } xs = Start(bbox.GetMinX() - 10D, grid_scale); xe = End(bbox.GetMaxX() + 10D, grid_scale); zs = Start(bbox.GetMinZ() - 10D, grid_scale); ze = End(bbox.GetMaxZ() + 10D, grid_scale); ys = Y_base(bbox); Vector3D v1 = new Vector3D(xs, 0.0D, zs); Vector3D v2 = new Vector3D(xe, 0.0D, zs); Vector3D v3 = new Vector3D(xe, 0.0D, ze); Vector3D v4 = new Vector3D(xs, 0.0D, ze); Vector3D v5 = new Vector3D(xs, ys, zs); Vector3D v6 = new Vector3D(xe, ys, zs); Vector3D v7 = new Vector3D(xe, ys, ze); Vector3D v8 = new Vector3D(xs, ys, ze); VsPolygon groundPol = new VsPolygon(); groundPol.col = groundcCol; groundPol.pol.AddVertex(v1); groundPol.pol.AddVertex(v2); groundPol.pol.AddVertex(v3); groundPol.pol.AddVertex(v4); grid = new VsObject(); grid.Add(groundPol); grid.Add(Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.0D, xs, zs, xe, ze, grid_scale, grid_scale, groundGridCol)); if (ys > 0.0D) { grid.Add(new VsSegment(v1, v5, yBaseGridCol)); grid.Add(new VsSegment(v2, v6, yBaseGridCol)); grid.Add(new VsSegment(v3, v7, yBaseGridCol)); grid.Add(new VsSegment(v4, v8, yBaseGridCol)); VsPolygon basePol = new VsPolygon(); basePol.col = yBaseCol; basePol.pol.AddVertex(v5); basePol.pol.AddVertex(v6); basePol.pol.AddVertex(v7); basePol.pol.AddVertex(v8); grid.Add(basePol); grid.Add(Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(ys, xs, zs, xe, ze, grid_scale, grid_scale, yBaseGridCol)); } grid.Add(new VsString(DispFormat.DoubleFormat(ys, 0) + "m", v5, Color.Gray, smallFont)); grid.Add(new VsString(DispFormat.DoubleFormat(ys, 0) + "m", v6, Color.Gray, smallFont)); grid.Add(new VsString(DispFormat.DoubleFormat(ys, 0) + "m", v7, Color.Gray, smallFont)); grid.Add(new VsString(DispFormat.DoubleFormat(ys, 0) + "m", v8, Color.Gray, smallFont)); grid.Add(new VsString("NORTH", v7.Add(v8).SclProd(0.5D), Color.Gray, smallFont)); grid.Add(new VsString("SOUTH", v5.Add(v6).SclProd(0.5D), Color.Gray, smallFont)); grid.Add(new VsString("WEST", v8.Add(v5).SclProd(0.5D), Color.Gray, smallFont)); grid.Add(new VsString("EAST", v7.Add(v6).SclProd(0.5D), Color.Gray, smallFont)); return(grid); }
private void ReadControlPlane(Wing wg, ControlPlane cpR, ControlPlane cpL, bool flagMessage) { cpR.type = 0; cpL.type = 0; String typeStr = ReadString("type", flagMessage); if (typeStr.Equals("all_flying")) { cpR.type = 2; } else if (typeStr.Equals("tailing_edge")) { cpR.type = 1; } else if (typeStr.Equals("leading_edge")) { cpR.type = 1; } else { cpR.type = 0; } typeStr = ReadString("actuate_type", flagMessage); if (typeStr.Equals("actuator_drive")) { cpR.actuate_type = 1; } else { cpR.actuate_type = 0; } if (wg.n_lr == 2) { cpL.type = cpR.type; cpL.actuate_type = cpR.actuate_type; } ReadWingPlane(wg, cpR.baseWingBlock, cpL.baseWingBlock, flagMessage); cpR.delta_max = MathTool.DegToRad(ReadDblValue("delta_max", flagMessage)); cpR.delta_min = MathTool.DegToRad(ReadDblValue("delta_min", flagMessage)); cpR.lamda_h = MathTool.DegToRad(ReadDblValue("lamda_H", flagMessage)); if (cpL.type != 0) { cpL.delta_max = cpR.delta_max; cpL.delta_min = cpR.delta_min; cpL.lamda_h = cpR.lamda_h; } if ((cpR.type == 1) || (cpR.type == 1)) { ReadControlPlaneFlapType(cpR, cpL, flagMessage); } if (cpR.type == 2) { ReadControlPlaneAllFType(cpR, cpL, flagMessage); } if (cpR.actuate_type == 1) { cpR.t_move = ReadDblValue("t_moving", flagMessage); if ((cpL.baseWingBlock != null) && (cpL.baseWingBlock.flag == 1)) { cpL.t_move = cpR.t_move; } } cpR.Init(); cpL.Init(); }
private void ReadWingPlane(Wing wg, WingPlane wpR, WingPlane wpL, bool flagMessage) { wpR.flag = 0; wpL.flag = 0; wpR.block_name = ReadString("block_name", flagMessage); if (wg.n_lr >= 1) { wpR.flag = 1; wpR.wing = wg; if (wg.hv_arrangement == 0) { wpR.arrangement = 1; } else { wpR.arrangement = 3; } wpR.s2 = ReadDblValue("S/n", flagMessage); wpR.ac_base = ReadVector("Ac", flagMessage); wpR.gc = ReadVector("Gc", flagMessage); wpR.gamma = MathTool.DegToRad(ReadDblValue("gamma", flagMessage)); wpR.delta = MathTool.DegToRad(ReadDblValue("delta", flagMessage)); wpR.lamda = MathTool.DegToRad(ReadDblValue("lamda", flagMessage)); wpR.t_c = ReadDblValue("t/c", flagMessage); wpR.a0 = ReadDblValue("a0", flagMessage); wpR.alpha0 = MathTool.DegToRad(ReadDblValue("alpha0", flagMessage)); wpR.clmax = ReadDblValue("CLmax", flagMessage); wpR.delta_clmax = ReadDblValue("delta_CLmax", flagMessage); wpR.delta_alphe_p = MathTool.DegToRad(ReadDblValue("delta_alpha_p", flagMessage)); wpR.clmin = ReadDblValue("CLmin", flagMessage); wpR.delta_clmin = ReadDblValue("delta_CLmin", flagMessage); wpR.delta_alphe_m = MathTool.DegToRad(ReadDblValue("delta_alpha_m", flagMessage)); wpR.alpha_i = MathTool.DegToRad(ReadDblValue("alpha_i", flagMessage)); wpR.cdmin = ReadDblValue("CDmin", flagMessage); wpR.k_cd = ReadDblValue("k_cd", flagMessage); wpR.delta_cdmin = ReadDblValue("delta_CDmin", flagMessage); wpR.alpha_backet = MathTool.DegToRad(ReadDblValue("alpha_backet", flagMessage)); wpR.cmac = ReadDblValue("Cmac", flagMessage); wpR.ew = ReadDblValue("ew", flagMessage); wpR.mc = ReadDblValue("Mc", flagMessage); wpR.Init(); } if (wg.n_lr == 2) { wpL.flag = 1; wpL.wing = wg; wpL.block_name = wpR.block_name; if (wg.hv_arrangement == 0) { wpL.arrangement = 2; } else { wpL.arrangement = 4; } wpL.s2 = wpR.s2; wpL.ac_base = wpR.ac_base; wpL.gc = wpR.gc; wpL.gamma = wpR.gamma; wpL.delta = wpR.delta; wpL.lamda = wpR.lamda; wpL.t_c = wpR.t_c; wpL.a0 = wpR.a0; wpL.alpha0 = wpR.alpha0; wpL.clmax = wpR.clmax; wpL.delta_clmax = wpR.delta_clmax; wpL.delta_alphe_p = wpR.delta_alphe_p; wpL.clmin = wpR.clmin; wpL.delta_clmin = wpR.delta_clmin; wpL.delta_alphe_m = wpR.delta_alphe_m; wpL.alpha_i = wpR.alpha_i; wpL.cdmin = wpR.cdmin; wpL.k_cd = wpR.k_cd; wpL.delta_cdmin = wpR.delta_cdmin; wpL.alpha_backet = wpR.alpha_backet; wpL.cmac = wpR.cmac; wpL.ew = wpR.ew; wpL.mc = wpR.mc; wpL.Init(); } }
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); }
public GraphicsGenerator(Uri codeBase, double sX0, double sY0, double sX1, double sY1) { sc = new Scine(); oa = new OpticalAmbience(); bgColor = Color.FromArgb(134, 171, 225); earthColorRed = 50; earthColorGreen = 93; earthColorBlue = 45; glid1mColor = Color.FromArgb(55, 102, 48); glid10mColor = Color.FromArgb(61, 113, 59); glid100mColor = Color.FromArgb(67, 124, 65); glid1kmColor = Color.FromArgb(61, 113, 59); glid10kmColor = Color.FromArgb(55, 102, 48); runwayColorRed = 151; runwayColorGreen = 151; runwayColorBlue = 159; gridRunwayColor = Color.FromArgb(160, 160, 170); interfaceColorPen = new Pen(Color.FromArgb(200, 200, 255)); interfaceColorBrush = new SolidBrush(Color.FromArgb(200, 200, 255)); interfaceColorDPen = new Pen(Color.FromArgb(180, 180, 235)); instrumentColor = Color.FromArgb(255, 255, 255); instrumentGreen = Color.FromArgb(128, 200, 128); instrumentYellow = Color.FromArgb(200, 200, 128); instrumentRed = Color.FromArgb(200, 128, 128); informationColor = Color.FromArgb(220, 220, 255); simInterfaceColor = Color.FromArgb(230, 255, 200); padLockColor = Color.FromArgb(200, 200, 255); stdFont = new Font("SansSelif", 12); bigFont = new Font("SansSelif", 16); smallFont = new Font("SansSelif", 9); padFont = new Font("SansSelif", 11); stick_center_x = 300; stick_center_y = 200; stick_x_width = 140; stick_y_width = 140; rudder_center_x = 300; rudder_center_y = 320; rudder_x_witdh = 45; rudder_y_width = 30; throttle_x = 10; throttle_y = 390; throttle_width = 100; mixture_x = 25; mixture_y = 390; mixture_width = 100; prop_pitch_x = 40; prop_pitch_y = 390; prop_pitch_width = 100; brake_right_x = 580; brake_right_y = 390; brake_right_width = 100; brake_left_x = 565; brake_left_y = 390; brake_left_width = 100; instrument_object_list = new VsObjectList(); v_true_x = 100; v_true_y = 12; alt_x = 185; alt_y = 12; atmo_x = 280; atmo_y = 12; gear_x = 130; gear_y = 325; gear_box_size = 9; gear_box_maegine = 12; flap_x = 450; flap_y = 395; flap_width = 100; stallAlert_x = 257; stallAlert_y = 140; pause_x = 275; pause_y = 100; slowMoton_x = 245; slowMoton_y = 115; proj = new Projector(sX1 - sX0 + 1.0D, sY1 - sY0 + 1.0D, MathTool.DegToRad(45.0D)); proj.SetVerticalParamer(0.0D, 0.0D, sX1 - sX0 + 1.0D, sY1 - sY0 + 1.0D, MathTool.DegToRad(45.0D)); clip = new Clipper(sX0, sY0, sX1, sY1); Matrix44 mtemp = new Matrix44(); Matrix44 smat = new Matrix44(); mtemp.SetRxMat(MathTool.DegToRad(90.0D)); earth = ((VsPolygon)Jp.Maker1.Vsys3.Tools.BasicObject.RegularPolygon(32, earthColorRed, earthColorGreen, earthColorBlue).Transform(mtemp)); glid10km = Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.0D, -50000.0D, -50000.0D, 50000.0D, 50000.0D, 10000.0D, 10000.0D, glid10kmColor); glid1km = Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.0D, -10000.0D, -10000.0D, 10000.0D, 10000.0D, 1000.0D, 1000.0D, glid1kmColor); glid100m = Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.0D, -1000.0D, -1000.0D, 1000.0D, 1000.0D, 100.0D, 100.0D, glid100mColor); glid10m = Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.0D, -200.0D, -200.0D, 200.0D, 200.0D, 10.0D, 10.0D, glid10mColor); glid1m = Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.0D, -30.0D, -30.0D, 30.0D, 30.0D, 1.0D, 1.0D, glid1mColor); smat.SetSMat(60.0D, 0.0D, 1000.0D); runway = ((VsPolygon)Jp.Maker1.Vsys3.Tools.BasicObject.Square(runwayColorRed, runwayColorGreen, runwayColorBlue).Transform(mtemp.MultMat(smat))); glid_runway = Jp.Maker1.Vsys3.Tools.BasicObject.XzGlid(0.1D, -30.0D, -500.0D, 30.0D, 500.0D, 10.0D, 10.0D, gridRunwayColor); FormUnitFile fmu = new FormUnitFile(instrument_object_list, codeBase, "data/instrument.fmu", "data/instrument.mdf"); pitch_miniature_aircraft = instrument_object_list.Get("PITCH_MINIATURE_ARECRAFT"); pitch_miniature_aircraft.SetColor(informationColor); roll_miniature_aircraft = instrument_object_list.Get("ROLL_MINIATURE_ARECRAFT"); roll_miniature_aircraft.SetColor(informationColor); heading_miniature_aircraft = instrument_object_list.Get("HEADING_MINIATURE_ARECRAFT"); heading_miniature_aircraft.SetColor(instrumentColor); velocity_vector = instrument_object_list.Get("VELOCITY_VECTOR"); velocity_vector.SetColor(informationColor); artificial_horizon = instrument_object_list.Get("ARTIFICIAL_HORIZON"); artificial_horizon.SetColor(instrumentColor); front_point = instrument_object_list.Get("FRONT_POINT"); front_point.SetColor(informationColor); }