Avionics
Dropship Simulator
IndicatedAirSpeedTape.cpp
Go to the documentation of this file.
1 #include "../Instrument.h"
2 
3 IndicatedAirSpeedTape::IndicatedAirSpeedTape(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile, float prmModulateKm) : Instrument(prmX, prmY, 1, 1)
4 {
5  width = prmWidth;
6  height = prmHeight;
7  textureFile = prmTextureFile;
8  modulateKm = prmModulateKm;
9 }
10 
11 void IndicatedAirSpeedTape::Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip)
12 {
13  Instrument::Initialize(prmBus, prmLogger, prmDevice, prmScreenWidth, prmScreenHeight, prmFonts, prmFlip);
14 
15  sprite.elementName = "AirspeedTape";
16  sprite.width = width;
18  sprite.z = 0.9f; // the artificial horizon is at 1.0, text is at 0.5, overlay is at 0.6
21 
23  tvpitchscale = 2.2f / static_cast<float>(sprite.desc.Height) * modulateKm; // 44 px per 20 knot
24  vertoffset = 742.0f / static_cast<float>(sprite.desc.Height);
25  font = 2;
26 
27  tvrange = static_cast<float>(sprite.desc.Width) / static_cast<float>(sprite.desc.Height) * height / width; // proportionally match above
29 }
30 
31 void IndicatedAirSpeedTape::Render(float fElapsed)
32 {
33  ias += (bus->IndicatedAirspeed - ias)*0.25f;
34 
36  sprite.Update();
37  sprite.Draw();
38 
39  WCHAR msg[99];
40  swprintf_s(msg, 99, L"%3.0f", ias* modulateKm);
41  DrawTextW(msg, 12, 236, DT_NOCLIP, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f), font, "AirspeedReadout");
42 };
virtual void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip)
Definition: Instrument.h:45
Definition: Logger.h:5
int height
Definition: Instrument.h:30
D3DXVECTOR2 texSize
Definition: Sprite.h:24
IndicatedAirSpeedTape(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile, float prmModulateKm)
void Update()
Definition: Sprite.h:50
float IndicatedAirspeed
(3) Indicated Airspeed in km per second?
Definition: Bus.h:42
D3D10_TEXTURE2D_DESC desc
Definition: Sprite.h:15
float z
Definition: Sprite.h:17
D3DXVECTOR2 texCoord
Definition: Sprite.h:23
int height
Definition: Sprite.h:16
std::string textureFile
Definition: Instrument.h:93
Definition: Bus.h:12
Bus * bus
Definition: Instrument.h:21
void Draw()
Definition: Sprite.h:64
Abstract base class for instrumentation By definition, instruments don&#39;t do any of the work (they don...
Definition: Instrument.h:15
DEVICE_OBJECT * pDevice
Definition: Instrument.h:24
int width
Definition: Sprite.h:16
std::string elementName
Definition: Sprite.h:19
void Render(float fElapsed) override
std::string pathAndFilename
Definition: Sprite.h:18
Logger * logger
Definition: Instrument.h:22
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
int screenHeight
Definition: Instrument.h:23
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int prmScreenHeight, int prmElementX, int prmElementY, bool prmFlip)
Definition: Sprite.h:26