Avionics
Dropship Simulator
HeadingIndicator.cpp
Go to the documentation of this file.
1 #include "../Instrument.h"
2 
3 HeadingIndicator::HeadingIndicator(int prmX, int prmY, float prmXScale, float prmYScale): Instrument(prmX, prmY, prmXScale, prmYScale)
4 {
5 }
6 
7 void HeadingIndicator::Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip)
8 {
9  Instrument::Initialize(prmBus, prmLogger, prmDevice, prmScreenWidth, prmScreenHeight, prmFonts, prmFlip);
10 
11  compassMoving.elementName = "HeadingCompass";
12  compassMoving.pathAndFilename = "Textures/Instruments/compass-moving.png";
13  compassMoving.Initialize(logger, bus, prmDevice, prmScreenHeight, 0, 0, prmFlip);
14  compassMoving.x = x - compassMoving.desc.Width / 2;
15  compassMoving.y = y - compassMoving.desc.Height / 2;
16  compassMoving.z = 0.5f; // above the overlay which is at 0.6
19 }
20 
21 void HeadingIndicator::Render(float fElapsed)
22 {
23  WCHAR msg[99];
25  if ((bus->HeadingTrue - hdg) > D3DX_PI)
26  hdg += D3DX_PI*2.0f;
27  else if ((bus->HeadingTrue - hdg) <-D3DX_PI)
28  hdg -= D3DX_PI*2.0f;
29  hdg += (bus->HeadingTrue - hdg)*0.25f;
30 
31  int hdgDegree = static_cast<int>(D3DXToDegree(hdg));
32  if (hdgDegree > 360) hdgDegree -= 360;
33  if (hdgDegree < 0) hdgDegree += 360;
34  swprintf_s(msg, 99, L"%03i", hdgDegree);
35  DrawTextW(msg, 247, 472, DT_NOCLIP, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f), 1, "HeadingReadout");
36 
40 };
virtual void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip)
Definition: Instrument.h:45
Sprite compassMoving
Definition: Instrument.h:151
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Definition: Logger.h:5
int y
Definition: Sprite.h:16
void Update()
Definition: Sprite.h:50
D3D10_TEXTURE2D_DESC desc
Definition: Sprite.h:15
float rotate
Definition: Sprite.h:21
int x
Definition: Sprite.h:16
float z
Definition: Sprite.h:17
float HeadingTrue
(4) Heading–primary flight crew reference (if selectable, record discrete, true or magnetic); ...
Definition: Bus.h:44
int height
Definition: Sprite.h:16
Definition: Bus.h:12
HeadingIndicator(int prmX, int prmY, float prmXScale, float prmYScale)
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
int width
Definition: Sprite.h:16
std::string elementName
Definition: Sprite.h:19
std::string pathAndFilename
Definition: Sprite.h:18
void Render(float fElapsed) override
Logger * logger
Definition: Instrument.h:22
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int prmScreenHeight, int prmElementX, int prmElementY, bool prmFlip)
Definition: Sprite.h:26