X-Plane multiplayer library 2 - using instancing
Go to the documentation of this file.
22 #ifndef _XPMPAircraft_h_
23 #define _XPMPAircraft_h_
25 #include "XPMPMultiplayer.h"
26 #include "XPLMInstance.h"
27 #include "XPLMCamera.h"
28 #include "XPLMMap.h"
30 #include <cstdint>
31 #include <stdexcept>
32 #include <string>
33 #include <vector>
34 #include <list>
36 //
37 // MARK: XPMP2 New Definitions
38 //
40 namespace XPMP2 {
42 class CSLModel;
45 constexpr float RPM_to_RADs = 0.10471975511966f;
47 constexpr double M_per_FT = 0.3048; // meter per 1 foot
49 constexpr int M_per_NM = 1852; // meter per one nautical mile
52 enum DR_VALS : std::uint8_t {
102  V_COUNT
103 };
112  std::string cslId;
114  std::string modelName;
116  std::string xsbAircraftPath;
118  int xsbAircraftLn = 0;
120  std::string icaoType;
124  std::string doc8643WTC;
127  struct MatchCrit_t {
128  std::string icaoAirline;
129  std::string livery;
130  };
131  typedef std::vector<MatchCrit_t> vecMatchCrit_t;
132  // List of match criteria defined for the model, can be empty
138  CSLModelInfo_t(const XPMP2::CSLModel& csl);
139 };
143 class Aircraft {
145 public:
147 protected:
154 public:
157  std::string acIcaoType;
158  std::string acIcaoAirline;
159  std::string acLivery;
165  XPLMDrawInfo_t drawInfo;
174  std::vector<float> v;
177  std::string label;
178  float colLabel[4] = {1.0f,1.0f,0.0f,1.0f};
181  float vertOfsRatio = 1.0f;
188  float gearDeflectRatio = 0.5f;
195  bool bClampToGround = false;
201  int aiPrio = 1;
210 protected:
211  bool bValid = true;
212  bool bVisible = true;
213  bool bRender = true;
216  int matchQuality = -1;
217  int acRelGrp = 0;
219  // this is data from about a second ago to calculate cartesian velocities
220  float prev_x = 0.0f, prev_y = 0.0f, prev_z = 0.0f;
221  float prev_ts = 0.0f;
224  std::list<XPLMInstanceRef> listInst;
226  int tcasTargetIdx = -1;
229  float camTimLstUpd = 0.0f;
231  float camDist = 0.0f;
233  float camBearing = 0.0f;
236  XPLMProbeRef hProbe = nullptr;
238  // Data used for drawing icons in X-Plane's map
239  int mapIconRow = 0;
240  int mapIconCol = 0;
241  float mapX = 0.0f;
242  float mapY = 0.0f;
243  std::string mapLabel;
245 private:
246  bool bDestroyInst = false;
247 public:
255  Aircraft (const std::string& _icaoType,
256  const std::string& _icaoAirline,
257  const std::string& _livery,
258  XPMPPlaneID _modeS_id = 0,
259  const std::string& _cslId = "");
261  Aircraft ();
263  virtual ~Aircraft();
266  Aircraft (const Aircraft&) = delete;
268  Aircraft& operator=(const Aircraft&) = delete;
278  void Create (const std::string& _icaoType,
279  const std::string& _icaoAirline,
280  const std::string& _livery,
281  XPMPPlaneID _modeS_id = 0,
282  const std::string& _cslId = "",
283  CSLModel* _pCSLModel = nullptr);
286  XPMPPlaneID GetModeS_ID () const { return modeS_id; }
288  bool IsGroundVehicle() const;
292  bool IsRelatedTo (const std::string& _icaoType) const;
294  int GetTcasTargetIdx () const { return tcasTargetIdx; }
296  bool IsCurrentlyShownAsTcasTarget () const { return tcasTargetIdx >= 1; }
298  bool IsCurrentlyShownAsAI () const;
306  virtual std::string GetFlightId() const;
313  int ChangeModel (const std::string& _icaoType,
314  const std::string& _icaoAirline,
315  const std::string& _livery);
325  bool AssignModel (const std::string& _cslId,
326  CSLModel* _pCSLModel = nullptr);
328  XPMP2::CSLModel* GetModel () const { return pCSLMdl; }
330  const std::string& GetModelName () const;
334  int GetMatchQuality () const { return matchQuality; }
336  float GetVertOfs () const;
339  bool IsValid() const { return bValid; }
341  virtual void SetInvalid();
344  virtual void SetVisible (bool _bVisible);
346  bool IsVisible () const { return bVisible && bValid; }
349  virtual void SetRender (bool _bRender);
351  bool IsRendered () const { return bRender && IsVisible(); }
354  bool IsInstanciated () const { return !listInst.empty(); }
357  float GetCameraDist () const { return camDist; }
359  float GetCameraBearing () const { return camBearing; }
369  virtual void UpdatePosition (float _elapsedSinceLastCall, int _flCounter) = 0;
371  // --- Getters and Setters for the values in `drawInfo` ---
378  void SetLocation (double lat, double lon, double alt_ft);
382  void GetLocation (double& lat, double& lon, double& alt_ft) const;
385  void SetLocalLoc (float _x, float _y, float _z) { drawInfo.x = _x; drawInfo.y = _y; drawInfo.z = _z; }
387  const XPLMDrawInfo_t& GetLocation () const { return drawInfo; }
389  float GetPitch () const { return drawInfo.pitch; }
390  void SetPitch (float _deg) { drawInfo.pitch = _deg; }
391  float GetHeading () const { return drawInfo.heading; }
392  void SetHeading (float _deg) { drawInfo.heading = _deg; }
393  float GetRoll () const { return drawInfo.roll; }
394  void SetRoll (float _deg) { drawInfo.roll = _deg; }
396  // --- Getters and Setters for the values in the `v` array ---
397  float GetGearRatio () const { return v[V_CONTROLS_GEAR_RATIO]; }
398  void SetGearRatio (float _f) { v[V_CONTROLS_GEAR_RATIO] = _f; }
399  float GetNoseWheelAngle () const { return v[V_CONTROLS_NWS_RATIO]; }
400  void SetNoseWheelAngle (float _f) { v[V_CONTROLS_NWS_RATIO] = _f; }
401  float GetFlapRatio () const { return v[V_CONTROLS_FLAP_RATIO]; }
402  void SetFlapRatio (float _f) { v[V_CONTROLS_FLAP_RATIO] = _f; }
403  float GetSpoilerRatio () const { return v[V_CONTROLS_SPOILER_RATIO]; }
404  void SetSpoilerRatio (float _f) { v[V_CONTROLS_SPOILER_RATIO] = _f; }
405  float GetSpeedbrakeRatio () const { return v[V_CONTROLS_SPEED_BRAKE_RATIO]; }
407  float GetSlatRatio () const { return v[V_CONTROLS_SLAT_RATIO]; }
408  void SetSlatRatio (float _f) { v[V_CONTROLS_SLAT_RATIO] = _f; }
409  float GetWingSweepRatio () const { return v[V_CONTROLS_WING_SWEEP_RATIO]; }
410  void SetWingSweepRatio (float _f) { v[V_CONTROLS_WING_SWEEP_RATIO] = _f; }
411  float GetThrustRatio () const { return v[V_CONTROLS_THRUST_RATIO]; }
412  void SetThrustRatio (float _f) { v[V_CONTROLS_THRUST_RATIO] = _f; }
413  float GetYokePitchRatio () const { return v[V_CONTROLS_YOKE_PITCH_RATIO]; }
414  void SetYokePitchRatio (float _f) { v[V_CONTROLS_YOKE_PITCH_RATIO] = _f; }
417  float GetYokeRollRatio () const { return v[V_CONTROLS_YOKE_ROLL_RATIO]; }
418  void SetYokeRollRatio (float _f) { v[V_CONTROLS_YOKE_ROLL_RATIO] = _f; }
419  float GetThrustReversRatio () const { return v[V_CONTROLS_THRUST_REVERS]; }
422  bool GetLightsTaxi () const { return v[V_CONTROLS_TAXI_LITES_ON] > 0.5f; }
423  void SetLightsTaxi (bool _b) { v[V_CONTROLS_TAXI_LITES_ON] = float(_b); }
424  bool GetLightsLanding () const { return v[V_CONTROLS_LANDING_LITES_ON] > 0.5f; }
425  void SetLightsLanding (bool _b) { v[V_CONTROLS_LANDING_LITES_ON] = float(_b); }
426  bool GetLightsBeacon () const { return v[V_CONTROLS_BEACON_LITES_ON] > 0.5f; }
427  void SetLightsBeacon (bool _b) { v[V_CONTROLS_BEACON_LITES_ON] = float(_b); }
428  bool GetLightsStrobe () const { return v[V_CONTROLS_STROBE_LITES_ON] > 0.5f; }
429  void SetLightsStrobe (bool _b) { v[V_CONTROLS_STROBE_LITES_ON] = float(_b); }
430  bool GetLightsNav () const { return v[V_CONTROLS_NAV_LITES_ON] > 0.5f; }
431  void SetLightsNav (bool _b) { v[V_CONTROLS_NAV_LITES_ON] = float(_b); }
437  float GetTireRotAngle () const { return v[V_GEAR_TIRE_ROTATION_ANGLE_DEG]; }
438  void SetTireRotAngle (float _deg) { v[V_GEAR_TIRE_ROTATION_ANGLE_DEG] = _deg; }
439  float GetTireRotRpm () const { return v[V_GEAR_TIRE_ROTATION_SPEED_RPM]; }
440  void SetTireRotRpm (float _rpm) { v[V_GEAR_TIRE_ROTATION_SPEED_RPM] = _rpm;
443  void SetTireRotRad (float _rad) { v[V_GEAR_TIRE_ROTATION_SPEED_RAD_SEC] = _rad;
447  void SetEngineRotAngle (float _deg);
449  void SetEngineRotRpm (float _rpm);
451  void SetEngineRotRad (float _rad);
453  float GetEngineRotAngle (size_t idx) const
454  { return 1 <= idx && idx <= 4 ? v[V_ENGINES_ENGINE_ROTATION_ANGLE_DEG1+idx-1] : 0.0f; }
455  void SetEngineRotAngle (size_t idx, float _deg);
456  float GetEngineRotRpm (size_t idx) const
457  { return 1 <= idx && idx <= 4 ? v[V_ENGINES_ENGINE_ROTATION_SPEED_RPM1+idx-1] : 0.0f; }
458  void SetEngineRotRpm (size_t idx, float _rpm);
459  float GetEngineRotRad (size_t idx) const
460  { return 1 <= idx && idx <= 4 ? v[V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC+idx-1] : 0.0f; }
461  void SetEngineRotRad (size_t idx, float _rad);
464  void SetPropRotAngle (float _deg) { v[V_ENGINES_PROP_ROTATION_ANGLE_DEG] = _deg; }
465  float GetPropRotRpm () const { return v[V_ENGINES_PROP_ROTATION_SPEED_RPM]; }
466  void SetPropRotRpm (float _rpm) { v[V_ENGINES_PROP_ROTATION_SPEED_RPM] = _rpm;
475  bool GetTouchDown () const { return v[V_MISC_TOUCH_DOWN] > 0.5f; }
476  void SetTouchDown (bool _b) { v[V_MISC_TOUCH_DOWN] = float(_b); }
478  // The following is implemented in Map.cpp:
480  void MapFindIcon ();
482  void MapPreparePos (XPLMMapProjectionID projection,
483  const float boundsLTRB[4]);
485  void MapDrawIcon (XPLMMapLayerID inLayer, float acSize);
487  void MapDrawLabel (XPLMMapLayerID inLayer, float yOfs);
489 protected:
491  static float FlightLoopCB (float, float, int, void*);
493  void DoMove ();
495  void UpdateDistBearingCamera (const XPLMCameraPosition_t& posCam);
497  void ClampToGround ();
499  bool CreateInstances ();
501  void DestroyInstances ();
505  virtual void ComputeMapLabel ();
507  // The following functions are implemented in AIMultiplayer.cpp:
509  virtual void SetTcasTargetIdx (int _idx) { tcasTargetIdx = _idx; }
510  // These functions perform the TCAS target / multiplayer data updates
511  friend void AIMultiUpdate ();
512  friend size_t AIUpdateTCASTargets ();
513  friend size_t AIUpdateMultiplayerDataRefs ();
514 };
517 Aircraft* AcFindByID (XPMPPlaneID _id);
519 //
520 // MARK: XPMP2 Exception class
521 //
524 class XPMP2Error : public std::logic_error {
525 protected:
526  std::string fileName;
527  int ln;
528  std::string funcName;
529  std::string msg;
530 public:
532  XPMP2Error (const char* szFile, int ln, const char* szFunc, const char* szMsg, ...);
533 public:
535  virtual const char* what() const noexcept;
537 public:
538  // copy/move constructor/assignment as per default
539  XPMP2Error (const XPMP2Error& o) = default;
540  XPMP2Error (XPMP2Error&& o) = default;
541  XPMP2Error& operator = (const XPMP2Error& o) = default;
542  XPMP2Error& operator = (XPMP2Error&& o) = default;
543 };
547 } // namespace XPMP2
549 #endif
Initialization and general control functions for XPMP2.
XPMPTransponderMode mode
current radar mode, if not xpmpTransponderMode_Standby then is plane considered for TCAS display
Definition: XPMPMultiplayer.h:192
unsigned XPMPPlaneID
Unique ID for an aircraft created by a plugin.
Definition: XPMPMultiplayer.h:243
@ xpmpTransponderMode_Standby
transponder is in standby, not currently sending -> aircraft not visible on TCAS
Definition: XPMPMultiplayer.h:180
Textual information of planes to be passed on via shared dataRefs to other plugins.
Definition: XPMPMultiplayer.h:199
defines information about an aircraft visible to radar.
Definition: XPMPMultiplayer.h:189
Actual representation of all aircraft in XPMP2.
Definition: XPMPAircraft.h:143
bool GetLightsBeacon() const
Beacon lights.
Definition: XPMPAircraft.h:426
virtual void UpdatePosition(float _elapsedSinceLastCall, int _flCounter)=0
Called right before updating the aircraft's placement in the world.
float GetGearRatio() const
Gear deploy ratio.
Definition: XPMPAircraft.h:397
void SetLocalLoc(float _x, float _y, float _z)
Sets location in local world coordinates.
Definition: XPMPAircraft.h:385
float GetThrustReversRatio() const
Thrust reversers ratio.
Definition: XPMPAircraft.h:419
std::string label
aircraft label shown in the 3D world next to the plane
Definition: XPMPAircraft.h:177
void SetLightsNav(bool _b)
Navigation lights.
Definition: XPMPAircraft.h:431
float GetNoseWheelAngle() const
Nose Wheel angle in degrees.
Definition: XPMPAircraft.h:399
bool IsRendered() const
Is this plane to be rendered?
Definition: XPMPAircraft.h:351
float GetVertOfs() const
Vertical offset, ie. the value that needs to be added to drawInfo.y to make the aircraft appear on th...
Definition: Aircraft.cpp:399
float GetSpeedbrakeRatio() const
Speedbrakes deploy ratio.
Definition: XPMPAircraft.h:405
std::string acIcaoType
ICAO aircraft type designator of this plane.
Definition: XPMPAircraft.h:157
float GetRoll() const
roll [degree]
Definition: XPMPAircraft.h:393
CSLModelInfo_t GetModelInfo() const
return an information structure for the CSL model associated with the aircraft
Definition: XPMPAircraft.h:332
XPLMProbeRef hProbe
Y Probe for terrain testing, needed in ground clamping.
Definition: XPMPAircraft.h:236
void SetSpoilerRatio(float _f)
Spoilers deploy ratio.
Definition: XPMPAircraft.h:404
void MapDrawLabel(XPLMMapLayerID inLayer, float yOfs)
Actually draw the map label.
Definition: Map.cpp:151
bool IsCurrentlyShownAsTcasTarget() const
Is this plane currently also being tracked as a TCAS target, ie. will appear on TCAS?
Definition: XPMPAircraft.h:296
bool IsCurrentlyShownAsAI() const
Is this plane currently also being tracked by X-Plane's classic AI/multiplayer?
Definition: AIMultiplayer.cpp:209
virtual void SetRender(bool _bRender)
Switch rendering of the CSL model on or off.
Definition: Aircraft.cpp:746
float vertOfsRatio
How much of the vertical offset shall be applied? (This allows phasing out the vertical offset in hig...
Definition: XPMPAircraft.h:181
int GetTcasTargetIdx() const
return the current TCAS target index (into sim/cockpit2/tcas/targets), 1-based, -1 if not used
Definition: XPMPAircraft.h:294
int aiPrio
Priority for display in one of the limited number of TCAS target slots.
Definition: XPMPAircraft.h:201
XPMP2::CSLModel * GetModel() const
return a pointer to the CSL model in use (Note: The CSLModel structure is not public....
Definition: XPMPAircraft.h:328
void SetEngineRotRpm(float _rpm)
Engine rotation speed [rpm], also sets [rad/s] and engines 1..4.
Definition: Aircraft.cpp:637
float GetEngineRotAngle() const
Engine rotation angle [degree].
Definition: XPMPAircraft.h:446
float GetPropRotAngle() const
Propellor rotation angle [degree].
Definition: XPMPAircraft.h:463
std::string acIcaoAirline
ICAO Airline code of this plane.
Definition: XPMPAircraft.h:158
float GetNoseGearDeflection() const
Vertical nose gear deflection [meter].
Definition: XPMPAircraft.h:433
virtual void ComputeMapLabel()
Put together the map label.
Definition: Map.cpp:165
virtual void SetVisible(bool _bVisible)
Make the plane (in)visible.
Definition: Aircraft.cpp:729
float camDist
Distance to camera in meters (updated internally regularly)
Definition: XPMPAircraft.h:231
virtual std::string GetFlightId() const
Return a value for dataRef .../tcas/target/flight_id.
Definition: Aircraft.cpp:273
float mapX
temporary: map coordinates (NAN = not to be drawn)
Definition: XPMPAircraft.h:241
float camBearing
Bearing from camera in degrees (updated internally regularly)
Definition: XPMPAircraft.h:233
bool GetLightsLanding() const
Landing lights.
Definition: XPMPAircraft.h:424
float GetTireRotRpm() const
Tire rotation speed [rpm].
Definition: XPMPAircraft.h:439
Default constructor creates an empty, invalid(!) and invisible shell; call XPMP2::Aircraft::Create() ...
Definition: Aircraft.cpp:141
bool GetLightsStrobe() const
Strobe lights.
Definition: XPMPAircraft.h:428
float GetEngineRotAngle(size_t idx) const
< Engine rotation angle [degree] for engine idx (1..4)
Definition: XPMPAircraft.h:453
float GetThrustRatio() const
Thrust ratio.
Definition: XPMPAircraft.h:411
void SetGearRatio(float _f)
Gear deploy ratio.
Definition: XPMPAircraft.h:398
float GetSpoilerRatio() const
Spoilers deploy ratio.
Definition: XPMPAircraft.h:403
bool GetTouchDown() const
Moment of touch down.
Definition: XPMPAircraft.h:475
void SetThrustReversRatio(float _f)
Thrust reversers ratio.
Definition: XPMPAircraft.h:420
float GetTireRotAngle() const
Tire rotation angle [degree].
Definition: XPMPAircraft.h:437
float GetCameraBearing() const
Bearing from camera [°].
Definition: XPMPAircraft.h:359
void SetLightsStrobe(bool _b)
Strobe lights.
Definition: XPMPAircraft.h:429
virtual void SetTcasTargetIdx(int _idx)
Define the TCAS target index in use.
Definition: XPMPAircraft.h:509
bool GetLightsTaxi() const
Taxi lights.
Definition: XPMPAircraft.h:422
void SetTireRotRpm(float _rpm)
Definition: XPMPAircraft.h:440
bool bVisible
Shall this plane be drawn at the moment and be visible to TCAS/interfaces?
Definition: XPMPAircraft.h:212
int matchQuality
quality of the match with the CSL model
Definition: XPMPAircraft.h:216
friend size_t AIUpdateTCASTargets()
The modern way: Use TCAS override and update TCAS targets.
Definition: AIMultiplayer.cpp:327
void SetNoseWheelAngle(float _f)
Nose Wheel angle in degrees.
Definition: XPMPAircraft.h:400
XPMPPlaneID GetModeS_ID() const
return the XPMP2 plane id
Definition: XPMPAircraft.h:286
void SetSpeedbrakeRatio(float _f)
Speedbrakes deploy ratio.
Definition: XPMPAircraft.h:406
friend void AIMultiUpdate()
Updates all TCAS target dataRefs, both standard X-Plane, as well as additional shared dataRefs for te...
Definition: AIMultiplayer.cpp:560
bool AssignModel(const std::string &_cslId, CSLModel *_pCSLModel=nullptr)
Assigns the given model.
Definition: Aircraft.cpp:343
void DestroyInstances()
Destroy all instances.
Definition: Aircraft.cpp:574
void SetTireDeflection(float _mtr)
Vertical (main) gear deflection [meter].
Definition: XPMPAircraft.h:436
void SetLightsLanding(bool _b)
Landing lights.
Definition: XPMPAircraft.h:425
std::list< XPLMInstanceRef > listInst
X-Plane instance handles for all objects making up the model.
Definition: XPMPAircraft.h:224
float GetTireDeflection() const
Vertical (main) gear deflection [meter].
Definition: XPMPAircraft.h:435
void SetYokeHeadingRatio(float _f)
Yoke heading ratio.
Definition: XPMPAircraft.h:416
bool IsRelatedTo(const std::string &_icaoType) const
Is this object "related" to the given ICAO code? (named in the same line in related....
Definition: Aircraft.cpp:262
bool IsInstanciated() const
Are instances created for this aircraft?
Definition: XPMPAircraft.h:354
XPMPPlaneID modeS_id
A plane is uniquely identified by a 24bit number [0x01..0xFFFFFF].
Definition: XPMPAircraft.h:152
void MapPreparePos(XPLMMapProjectionID projection, const float boundsLTRB[4])
Prepare map coordinates.
Definition: Map.cpp:116
int tcasTargetIdx
Which sim/cockpit2/tcas/targets-index does this plane occupy? [1..63], -1 if none.
Definition: XPMPAircraft.h:226
void SetPropRotRpm(float _rpm)
Definition: XPMPAircraft.h:466
void SetFlapRatio(float _f)
Flaps deploy ratio.
Definition: XPMPAircraft.h:402
bool ShowAsAIPlane() const
Is this plane to be drawn on TCAS? (It will if transponder is not switched off)
Definition: XPMPAircraft.h:300
float GetTireRotRad() const
Tire rotation speed [rad/s].
Definition: XPMPAircraft.h:442
void DoMove()
Internal: This puts the instance into XP's sky and makes it move.
Definition: Aircraft.cpp:480
float gearDeflectRatio
By how much of the gear deflection shall the plane's altitude be reduced?
Definition: XPMPAircraft.h:188
void SetLightsBeacon(bool _b)
Beacon lights.
Definition: XPMPAircraft.h:427
float GetPropRotRpm() const
Propellor rotation speed [rpm].
Definition: XPMPAircraft.h:465
Aircraft & operator=(const Aircraft &)=delete
Aircraft must not be copied as they reference non-copyable resources like XP instances.
void Create(const std::string &_icaoType, const std::string &_icaoAirline, const std::string &_livery, XPMPPlaneID _modeS_id=0, const std::string &_cslId="", CSLModel *_pCSLModel=nullptr)
Creates a plane, only a valid operation if object was created using the default constructor.
Definition: Aircraft.cpp:174
void SetPropRotAngle(float _deg)
Propellor rotation angle [degree].
Definition: XPMPAircraft.h:464
void SetSlatRatio(float _f)
Slats deploy ratio.
Definition: XPMPAircraft.h:408
void SetLightsTaxi(bool _b)
Taxi lights.
Definition: XPMPAircraft.h:423
bool IsGroundVehicle() const
Is this object a ground vehicle?
Definition: Aircraft.cpp:255
static float FlightLoopCB(float, float, int, void *)
Internal: Flight loop callback function controlling update and movement of all planes.
Definition: Aircraft.cpp:408
XPLMDrawInfo_t drawInfo
Holds position (in local coordinates!) and orientation (pitch, heading roll) of the aircraft.
Definition: XPMPAircraft.h:165
float GetYokePitchRatio() const
Yoke pitch ratio.
Definition: XPMPAircraft.h:413
int ChangeModel(const std::string &_icaoType, const std::string &_icaoAirline, const std::string &_livery)
(Potentially) changes the plane's model after doing a new match attempt
Definition: Aircraft.cpp:294
std::vector< float > v
actual dataRef values to be provided to the CSL model
Definition: XPMPAircraft.h:174
float GetFlapRatio() const
Flaps deploy ratio.
Definition: XPMPAircraft.h:401
float GetEngineRotRpm(size_t idx) const
< Engine rotation speed [rpm] for engine idx (1..4)
Definition: XPMPAircraft.h:456
float GetEngineRotRad(size_t idx) const
< Engine rotation speed [rad/s] for engine idx (1..4)
Definition: XPMPAircraft.h:459
XPMPInfoTexts_t acInfoTexts
Informational texts passed on via multiplayer shared dataRefs.
Definition: XPMPAircraft.h:208
bool CreateInstances()
Create the instances required to represent the plane, return if successful.
Definition: Aircraft.cpp:537
float prev_y
Definition: XPMPAircraft.h:220
const std::string & GetModelName() const
return the name of the CSL model in use
Definition: Aircraft.cpp:389
void UpdateDistBearingCamera(const XPLMCameraPosition_t &posCam)
Internal: Update the plane's distance/bearing from the camera location.
Definition: Aircraft.cpp:526
float GetYokeRollRatio() const
Yoke roll ratio.
Definition: XPMPAircraft.h:417
void ClampToGround()
Clamp to ground: Make sure the plane is not below ground, corrects Aircraft::drawInfo if needed.
Definition: Aircraft.cpp:494
bool bClampToGround
Shall this plane be clamped to ground (ie. never sink below ground)?
Definition: XPMPAircraft.h:195
void SetHeading(float _deg)
heading [degree]
Definition: XPMPAircraft.h:392
bool bRender
Shall the CSL model be drawn in 3D world? (if !bRender && bVivile then still visible on TCAS/interfac...
Definition: XPMPAircraft.h:213
bool bValid
is this object valid? (Will be reset in case of exceptions)
Definition: XPMPAircraft.h:211
void SetTouchDown(bool _b)
Moment of touch down.
Definition: XPMPAircraft.h:476
float prev_x
Definition: XPMPAircraft.h:220
void SetNoseGearDeflection(float _mtr)
Vertical nose gear deflection [meter].
Definition: XPMPAircraft.h:434
float GetEngineRotRpm() const
Engine rotation speed [rpm].
Definition: XPMPAircraft.h:448
void MapFindIcon()
Determine which map icon to use for this aircraft.
Definition: Map.cpp:72
float camTimLstUpd
Timestamp of last update of camera dist/bearing.
Definition: XPMPAircraft.h:229
void SetReversDeployRatio(float _f)
Thrust reversers deploy ratio.
Definition: XPMPAircraft.h:473
bool IsValid() const
Is the a/c object valid?
Definition: XPMPAircraft.h:339
float GetEngineRotRad() const
Engine rotation speed [rad/s].
Definition: XPMPAircraft.h:450
void SetYokePitchRatio(float _f)
Yoke pitch ratio.
Definition: XPMPAircraft.h:414
int GetMatchQuality() const
quality of the match with the CSL model
Definition: XPMPAircraft.h:334
XPMPPlaneRadar_t acRadar
Current radar status.
Definition: XPMPAircraft.h:205
int acRelGrp
related group, ie. line in related.txt in which this a/c appears, if any
Definition: XPMPAircraft.h:217
void SetPropRotRad(float _rad)
Definition: XPMPAircraft.h:469
virtual ~Aircraft()
Destructor cleans up all resources acquired.
Definition: Aircraft.cpp:149
bool IsVisible() const
Is the plane visible?
Definition: XPMPAircraft.h:346
void ResetTcasTargetIdx()
Reset TCAS target slot index to -1
Definition: XPMPAircraft.h:302
float GetReversDeployRatio() const
Thrust reversers deploy ratio.
Definition: XPMPAircraft.h:472
bool GetLightsNav() const
Navigation lights.
Definition: XPMPAircraft.h:430
float prev_ts
last update of prev_x/y/z in XP's network time
Definition: XPMPAircraft.h:221
void SetRoll(float _deg)
roll [degree]
Definition: XPMPAircraft.h:394
float GetWingSweepRatio() const
Wing sweep ratio.
Definition: XPMPAircraft.h:409
float GetSlatRatio() const
Slats deploy ratio.
Definition: XPMPAircraft.h:407
std::string mapLabel
label for map drawing
Definition: XPMPAircraft.h:243
virtual void SetInvalid()
Mark the plane invalid, e.g. after exceptions occured on the data.
Definition: Aircraft.cpp:709
void SetWingSweepRatio(float _f)
Wing sweep ratio.
Definition: XPMPAircraft.h:410
float GetHeading() const
heading [degree]
Definition: XPMPAircraft.h:391
void SetPitch(float _deg)
pitch [degree]
Definition: XPMPAircraft.h:390
void SetYokeRollRatio(float _f)
Yoke roll ratio.
Definition: XPMPAircraft.h:418
const XPLMDrawInfo_t & GetLocation() const
Gets all location info (including local coordinates)
Definition: XPMPAircraft.h:387
int mapIconRow
map icon coordinates, row
Definition: XPMPAircraft.h:239
void MapDrawIcon(XPLMMapLayerID inLayer, float acSize)
Actually draw the map icon.
Definition: Map.cpp:135
float GetCameraDist() const
Distance to camera [m].
Definition: XPMPAircraft.h:357
XPMP2::CSLModel * pCSLMdl
the CSL model in use
Definition: XPMPAircraft.h:215
void SetLocation(double lat, double lon, double alt_ft)
Converts world coordinates to local coordinates, writes to Aircraft::drawInfo.
Definition: Aircraft.cpp:596
void SetTireRotAngle(float _deg)
Tire rotation angle [degree].
Definition: XPMPAircraft.h:438
void SetThrustRatio(float _f)
Thrust ratio.
Definition: XPMPAircraft.h:412
float GetPropRotRad() const
Propellor rotation speed [rad/s].
Definition: XPMPAircraft.h:468
float colLabel[4]
label base color (RGB)
Definition: XPMPAircraft.h:178
int ReMatchModel()
Finds a match again, using the existing parameters, eg. after more models have been loaded.
Definition: XPMPAircraft.h:319
int mapIconCol
map icon coordinates, column
Definition: XPMPAircraft.h:240
void SetEngineRotRad(float _rad)
Engine rotation speed [rad/s], also sets [rpm] and engines 1..4.
Definition: Aircraft.cpp:652
Aircraft(const Aircraft &)=delete
Aircraft must not be copied as they reference non-copyable resources like XP instances.
friend size_t AIUpdateMultiplayerDataRefs()
The old way: Update Multiplayer dataRefs directly.
Definition: AIMultiplayer.cpp:230
std::string acLivery
Livery code of this plane.
Definition: XPMPAircraft.h:159
float GetPitch() const
pitch [degree]
Definition: XPMPAircraft.h:389
float GetYokeHeadingRatio() const
Yoke heading ratio.
Definition: XPMPAircraft.h:415
void SetTireRotRad(float _rad)
Definition: XPMPAircraft.h:443
void SetEngineRotAngle(float _deg)
Engine rotation angle [degree], also sets engines 1..4.
Definition: Aircraft.cpp:627
float prev_z
Definition: XPMPAircraft.h:220
float mapY
temporary: map coordinates (NAN = not to be drawn)
Definition: XPMPAircraft.h:242
Represetns a CSL model as it is saved on disk.
Definition: CSLModels.h:113
XPMP2 Exception class, e.g. thrown if there are no CSL models or duplicate modeS_ids when creating an...
Definition: XPMPAircraft.h:524
std::string fileName
filename of the line of code where exception occurred
Definition: XPMPAircraft.h:526
virtual const char * what() const noexcept
returns msg.c_str()
Definition: Utilities.cpp:686
std::string msg
additional text message
Definition: XPMPAircraft.h:529
XPMP2Error(const char *szFile, int ln, const char *szFunc, const char *szMsg,...)
Constructor puts together a formatted exception text.
Definition: Utilities.cpp:671
std::string funcName
function of the line of code where exception occurred
Definition: XPMPAircraft.h:528
int ln
line number of the line of code where exception occurred
Definition: XPMPAircraft.h:527
Definition: XPMPAircraft.h:40
Aircraft * AcFindByID(XPMPPlaneID _id)
Find aircraft by its plane ID, can return nullptr.
Definition: Aircraft.cpp:959
constexpr float RPM_to_RADs
Convert revolutions-per-minute (RPM) to radians per second (rad/s) by multiplying with PI/30.
Definition: XPMPAircraft.h:45
The dataRefs provided by XPMP2 to the CSL models.
Definition: XPMPAircraft.h:52
Definition: XPMPAircraft.h:96
libxplanemp/controls/yoke_heading_ratio and sim/cockpit2/tcas/targets/position/yolk_yaw
Definition: XPMPAircraft.h:62
libxplanemp/controls/thrust_ratio and sim/cockpit2/tcas/targets/position/throttle
Definition: XPMPAircraft.h:60
libxplanemp/controls/wing_sweep_ratio and sim/cockpit2/tcas/targets/position/wing_sweep
Definition: XPMPAircraft.h:59
libxplanemp/controls/yoke_pitch_ratio and sim/cockpit2/tcas/targets/position/yolk_pitch
Definition: XPMPAircraft.h:61
Definition: XPMPAircraft.h:74
Definition: XPMPAircraft.h:83
Definition: XPMPAircraft.h:94
Definition: XPMPAircraft.h:100
Definition: XPMPAircraft.h:88
Definition: XPMPAircraft.h:95
Definition: XPMPAircraft.h:72
always last, number of dataRefs XPMP2 pre-defines
Definition: XPMPAircraft.h:102
Definition: XPMPAircraft.h:97
Definition: XPMPAircraft.h:81
libxplanemp/controls/yoke_roll_ratio and sim/cockpit2/tcas/targets/position/yolk_roll
Definition: XPMPAircraft.h:63
Definition: XPMPAircraft.h:56
libxplanemp/controls/taxi_lites_on and sim/cockpit2/tcas/targets/position/lights
Definition: XPMPAircraft.h:66
Definition: XPMPAircraft.h:80
Definition: XPMPAircraft.h:73
libxplanemp/controls/nws_ratio, the nose wheel angle, actually in degrees
Definition: XPMPAircraft.h:54
Definition: XPMPAircraft.h:89
Definition: XPMPAircraft.h:75
Definition: XPMPAircraft.h:86
Definition: XPMPAircraft.h:78
Definition: XPMPAircraft.h:84
libxplanemp/controls/beacon_lites_on and sim/cockpit2/tcas/targets/position/lights
Definition: XPMPAircraft.h:68
Definition: XPMPAircraft.h:93
Definition: XPMPAircraft.h:82
Definition: XPMPAircraft.h:91
libxplanemp/controls/nav_lites_on and sim/cockpit2/tcas/targets/position/lights
Definition: XPMPAircraft.h:70
Definition: XPMPAircraft.h:79
libxplanemp/controls/slat_ratio and sim/cockpit2/tcas/targets/position/slat_ratio
Definition: XPMPAircraft.h:58
Definition: XPMPAircraft.h:92
Definition: XPMPAircraft.h:64
Definition: XPMPAircraft.h:76
Definition: XPMPAircraft.h:90
Definition: XPMPAircraft.h:87
libxplanemp/controls/flap_ratio and sim/cockpit2/tcas/targets/position/flap_ratio and ....
Definition: XPMPAircraft.h:55
libxplanemp/controls/landing_lites_on and sim/cockpit2/tcas/targets/position/lights
Definition: XPMPAircraft.h:67
libxplanemp/controls/gear_ratio and sim/cockpit2/tcas/targets/position/gear_deploy
Definition: XPMPAircraft.h:53
libxplanemp/controls/strobe_lites_on and sim/cockpit2/tcas/targets/position/lights
Definition: XPMPAircraft.h:69
libxplanemp/controls/speed_brake_ratio and sim/cockpit2/tcas/targets/position/speedbrake_ratio
Definition: XPMPAircraft.h:57
constexpr int M_per_NM
Convert nautical miles to meters.
Definition: XPMPAircraft.h:49
constexpr double M_per_FT
Convert feet to meters, e.g. for altitude calculations.
Definition: XPMPAircraft.h:47
Collates some information on the CSL model.
Definition: XPMPAircraft.h:110
vecMatchCrit_t vecMatchCrit
Definition: XPMPAircraft.h:133
std::string modelName
name, formed by last part of path plus id
Definition: XPMPAircraft.h:114
int xsbAircraftLn
Line number in the xsb_aircraft.txt file where the model definition starts.
Definition: XPMPAircraft.h:118
std::string icaoType
ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO
Definition: XPMPAircraft.h:120
std::string cslId
id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT
Definition: XPMPAircraft.h:112
std::string doc8643WTC
Doc8643 information: wake turbulence class, like M, L/M, L, H.
Definition: XPMPAircraft.h:124
std::string doc8643Classification
Doc8643 information: Classification, like L1P, L4J, H1T.
Definition: XPMPAircraft.h:122
std::string xsbAircraftPath
Path to the xsb_aircraft.txt file from where this model is loaded.
Definition: XPMPAircraft.h:116
Default constructor does nothing.
Definition: XPMPAircraft.h:136
std::string livery
special livery (not often used)
Definition: XPMPAircraft.h:129
std::string icaoAirline
ICAO airine/operator code.
Definition: XPMPAircraft.h:128
std::vector< MatchCrit_t > vecMatchCrit_t
Definition: XPMPAircraft.h:131
Any number of airline codes and/or liveries can be assigned to a model for matching purpose.
Definition: XPMPAircraft.h:127