Rise
The Vieneo Province
Loading...
Searching...
No Matches
IndicatedAirSpeed2.cpp
Go to the documentation of this file.
1#include "../Instrument.h"
2#include "../../Bus.h"
3
4IndicatedAirSpeed2::IndicatedAirSpeed2(int prmX, int prmY, float prmXScale, float prmYScale, Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice, std::vector<Font*> prmFonts) :
5 Instrument(prmX, prmY, prmXScale, prmYScale, prmBus, prmLogger, prmDevice, prmFonts)
6{
7 logger->AddToCallStack("IndicatedAirSpeed2::ctor");
8 defaultFont = 1;
9
10 tape = new Sprite(logger, pDevice, "Textures/Instruments/iastape2.png", prmX - 8, prmY, 0.1f, 0, 0, 29, 484, 0xFFFFFFFF);
11 overspeed = new Sprite(logger, pDevice, "Textures/Instruments/barberPole.png", prmX + 18, prmY, 0.2f, 0, 0, 3, 128, 0xFFFFFFFF);
12 stall = new Sprite(logger, pDevice, "Textures/Instruments/barberPole.png", prmX + 18, prmY, 0.2f, 0, 0, 3, 128, 0xFFFFFFFF);
13 bug = new Sprite(logger, pDevice, "Textures/Instruments/airspeedBug.png", prmX, prmY, 0.8f, 0, 0, 18, 33, 0xFFff3be9, 0.3f, 0.4f);
14 trend = new Sprite(logger, pDevice, "Textures/Instruments/cas-bar.png", prmX, prmY, 1.0f, 0, 0, 3, 256, 0xFFFFFFFF);
15 cueVr = new Sprite(logger, pDevice, "Textures/Instruments/airspeedCueR.png", prmX, prmY, 1.0f, 0, 0, 12, 7, 0xFF00FFFF);
16 cueVref = new Sprite(logger, pDevice, "Textures/Instruments/airspeedCueRef.png", prmX, prmY, 1.0f, 0, 0, 12, 7, 0xFF00FFFF);
17}
18
20{
21 tape->Draw();
22 if (bus->AirDensityScalar > 0 && bus->ComputedVneKms > 0)
23 overspeed->Draw();
24 trend->Draw();
25 if (playerships[0].reference != REF_ONGROUND)
26 stall->Draw();
27 else if (ourcockpit.wheeled)
28 DrawTextW(strVr, -6, 92, 0.95f, DT_NOCLIP, 0xff53d5fd, 1, "");
29 if (bus->AFCS.DesiredIasKms >= 0.02f)
30 bug->Draw();
31
33 cueVr->Draw();
34
35 cueVref->Draw();
36}
37
39{
40 const float ms2px = 1500.0f;
41
42 // ias tape
43 // 15px per 0.010m/s... 0.02 should be 10 perfect *1500
44 // test mode
45 //bus->IndicatedAirspeedKms = 0.04f;
46 short offsetY = static_cast<short>(RiseMath::Max(0.02f, bus->IndicatedAirspeedKms) * ms2px); // /20*10*1000
47 tape->SetRectangle(483 - 54 - offsetY, 0, 29, 483 + 73 - offsetY);
48 tape->Update();
49
50 // test mode
51 //ourcockpit.Vne = 0.05f;
52 if (bus->AirDensityScalar > 0 && bus->ComputedVneKms > 0)
53 {
54 offsetY = static_cast<short>((RiseMath::Max(0.02f, bus->IndicatedAirspeedKms) - bus->ComputedVneKms) * ms2px); // 120 - 100 means we are 20 away or 4px
55 overspeed->SetRectangle(128 - offsetY - 70, 0, 3, 128);
57 }
58
59 // @todo waiting to hear back from rana about what altitude we can cut off the display at
60 offsetY = static_cast<short>((RiseMath::Max(0.02f, bus->IndicatedAirspeedKms) - bus->ComputedVsKms) * ms2px); // 120 - 100 means we are 20 away or 4px
61 stall->SetLocation(x + 18, y + 70 + offsetY);
62 if (offsetY > 57)
63 offsetY = 57;
64 stall->SetRectangle(0, 0, 3, 57 - offsetY);
65 stall->Update();
66
67 const float delta = (bus->IndicatedAirspeedKms - oldIndicatedAirspeedKms) / fElapsed * 10.0f;
69 smoothDelta += (delta - smoothDelta) * fElapsed;
70 const int scaledDelta = static_cast<int>(smoothDelta * ms2px);
71 const int bottom = RiseMath::Max(-56, RiseMath::Min(70, scaledDelta));
72 trend->SetRectangle(0, 0, 3, bottom);
73 trend->SetLocation(30, 97 - bottom);
74 trend->Update();
75
76 // test mode
77 //bus->AFCS.DesiredIasKms = 0.04f;
78 offsetY = 63 + static_cast<short>((RiseMath::Max(0.02f, bus->IndicatedAirspeedKms) - bus->AFCS.DesiredIasKms) * ms2px); // 120 - 100 means we are 20 away or 4px
79 if (offsetY < -13) // height
80 offsetY = -13;
81 else if (offsetY > 127)
82 offsetY = 127;
83 bug->SetLocation(x + 16, y + offsetY);
84 bug->Update();
85
86
87 offsetY = 65 + static_cast<short>((RiseMath::Max(0.02f, bus->IndicatedAirspeedKms) - bus->ComputedVrKms) * ms2px); // 120 - 100 means we are 20 away or 4px
88 if (offsetY < -7) // height
89 offsetY = -7;
90 else if (offsetY > 127)
91 offsetY = 127;
92 cueVr->SetLocation(x + 19, y + offsetY);
93 cueVr->Update();
94 swprintf_s(strVr, sizeof strVr, L"%3.0f-R", bus->ComputedVrKms * 1000.0f);
95
96 offsetY = 65 + static_cast<short>((RiseMath::Max(0.02f, bus->IndicatedAirspeedKms) - bus->ComputedVsKms * ourcockpit.VrefMod) * ms2px); // 120 - 100 means we are 20 away or 4px
97 if (offsetY < -7) // height
98 offsetY = -7;
99 else if (offsetY > 127)
100 offsetY = 127;
101 cueVref->SetLocation(x + 19, y + offsetY);
102 cueVref->Update();
103
104 if (bus->IndicatedAirspeedKms <= 0.02f && (playerships[0].reference == REF_ONGROUND || playerships[0].mslKm > 10.0f))
105 airspeedAlive = false;
106 else if (!airspeedAlive && bus->IndicatedAirspeedKms > 0.02f)
107 {
108 airspeedAlive = true;
109 Command command;
110 command.name = "AuralAirspeedAlive";
111 bus->commandStream.emplace_back(command);
112 }
113
114 /*if (playerships[0].reference == REF_ONGROUND)
115 {
116 if (bus->IndicatedAirspeedKms <= 0.02f)
117 {
118 v1 = false;
119 v2 = false;
120 }
121 if (!v1 && bus->IndicatedAirspeedKms > ourcockpit.V1)
122 {
123 v1 = true;
124 Command command;
125 command.name = "AuralV1";
126 bus->commandStream.emplace_back(command);
127 }
128 if (!v2 && bus->IndicatedAirspeedKms > ourcockpit.V2)
129 {
130 v2 = true;
131 Command command;
132 command.name = "AuralV2";
133 bus->commandStream.emplace_back(command);
134 }
135 }*/
136}
@ REF_ONGROUND
Definition ServerTypes.h:43
Definition Bus.h:20
float IndicatedAirspeedKms
Definition Bus.h:34
struct Bus::Afcs AFCS
float AirDensityScalar
Definition Bus.h:453
float ComputedVsKms
Definition Bus.h:37
float ComputedVrKms
Definition Bus.h:36
float ComputedVneKms
Definition Bus.h:38
std::vector< Command > commandStream
Definition Bus.h:442
void FrameMove(float fElapsed) override
float oldIndicatedAirspeedKms
Definition Instrument.h:624
IndicatedAirSpeed2(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Bus * bus
Definition Instrument.h:22
Instrument(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition Instrument.h:36
Logger * logger
Definition Instrument.h:23
DeviceObject * pDevice
Definition Instrument.h:21
UINT defaultFont
Definition Instrument.h:24
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
void SetLocation(int absoluteX, int absoluteY)
Definition Sprite.cpp:99
Sprite(Logger *prmLogger, DeviceObject *prmpDevice, std::string prmPathAndFilename, int prmX, int prmY, float prmZ, int prmTop, int prmLeft, int prmWidth, int prmHeight, DWORD prmColor, float scaleX=1.0f, float scaleY=1.0f)
Definition Sprite.cpp:5
void Draw(RiseMath::Color prmColor)
Definition Sprite.cpp:75
void Update()
Definition Sprite.cpp:50
void SetRectangle(int top, int left, int right, int bottom)
Definition Sprite.cpp:105
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
Scockpit ourcockpit
Definition globals.cpp:114
constexpr auto Min(A first, B second)
Definition ClientMath.h:15
constexpr auto Max(A first, B second)
Definition ClientMath.h:16
float DesiredIasKms
Definition Bus.h:126
std::string name
Definition Command.h:11
float VrefMod
Definition globals.h:646
bool wheeled
Definition globals.h:596