XPMP2
X-Plane multiplayer library 2 - using instancing
Classes | Public Types | Public Attributes | Static Protected Member Functions | Protected Attributes | Friends | List of all members
XPMP2::Aircraft Class Referenceabstract

Actual representation of all aircraft in XPMP2. More...

#include <XPMPAircraft.h>

+ Inheritance diagram for XPMP2::Aircraft:

Classes

struct  SndChTy
 Operational values per sound channel, that is triggered by a standard sound event. More...
 
struct  wakeTy
 Wake dataRef support. More...
 

Public Types

enum  SoundEventsTy {
  SND_ENG = 0 , SND_REVERSE_THRUST , SND_TIRE , SND_GEAR ,
  SND_FLAPS , SND_NUM_EVENTS
}
 Types of sound supported directly by XPMP2. More...
 
typedef std::list< uint64_t > ChnListTy
 List of sound channel ids, also beyond sounds created for SoundEventsTy. More...
 

Public Member Functions

Construction
 Aircraft (const std::string &_icaoType, const std::string &_icaoAirline, const std::string &_livery, XPMPPlaneID _modeS_id=0, const std::string &_cslId="")
 Constructor creates a new aircraft object, which will be managed and displayed. More...
 
 Aircraft ()
 Default constructor creates an empty, invalid(!) and invisible shell; call XPMP2::Aircraft::Create() to actually create a plane. More...
 
virtual ~Aircraft ()
 Destructor cleans up all resources acquired. More...
 
 Aircraft (const Aircraft &)=delete
 Aircraft must not be copied as they reference non-copyable resources like XP instances. More...
 
Aircraftoperator= (const Aircraft &)=delete
 Aircraft must not be copied as they reference non-copyable resources like XP instances. More...
 
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. More...
 
Information
XPMPPlaneID GetModeS_ID () const
 return the XPMP2 plane id More...
 
bool IsRelatedTo (const std::string &_icaoType) const
 Is this object "related" to the given ICAO code? (named in the same line in related.txt) More...
 
bool IsGroundVehicle () const
 Is this object a ground vehicle? (related to glob.carIcaoType) More...
 
bool IsGlider () const
 Is this object a glider? More...
 
int GetTcasTargetIdx () const
 return the current TCAS target index (into sim/cockpit2/tcas/targets), 1-based, -1 if not used More...
 
bool IsCurrentlyShownAsTcasTarget () const
 Is this plane currently also being tracked as a TCAS target, ie. will appear on TCAS? More...
 
bool IsCurrentlyShownAsAI () const
 Is this plane currently also being tracked by X-Plane's classic AI/multiplayer? More...
 
bool ShowAsAIPlane () const
 Is this plane to be drawn on TCAS? (It will if transponder is not switched off) More...
 
void ResetTcasTargetIdx ()
 Reset TCAS target slot index to -1 More...
 
virtual std::string GetFlightId () const
 Return a value for dataRef .../tcas/target/flight_id. More...
 
Model Matching
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 More...
 
int ReMatchModel ()
 Finds a match again, using the existing parameters, eg. after more models have been loaded. More...
 
bool AssignModel (const std::string &_cslId, CSLModel *_pCSLModel=nullptr)
 Assigns the given model. More...
 
XPMP2::CSLModelGetModel () const
 return a pointer to the CSL model in use (Note: The CSLModel structure is not public.) More...
 
const std::string & GetModelName () const
 return the name of the CSL model in use More...
 
CSLModelInfo_t GetModelInfo () const
 return an information structure for the CSL model associated with the aircraft More...
 
int GetMatchQuality () const
 quality of the match with the CSL model More...
 
Visualization
float GetVertOfs () const
 Vertical offset, ie. the value that needs to be added to drawInfo.y to make the aircraft appear on the ground. More...
 
bool IsValid () const
 Is the a/c object valid? More...
 
virtual void SetInvalid ()
 Mark the plane invalid, e.g. after exceptions occured on the data. More...
 
virtual void SetVisible (bool _bVisible)
 Make the plane (in)visible. More...
 
bool IsVisible () const
 Is the plane visible? More...
 
virtual void SetRender (bool _bRender)
 Switch rendering of the CSL model on or off. More...
 
bool IsRendered () const
 Is this plane to be rendered? More...
 
bool IsInstanciated () const
 Are instances created for this aircraft? More...
 
void SetDrawLabel (bool _b)
 Define if this aircraft's label is to be drawn (provided label drawing is enabled globally) More...
 
bool ShallDrawLabel () const
 Shall this aircraft's label be drawn? More...
 
float GetCameraDist () const
 Distance to camera [m]. More...
 
float GetCameraBearing () const
 Bearing from camera [°]. More...
 
virtual void UpdatePosition (float _elapsedSinceLastCall, int _flCounter)=0
 Called right before updating the aircraft's placement in the world. More...
 
bool IsOnGrnd () const
 Is the aircraft on the ground? More...
 
void SetOnGrnd (bool on_grnd, float setTouchDownTime=NAN)
 Set if the aircraft is on the ground. More...
 
Getters and Setters for the values in Aircraft::drawInfo
void SetLocation (double lat, double lon, double alt_ft, bool on_grnd, float setTouchDownTime=NAN)
 Converts world coordinates to local coordinates, writes to Aircraft::drawInfo. More...
 
void SetLocation (double lat, double lon, double alt_ft)
 Legacy version of above version of SetLocatiion(), here without setting ground flag. More...
 
void GetLocation (double &lat, double &lon, double &alt_ft) const
 Converts aircraft's local coordinates to lat/lon values. More...
 
void SetLocalLoc (float _x, float _y, float _z)
 Sets location in local world coordinates. More...
 
const XPLMDrawInfo_t & GetLocation () const
 Gets all location info (including local coordinates) More...
 
float GetPitch () const
 pitch [degree] More...
 
void SetPitch (float _deg)
 pitch [degree] More...
 
float GetHeading () const
 heading [degree] More...
 
void SetHeading (float _deg)
 heading [degree] More...
 
float GetRoll () const
 roll [degree] More...
 
void SetRoll (float _deg)
 roll [degree] More...
 
float GetGS_kn () const
 Rough estimate of a ground speed based on v_x/z More...
 
Getters and Setters for the values in the Aircraft::v array
float GetGearRatio () const
 Gear deploy ratio. More...
 
void SetGearRatio (float _f)
 Gear deploy ratio. More...
 
float GetNoseWheelAngle () const
 Nose Wheel angle in degrees. More...
 
void SetNoseWheelAngle (float _f)
 Nose Wheel angle in degrees. More...
 
float GetFlapRatio () const
 Flaps deploy ratio. More...
 
void SetFlapRatio (float _f)
 Flaps deploy ratio. More...
 
float GetSpoilerRatio () const
 Spoilers deploy ratio. More...
 
void SetSpoilerRatio (float _f)
 Spoilers deploy ratio. More...
 
float GetSpeedbrakeRatio () const
 Speedbrakes deploy ratio. More...
 
void SetSpeedbrakeRatio (float _f)
 Speedbrakes deploy ratio. More...
 
float GetSlatRatio () const
 Slats deploy ratio. More...
 
void SetSlatRatio (float _f)
 Slats deploy ratio. More...
 
float GetWingSweepRatio () const
 Wing sweep ratio. More...
 
void SetWingSweepRatio (float _f)
 Wing sweep ratio. More...
 
float GetThrustRatio () const
 Thrust ratio. More...
 
void SetThrustRatio (float _f)
 Thrust ratio. More...
 
float GetYokePitchRatio () const
 Yoke pitch ratio. More...
 
void SetYokePitchRatio (float _f)
 Yoke pitch ratio. More...
 
float GetYokeHeadingRatio () const
 Yoke heading ratio. More...
 
void SetYokeHeadingRatio (float _f)
 Yoke heading ratio. More...
 
float GetYokeRollRatio () const
 Yoke roll ratio. More...
 
void SetYokeRollRatio (float _f)
 Yoke roll ratio. More...
 
float GetThrustReversRatio () const
 Thrust reversers ratio. More...
 
void SetThrustReversRatio (float _f)
 Thrust reversers ratio. More...
 
bool GetLightsTaxi () const
 Taxi lights. More...
 
void SetLightsTaxi (bool _b)
 Taxi lights. More...
 
bool GetLightsLanding () const
 Landing lights. More...
 
void SetLightsLanding (bool _b)
 Landing lights. More...
 
bool GetLightsBeacon () const
 Beacon lights. More...
 
void SetLightsBeacon (bool _b)
 Beacon lights. More...
 
bool GetLightsStrobe () const
 Strobe lights. More...
 
void SetLightsStrobe (bool _b)
 Strobe lights. More...
 
bool GetLightsNav () const
 Navigation lights. More...
 
void SetLightsNav (bool _b)
 Navigation lights. More...
 
float GetNoseGearDeflection () const
 Vertical nose gear deflection [meter]. More...
 
void SetNoseGearDeflection (float _mtr)
 Vertical nose gear deflection [meter]. More...
 
float GetTireDeflection () const
 Vertical (main) gear deflection [meter]. More...
 
void SetTireDeflection (float _mtr)
 Vertical (main) gear deflection [meter]. More...
 
float GetTireRotAngle () const
 Tire rotation angle [degree]. More...
 
void SetTireRotAngle (float _deg)
 Tire rotation angle [degree]. More...
 
float GetTireRotRpm () const
 Tire rotation speed [rpm]. More...
 
void SetTireRotRpm (float _rpm)
 
float GetTireRotRad () const
 Tire rotation speed [rad/s]. More...
 
void SetTireRotRad (float _rad)
 
float GetEngineRotAngle () const
 Engine rotation angle [degree]. More...
 
void SetEngineRotAngle (float _deg)
 Engine rotation angle [degree], also sets engines 1..4. More...
 
float GetEngineRotRpm () const
 Engine rotation speed [rpm]. More...
 
void SetEngineRotRpm (float _rpm)
 Engine rotation speed [rpm], also sets [rad/s] and engines 1..4. More...
 
float GetEngineRotRad () const
 Engine rotation speed [rad/s]. More...
 
void SetEngineRotRad (float _rad)
 Engine rotation speed [rad/s], also sets [rpm] and engines 1..4. More...
 
float GetEngineRotAngle (size_t idx) const
 < Engine rotation angle [degree] for engine idx (1..4) More...
 
void SetEngineRotAngle (size_t idx, float _deg)
 Engine rotation angle [degree] for engine idx (1..4) More...
 
float GetEngineRotRpm (size_t idx) const
 < Engine rotation speed [rpm] for engine idx (1..4) More...
 
void SetEngineRotRpm (size_t idx, float _rpm)
 Engine rotation speed [rpm] for engine idx (1..4), also sets [rad/s]. More...
 
float GetEngineRotRad (size_t idx) const
 < Engine rotation speed [rad/s] for engine idx (1..4) More...
 
void SetEngineRotRad (size_t idx, float _rad)
 Engine rotation speed [rad/s] for engine idx (1..4), also sets [rpm]. More...
 
float GetPropRotAngle () const
 Propellor rotation angle [degree]. More...
 
void SetPropRotAngle (float _deg)
 Propellor rotation angle [degree]. More...
 
float GetPropRotRpm () const
 Propellor rotation speed [rpm]. More...
 
void SetPropRotRpm (float _rpm)
 
float GetPropRotRad () const
 Propellor rotation speed [rad/s]. More...
 
void SetPropRotRad (float _rad)
 
float GetReversDeployRatio () const
 Thrust reversers deploy ratio. More...
 
void SetReversDeployRatio (float _f)
 Thrust reversers deploy ratio. More...
 
bool GetTouchDown () const
 Moment of touch down. More...
 
void SetTouchDown (bool _b)
 Moment of touch down. More...
 
Wake support as per X-Plane 12
void WakeApplyDefaults (bool _bOverwriteAllFields=true)
 Fill in default wake turbulence support data based on Doc8643 wake turbulence category. More...
 
float GetWingSpan () const
 Wing span [m]. More...
 
void SetWingSpan (float _m)
 Wing span [m]. More...
 
float GetWingArea () const
 Wing area [m²]. More...
 
void SetWingArea (float _m2)
 Wing area [m²]. More...
 
int GetWakeCat () const
 Category between 0=light and 3=Super, derived from WTC. More...
 
float GetMass () const
 Mass [kg]. More...
 
void SetMass (float _kg)
 Mass [kg]. More...
 
virtual float GetAoA () const
 Angle of Attach, returns pitch (but you can override in your class) More...
 
virtual float GetLift () const
 Lift produced. You should override to blend in/out for take-off/landing, but XPMP2 has no dynamic info of your plane, not even an on-the-ground flag. More...
 
Contrails
Note
Implemented in Contrail.cpp
unsigned ContrailTrigger ()
 Trigger standard contrails as per plane type. More...
 
void ContrailRequest (unsigned num, unsigned dist_m=0, unsigned lifeTime=0)
 Request Contrails. More...
 
void ContrailRemove ()
 Remove all contrail objects. More...
 
Map Support
Note
Implemented in Map.cpp
void MapFindIcon ()
 Determine which map icon to use for this aircraft. More...
 
void MapPreparePos (XPLMMapProjectionID projection, const float boundsLTRB[4])
 Prepare map coordinates. More...
 
void MapDrawIcon (XPLMMapLayerID inLayer, float acSize)
 Actually draw the map icon. More...
 
void MapDrawLabel (XPLMMapLayerID inLayer, float yOfs)
 Actually draw the map label. More...
 
Sound Support
Note
Implemented in Sound.cpp
uint64_t SoundPlay (const std::string &sndName, float vol=1.0f)
 Play a sound; a looping sound plays until explicitely stopped. More...
 
void SoundStop (uint64_t chnId)
 Stop a continuously playing sound. More...
 
void SoundVolume (uint64_t chnId, float vol)
 Sets the sound's volume (after applying master volume and Sound File's adjustments) More...
 
void SoundMuteAll (bool bMute)
 Mute/Unmute all sounds of the airplane temporarily. More...
 
bool SoundIsMuted () const
 Are all sounds currently muted? More...
 
virtual std::string SoundGetName (SoundEventsTy sndEvent, float &volAdj) const
 Returns the name of the sound to play per event. More...
 

Public Attributes

std::string acIcaoType
 ICAO aircraft type designator of this plane. More...
 
std::string acIcaoAirline
 ICAO Airline code of this plane. More...
 
std::string acLivery
 Livery code of this plane. More...
 
XPLMDrawInfo_t drawInfo
 Holds position (in local coordinates!) and orientation (pitch, heading roll) of the aircraft. More...
 
float v_x = 0.0f
 Cartesian velocity in m/s per axis, updated at least once per second. More...
 
float v_y = 0.0f
 
float v_z = 0.0f
 
bool bOnGrnd = false
 Is the aircraft on the ground? More...
 
std::vector< float > v
 actual dataRef values to be provided to the CSL model More...
 
std::string label
 aircraft label shown in the 3D world next to the plane More...
 
float colLabel [4] = {1.0f,1.0f,0.0f,1.0f}
 label base color (RGB) More...
 
bool bDrawLabel = true
 Shall this aircraft's label be drawn? More...
 
float vertOfsRatio = 1.0f
 How much of the vertical offset shall be applied? (This allows phasing out the vertical offset in higher altitudes.) [0..1]. More...
 
float gearDeflectRatio = 0.5f
 By how much of the gear deflection shall the plane's altitude be reduced? More...
 
bool bClampToGround = false
 Shall this plane be clamped to ground (ie. never sink below ground)? More...
 
int aiPrio = 1
 Priority for display in one of the limited number of TCAS target slots. More...
 
XPMPPlaneRadar_t acRadar
 Current radar status. More...
 
std::list< XPLMInstanceRef > listContrail
 Contrail: list of objects for contrail generation. More...
 
unsigned contrailNum = 0
 number of contrails requested More...
 
unsigned contrailDist_m = 5
 distance between several contrails and to the aircraft's centerline, in meter More...
 
unsigned contrailLifeTime = 25
 this aircraft's contrail's life time More...
 
struct XPMP2::Aircraft::wakeTy wake
 wake-support data More...
 
XPMPInfoTexts_t acInfoTexts
 Informational texts passed on via multiplayer shared dataRefs. More...
 
int sndMinDist = 50
 Minimum distance in [m] to play sound in full volume, the larger the 'louder' the aircraft. More...
 

Protected Member Functions

Internal Control Functions
void DoMove ()
 Internal: This puts the instance into XP's sky and makes it move. More...
 
void DoEverySecondUpdates (float now)
 Internal: Processes once every second only stuff that doesn't require being computed every flight loop. More...
 
void ContrailMove ()
 Internal: Create/move contrails, implemented in Contrail.cpp. More...
 
void ContrailAutoUpdate ()
 Internal: (Re)Assess if contrails are to be created. More...
 
void UpdateDistBearingCamera (const XPLMCameraPosition_t &posCam)
 Internal: Update the plane's distance/bearing from the camera location. More...
 
void ClampToGround ()
 Clamp to ground: Make sure the plane is not below ground, corrects Aircraft::drawInfo if needed. More...
 
bool CreateInstances ()
 Create the instances required to represent the plane, return if successful. More...
 
void DestroyInstances ()
 Destroy all instances. More...
 
virtual void ComputeMapLabel ()
 Put together the map label. More...
 
virtual void SetTcasTargetIdx (int _idx)
 Define the TCAS target index in use. More...
 
Sound Support (internal)
Note
Implemented in Sound.cpp
virtual void SoundSetup ()
 Sound-related initializations, called by Create() and ChangeModel() More...
 
virtual void SoundUpdate ()
 Update sound, like position and volume, called once per frame. More...
 
virtual void SoundRemoveAll ()
 Remove all sound, e.g. during destruction. More...
 

Static Protected Member Functions

static float FlightLoopCB (float, float, int, void *)
 Internal: Flight loop callback function controlling update and movement of all planes. More...
 

Protected Attributes

XPMPPlaneID modeS_id = 0
 A plane is uniquely identified by a 24bit number [0x01..0xFFFFFF]. More...
 
bool bValid = true
 is this object valid? (Will be reset in case of exceptions) More...
 
bool bVisible = true
 Shall this plane be drawn at the moment and be visible to TCAS/interfaces? More...
 
bool bRender = true
 Shall the CSL model be drawn in 3D world? (if !bRender && bVivile then still visible on TCAS/interfaces, Remote Client uses this for local senders' planes to take over TCAS but not drawing) More...
 
XPMP2::CSLModelpCSLMdl = nullptr
 the CSL model in use More...
 
int matchQuality = -1
 quality of the match with the CSL model More...
 
int acRelGrp = 0
 related group, ie. line in related.txt in which this a/c appears, if any More...
 
float prev_x = 0.0f
 
float prev_y = 0.0f
 
float prev_z = 0.0f
 
float prev_ts = 0.0f
 last update of prev_x/y/z in XP's network time More...
 
float gs_kn = 0.0f
 
double lat1s = NAN
 ground speed in [kn] based on above v_x/z More...
 
double lon1s = NAN
 
double alt1s_ft = NAN
 
float tsResetTouchDown = NAN
 Set by SetOnGrnd() with the timestamp when to reset SetTouchDown() More...
 
std::list< XPLMInstanceRef > listInst
 X-Plane instance handles for all objects making up the model. More...
 
int tcasTargetIdx = -1
 Which sim/cockpit2/tcas/targets-index does this plane occupy? [1..63], -1 if none. More...
 
float camTimLstUpd = 0.0f
 Timestamp of last update of camera dist/bearing. More...
 
float camDist = 0.0f
 Distance to camera in meters (updated internally regularly) More...
 
float camBearing = 0.0f
 Bearing from camera in degrees (updated internally regularly) More...
 
XPLMProbeRef hProbe = nullptr
 Y Probe for terrain testing, needed in ground clamping. More...
 
int mapIconRow = 0
 map icon coordinates, row More...
 
int mapIconCol = 0
 map icon coordinates, column More...
 
float mapX = 0.0f
 temporary: map coordinates (NAN = not to be drawn) More...
 
float mapY = 0.0f
 temporary: map coordinates (NAN = not to be drawn) More...
 
std::string mapLabel
 label for map drawing More...
 
SndChTy aSndCh [SND_NUM_EVENTS]
 Operational values per sound channel, that is triggered by a standard sound event. More...
 
bool bChnMuted = false
 Is sound for this aircraft currently muted? More...
 
ChnListTy chnList
 List of channels produced via calls to SoundPlay() More...
 
int skipCounter = 0
 Counts how often we skipped expensive computations. More...
 

Friends

void AIMultiUpdate ()
 Updates all TCAS target dataRefs, both standard X-Plane, as well as additional shared dataRefs for text publishing. More...
 
size_t AIUpdateTCASTargets ()
 The modern way: Use TCAS override and update TCAS targets. More...
 
size_t AIUpdateMultiplayerDataRefs ()
 The old way: Update Multiplayer dataRefs directly. More...
 

Detailed Description

Actual representation of all aircraft in XPMP2.

Note
In modern implementations, this class shall be subclassed by your plugin's code.

Class Documentation

◆ XPMP2::Aircraft::SndChTy

struct XPMP2::Aircraft::SndChTy

Operational values per sound channel, that is triggered by a standard sound event.

Class Members
bool bAuto Shall this sound event be handled automatically? (Set to false in your constructor or in Aircraft::SoundSetup() if you want to control that event type yourself)
uint64_t chnId id of channel playing the sound currently
float lastDRVal last observed dataRef value to see if sound is to be triggered
float volAdj Volume adjustment, fed from Aircraft::SoundGetName()

Member Typedef Documentation

◆ ChnListTy

typedef std::list<uint64_t> XPMP2::Aircraft::ChnListTy

List of sound channel ids, also beyond sounds created for SoundEventsTy.

Member Enumeration Documentation

◆ SoundEventsTy

Types of sound supported directly by XPMP2.

Enumerator
SND_ENG 

Engine sound (continuously while engine running), bases on GetThrustRatio()

SND_REVERSE_THRUST 

Engine sound while reverse thrust (continuously while reversers deployed), bases on GetThrustReversRatio()

SND_TIRE 

Tires rolling on the ground (continuously while rolling on ground), bases on GetTireRotRpm()

SND_GEAR 

Gear extending/retracting (once per event), bases on GetGearRatio()

SND_FLAPS 

Flaps extending/retracting (once per event), bases on GetFlapRatio()

SND_NUM_EVENTS 

Number of events (always last in enum)

Constructor & Destructor Documentation

◆ Aircraft() [1/3]

XPMP2::Aircraft::Aircraft ( const std::string &  _icaoType,
const std::string &  _icaoAirline,
const std::string &  _livery,
XPMPPlaneID  _modeS_id = 0,
const std::string &  _cslId = "" 
)

Constructor creates a new aircraft object, which will be managed and displayed.

Exceptions
XPMP2::XPMP2ErrorMode S id invalid or duplicate, no model found during model matching
Parameters
_icaoTypeICAO aircraft type designator, like 'A320', 'B738', 'C172'
_icaoAirlineICAO airline code, like 'BAW', 'DLH', can be an empty string
_liverySpecial livery designator, can be an empty string
_modeS_id(optional) Unique identification of the plane [0x01..0xFFFFFF], e.g. the 24bit mode S transponder code. XPMP2 assigns an arbitrary unique number of not given
_cslId(optional) specific unique model id to be used (package name/short id, as defined in the OBJ8_AIRCRAFT line)

◆ Aircraft() [2/3]

XPMP2::Aircraft::Aircraft ( )

Default constructor creates an empty, invalid(!) and invisible shell; call XPMP2::Aircraft::Create() to actually create a plane.

◆ ~Aircraft()

XPMP2::Aircraft::~Aircraft ( )
virtual

Destructor cleans up all resources acquired.

◆ Aircraft() [3/3]

XPMP2::Aircraft::Aircraft ( const Aircraft )
delete

Aircraft must not be copied as they reference non-copyable resources like XP instances.

Member Function Documentation

◆ AssignModel()

bool XPMP2::Aircraft::AssignModel ( const std::string &  _cslId,
CSLModel _pCSLModel = nullptr 
)

Assigns the given model.

Parameters
_cslIdSearch for this id (package/short)
_pCSLModel(optional) If given use this model and don't search
Returns
Successfuly found and assigned a model?

◆ ChangeModel()

int XPMP2::Aircraft::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

Parameters
_icaoTypeICAO aircraft type designator, like 'A320', 'B738', 'C172'
_icaoAirlineICAO airline code, like 'BAW', 'DLH', can be an empty string
_liverySpecial livery designator, can be an empty string
Returns
match quality, the lower the better

◆ ClampToGround()

void XPMP2::Aircraft::ClampToGround ( )
protected

Clamp to ground: Make sure the plane is not below ground, corrects Aircraft::drawInfo if needed.

◆ ComputeMapLabel()

void XPMP2::Aircraft::ComputeMapLabel ( )
protectedvirtual

Put together the map label.

Called about once a second. Label depends on tcasTargetIdx

◆ ContrailAutoUpdate()

void XPMP2::Aircraft::ContrailAutoUpdate ( )
protected

Internal: (Re)Assess if contrails are to be created.

◆ ContrailMove()

void XPMP2::Aircraft::ContrailMove ( )
protected

Internal: Create/move contrails, implemented in Contrail.cpp.

◆ ContrailRemove()

void XPMP2::Aircraft::ContrailRemove ( )

Remove all contrail objects.

◆ ContrailRequest()

void XPMP2::Aircraft::ContrailRequest ( unsigned  num,
unsigned  dist_m = 0,
unsigned  lifeTime = 0 
)

Request Contrails.

They are not actually created here, that happens later in the flight loop

Parameters
numNumber of contrails. Keep performance impact in mind, 1 might be sufficient. Passing 0 will cause the contrails to be removed.
dist_mIf more than one contrail is created, this is the spacing between them and the aircraft's centerline in meters. 0 means no change: use current value of contrailDist_m, which in turn is initialized to 5
lifeTimeis the time to live in seconds for each contrail puff, indirectly determining its length; 0 means no change: use current value of contrailLifeTime, which in turn is initialized from global configuration item XPMP_CFG_ITM_CONTR_LIFE

◆ ContrailTrigger()

unsigned XPMP2::Aircraft::ContrailTrigger ( )

Trigger standard contrails as per plane type.

Bases on Doc8643 data. Contrails will be created for Jets only. No contrails for non-jet aircraft. Contrails will be created as per global configuration (multi? life time), see XPMP_CFG_ITM_CONTR_* config items. If you want more control use ContrailRequest().

Returns
Number of created contrails

◆ Create()

void XPMP2::Aircraft::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.

Exceptions
Triedon already defined object; XPMP2::XPMP2Error Mode S id invalid or duplicate, no model found during model matching
Parameters
_icaoTypeICAO aircraft type designator, like 'A320', 'B738', 'C172'
_icaoAirlineICAO airline code, like 'BAW', 'DLH', can be an empty string
_liverySpecial livery designator, can be an empty string
_modeS_id(optional) Unique identification of the plane [0x01..0xFFFFFF], e.g. the 24bit mode S transponder code. XPMP2 assigns an arbitrary unique number of not given
_cslId(optional) specific unique model id to be used (package name/short id, as defined in the OBJ8_AIRCRAFT line)
_pCSLModel(optional) The actual model to use (no matching or search by _cslId if model is given this way)

◆ CreateInstances()

bool XPMP2::Aircraft::CreateInstances ( )
protected

Create the instances required to represent the plane, return if successful.

◆ DestroyInstances()

void XPMP2::Aircraft::DestroyInstances ( )
protected

Destroy all instances.

◆ DoEverySecondUpdates()

void XPMP2::Aircraft::DoEverySecondUpdates ( float  now)
protected

Internal: Processes once every second only stuff that doesn't require being computed every flight loop.

◆ DoMove()

void XPMP2::Aircraft::DoMove ( )
protected

Internal: This puts the instance into XP's sky and makes it move.

◆ FlightLoopCB()

float XPMP2::Aircraft::FlightLoopCB ( float  _elapsedSinceLastCall,
float  ,
int  _flCounter,
void *   
)
staticprotected

Internal: Flight loop callback function controlling update and movement of all planes.

◆ GetAoA()

virtual float XPMP2::Aircraft::GetAoA ( ) const
inlinevirtual

Angle of Attach, returns pitch (but you can override in your class)

◆ GetCameraBearing()

float XPMP2::Aircraft::GetCameraBearing ( ) const
inline

Bearing from camera [°].

◆ GetCameraDist()

float XPMP2::Aircraft::GetCameraDist ( ) const
inline

Distance to camera [m].

◆ GetEngineRotAngle() [1/2]

float XPMP2::Aircraft::GetEngineRotAngle ( ) const
inline

Engine rotation angle [degree].

◆ GetEngineRotAngle() [2/2]

float XPMP2::Aircraft::GetEngineRotAngle ( size_t  idx) const
inline

< Engine rotation angle [degree] for engine idx (1..4)

◆ GetEngineRotRad() [1/2]

float XPMP2::Aircraft::GetEngineRotRad ( ) const
inline

Engine rotation speed [rad/s].

◆ GetEngineRotRad() [2/2]

float XPMP2::Aircraft::GetEngineRotRad ( size_t  idx) const
inline

< Engine rotation speed [rad/s] for engine idx (1..4)

◆ GetEngineRotRpm() [1/2]

float XPMP2::Aircraft::GetEngineRotRpm ( ) const
inline

Engine rotation speed [rpm].

◆ GetEngineRotRpm() [2/2]

float XPMP2::Aircraft::GetEngineRotRpm ( size_t  idx) const
inline

< Engine rotation speed [rpm] for engine idx (1..4)

◆ GetFlapRatio()

float XPMP2::Aircraft::GetFlapRatio ( ) const
inline

Flaps deploy ratio.

◆ GetFlightId()

std::string XPMP2::Aircraft::GetFlightId ( ) const
virtual

Return a value for dataRef .../tcas/target/flight_id.

Returns
The first non-empty string out of: flight number, registration, departure/arrival airports

◆ GetGearRatio()

float XPMP2::Aircraft::GetGearRatio ( ) const
inline

Gear deploy ratio.

◆ GetGS_kn()

float XPMP2::Aircraft::GetGS_kn ( ) const
inline

Rough estimate of a ground speed based on v_x/z

◆ GetHeading()

float XPMP2::Aircraft::GetHeading ( ) const
inline

heading [degree]

◆ GetLift()

virtual float XPMP2::Aircraft::GetLift ( ) const
inlinevirtual

Lift produced. You should override to blend in/out for take-off/landing, but XPMP2 has no dynamic info of your plane, not even an on-the-ground flag.

◆ GetLightsBeacon()

bool XPMP2::Aircraft::GetLightsBeacon ( ) const
inline

Beacon lights.

◆ GetLightsLanding()

bool XPMP2::Aircraft::GetLightsLanding ( ) const
inline

Landing lights.

◆ GetLightsNav()

bool XPMP2::Aircraft::GetLightsNav ( ) const
inline

Navigation lights.

◆ GetLightsStrobe()

bool XPMP2::Aircraft::GetLightsStrobe ( ) const
inline

Strobe lights.

◆ GetLightsTaxi()

bool XPMP2::Aircraft::GetLightsTaxi ( ) const
inline

Taxi lights.

◆ GetLocation() [1/2]

const XPLMDrawInfo_t& XPMP2::Aircraft::GetLocation ( ) const
inline

Gets all location info (including local coordinates)

◆ GetLocation() [2/2]

void XPMP2::Aircraft::GetLocation ( double &  lat,
double &  lon,
double &  alt_ft 
) const

Converts aircraft's local coordinates to lat/lon values.

Warning
This isn't exactly precice. If you need precise location keep it in your derived class yourself.

◆ GetMass()

float XPMP2::Aircraft::GetMass ( ) const
inline

Mass [kg].

◆ GetMatchQuality()

int XPMP2::Aircraft::GetMatchQuality ( ) const
inline

quality of the match with the CSL model

◆ GetModel()

XPMP2::CSLModel* XPMP2::Aircraft::GetModel ( ) const
inline

return a pointer to the CSL model in use (Note: The CSLModel structure is not public.)

◆ GetModelInfo()

CSLModelInfo_t XPMP2::Aircraft::GetModelInfo ( ) const
inline

return an information structure for the CSL model associated with the aircraft

◆ GetModelName()

const std::string & XPMP2::Aircraft::GetModelName ( ) const

return the name of the CSL model in use

◆ GetModeS_ID()

XPMPPlaneID XPMP2::Aircraft::GetModeS_ID ( ) const
inline

return the XPMP2 plane id

◆ GetNoseGearDeflection()

float XPMP2::Aircraft::GetNoseGearDeflection ( ) const
inline

Vertical nose gear deflection [meter].

◆ GetNoseWheelAngle()

float XPMP2::Aircraft::GetNoseWheelAngle ( ) const
inline

Nose Wheel angle in degrees.

◆ GetPitch()

float XPMP2::Aircraft::GetPitch ( ) const
inline

pitch [degree]

◆ GetPropRotAngle()

float XPMP2::Aircraft::GetPropRotAngle ( ) const
inline

Propellor rotation angle [degree].

◆ GetPropRotRad()

float XPMP2::Aircraft::GetPropRotRad ( ) const
inline

Propellor rotation speed [rad/s].

◆ GetPropRotRpm()

float XPMP2::Aircraft::GetPropRotRpm ( ) const
inline

Propellor rotation speed [rpm].

◆ GetReversDeployRatio()

float XPMP2::Aircraft::GetReversDeployRatio ( ) const
inline

Thrust reversers deploy ratio.

◆ GetRoll()

float XPMP2::Aircraft::GetRoll ( ) const
inline

roll [degree]

◆ GetSlatRatio()

float XPMP2::Aircraft::GetSlatRatio ( ) const
inline

Slats deploy ratio.

◆ GetSpeedbrakeRatio()

float XPMP2::Aircraft::GetSpeedbrakeRatio ( ) const
inline

Speedbrakes deploy ratio.

◆ GetSpoilerRatio()

float XPMP2::Aircraft::GetSpoilerRatio ( ) const
inline

Spoilers deploy ratio.

◆ GetTcasTargetIdx()

int XPMP2::Aircraft::GetTcasTargetIdx ( ) const
inline

return the current TCAS target index (into sim/cockpit2/tcas/targets), 1-based, -1 if not used

◆ GetThrustRatio()

float XPMP2::Aircraft::GetThrustRatio ( ) const
inline

Thrust ratio.

◆ GetThrustReversRatio()

float XPMP2::Aircraft::GetThrustReversRatio ( ) const
inline

Thrust reversers ratio.

◆ GetTireDeflection()

float XPMP2::Aircraft::GetTireDeflection ( ) const
inline

Vertical (main) gear deflection [meter].

◆ GetTireRotAngle()

float XPMP2::Aircraft::GetTireRotAngle ( ) const
inline

Tire rotation angle [degree].

◆ GetTireRotRad()

float XPMP2::Aircraft::GetTireRotRad ( ) const
inline

Tire rotation speed [rad/s].

◆ GetTireRotRpm()

float XPMP2::Aircraft::GetTireRotRpm ( ) const
inline

Tire rotation speed [rpm].

◆ GetTouchDown()

bool XPMP2::Aircraft::GetTouchDown ( ) const
inline

Moment of touch down.

◆ GetVertOfs()

float XPMP2::Aircraft::GetVertOfs ( ) const

Vertical offset, ie. the value that needs to be added to drawInfo.y to make the aircraft appear on the ground.

  1. add VERT_OFFSET, which pushes the plane up on the tarmac onto its gear
    1. reduce again by the tire deflection (which reduces gear's size, but based on experience is not exactly aligned with planes altitude in meters.

◆ GetWakeCat()

int XPMP2::Aircraft::GetWakeCat ( ) const

Category between 0=light and 3=Super, derived from WTC.

◆ GetWingArea()

float XPMP2::Aircraft::GetWingArea ( ) const
inline

Wing area [m²].

◆ GetWingSpan()

float XPMP2::Aircraft::GetWingSpan ( ) const
inline

Wing span [m].

◆ GetWingSweepRatio()

float XPMP2::Aircraft::GetWingSweepRatio ( ) const
inline

Wing sweep ratio.

◆ GetYokeHeadingRatio()

float XPMP2::Aircraft::GetYokeHeadingRatio ( ) const
inline

Yoke heading ratio.

◆ GetYokePitchRatio()

float XPMP2::Aircraft::GetYokePitchRatio ( ) const
inline

Yoke pitch ratio.

◆ GetYokeRollRatio()

float XPMP2::Aircraft::GetYokeRollRatio ( ) const
inline

Yoke roll ratio.

◆ IsCurrentlyShownAsAI()

bool XPMP2::Aircraft::IsCurrentlyShownAsAI ( ) const

Is this plane currently also being tracked by X-Plane's classic AI/multiplayer?

◆ IsCurrentlyShownAsTcasTarget()

bool XPMP2::Aircraft::IsCurrentlyShownAsTcasTarget ( ) const
inline

Is this plane currently also being tracked as a TCAS target, ie. will appear on TCAS?

◆ IsGlider()

bool XPMP2::Aircraft::IsGlider ( ) const
inline

Is this object a glider?

◆ IsGroundVehicle()

bool XPMP2::Aircraft::IsGroundVehicle ( ) const

Is this object a ground vehicle? (related to glob.carIcaoType)

◆ IsInstanciated()

bool XPMP2::Aircraft::IsInstanciated ( ) const
inline

Are instances created for this aircraft?

◆ IsOnGrnd()

bool XPMP2::Aircraft::IsOnGrnd ( ) const
inline

Is the aircraft on the ground?

◆ IsRelatedTo()

bool XPMP2::Aircraft::IsRelatedTo ( const std::string &  _icaoType) const

Is this object "related" to the given ICAO code? (named in the same line in related.txt)

Parameters
_icaoTypeICAO aircraft type designator, to which *this is compared

For example, IsRelatedTo("GLID") returns if *this is a glider

◆ IsRendered()

bool XPMP2::Aircraft::IsRendered ( ) const
inline

Is this plane to be rendered?

◆ IsValid()

bool XPMP2::Aircraft::IsValid ( ) const
inline

Is the a/c object valid?

◆ IsVisible()

bool XPMP2::Aircraft::IsVisible ( ) const
inline

Is the plane visible?

◆ MapDrawIcon()

void XPMP2::Aircraft::MapDrawIcon ( XPLMMapLayerID  inLayer,
float  acSize 
)

Actually draw the map icon.

◆ MapDrawLabel()

void XPMP2::Aircraft::MapDrawLabel ( XPLMMapLayerID  inLayer,
float  yOfs 
)

Actually draw the map label.

◆ MapFindIcon()

void XPMP2::Aircraft::MapFindIcon ( )

Determine which map icon to use for this aircraft.

MapIcon.png has the following models:
y \ x | 0       | 1   | 2   
----- | ------- | --- | ----
2     | H1T     | Car | GLID
1     | L1P     | L2P | L4P 
0     | Default | L2J | L4J 

◆ MapPreparePos()

void XPMP2::Aircraft::MapPreparePos ( XPLMMapProjectionID  projection,
const float  boundsLTRB[4] 
)

Prepare map coordinates.

◆ operator=()

Aircraft& XPMP2::Aircraft::operator= ( const Aircraft )
delete

Aircraft must not be copied as they reference non-copyable resources like XP instances.

◆ ReMatchModel()

int XPMP2::Aircraft::ReMatchModel ( )
inline

Finds a match again, using the existing parameters, eg. after more models have been loaded.

Returns
match quality, the lower the better

◆ ResetTcasTargetIdx()

void XPMP2::Aircraft::ResetTcasTargetIdx ( )
inline

Reset TCAS target slot index to -1

◆ SetDrawLabel()

void XPMP2::Aircraft::SetDrawLabel ( bool  _b)
inline

Define if this aircraft's label is to be drawn (provided label drawing is enabled globally)

◆ SetEngineRotAngle() [1/2]

void XPMP2::Aircraft::SetEngineRotAngle ( float  _deg)

Engine rotation angle [degree], also sets engines 1..4.

◆ SetEngineRotAngle() [2/2]

void XPMP2::Aircraft::SetEngineRotAngle ( size_t  idx,
float  _deg 
)

Engine rotation angle [degree] for engine idx (1..4)

◆ SetEngineRotRad() [1/2]

void XPMP2::Aircraft::SetEngineRotRad ( float  _rad)

Engine rotation speed [rad/s], also sets [rpm] and engines 1..4.

◆ SetEngineRotRad() [2/2]

void XPMP2::Aircraft::SetEngineRotRad ( size_t  idx,
float  _rad 
)

Engine rotation speed [rad/s] for engine idx (1..4), also sets [rpm].

◆ SetEngineRotRpm() [1/2]

void XPMP2::Aircraft::SetEngineRotRpm ( float  _rpm)

Engine rotation speed [rpm], also sets [rad/s] and engines 1..4.

◆ SetEngineRotRpm() [2/2]

void XPMP2::Aircraft::SetEngineRotRpm ( size_t  idx,
float  _rpm 
)

Engine rotation speed [rpm] for engine idx (1..4), also sets [rad/s].

◆ SetFlapRatio()

void XPMP2::Aircraft::SetFlapRatio ( float  _f)
inline

Flaps deploy ratio.

◆ SetGearRatio()

void XPMP2::Aircraft::SetGearRatio ( float  _f)
inline

Gear deploy ratio.

◆ SetHeading()

void XPMP2::Aircraft::SetHeading ( float  _deg)
inline

heading [degree]

◆ SetInvalid()

void XPMP2::Aircraft::SetInvalid ( )
virtual

Mark the plane invalid, e.g. after exceptions occured on the data.

◆ SetLightsBeacon()

void XPMP2::Aircraft::SetLightsBeacon ( bool  _b)
inline

Beacon lights.

◆ SetLightsLanding()

void XPMP2::Aircraft::SetLightsLanding ( bool  _b)
inline

Landing lights.

◆ SetLightsNav()

void XPMP2::Aircraft::SetLightsNav ( bool  _b)
inline

Navigation lights.

◆ SetLightsStrobe()

void XPMP2::Aircraft::SetLightsStrobe ( bool  _b)
inline

Strobe lights.

◆ SetLightsTaxi()

void XPMP2::Aircraft::SetLightsTaxi ( bool  _b)
inline

Taxi lights.

◆ SetLocalLoc()

void XPMP2::Aircraft::SetLocalLoc ( float  _x,
float  _y,
float  _z 
)
inline

Sets location in local world coordinates.

◆ SetLocation() [1/2]

void XPMP2::Aircraft::SetLocation ( double  lat,
double  lon,
double  alt_ft 
)

Legacy version of above version of SetLocatiion(), here without setting ground flag.

◆ SetLocation() [2/2]

void XPMP2::Aircraft::SetLocation ( double  lat,
double  lon,
double  alt_ft,
bool  on_grnd,
float  setTouchDownTime = NAN 
)
inline

Converts world coordinates to local coordinates, writes to Aircraft::drawInfo.

Note
Alternatively, the calling plugin can set local coordinates in Aircraft::drawInfo directly
Parameters
latLatitude in degress -90..90
lonLongitude in degrees -180..180
alt_ftAltitude in feet above MSL
on_grndIs the aircraft on the ground?
setTouchDownTime[opt] If not NAN activates SetTouchDown(), and automatically resets it after the given time in seconds

◆ SetMass()

void XPMP2::Aircraft::SetMass ( float  _kg)
inline

Mass [kg].

◆ SetNoseGearDeflection()

void XPMP2::Aircraft::SetNoseGearDeflection ( float  _mtr)
inline

Vertical nose gear deflection [meter].

◆ SetNoseWheelAngle()

void XPMP2::Aircraft::SetNoseWheelAngle ( float  _f)
inline

Nose Wheel angle in degrees.

◆ SetOnGrnd()

void XPMP2::Aircraft::SetOnGrnd ( bool  on_grnd,
float  setTouchDownTime = NAN 
)

Set if the aircraft is on the ground.

Parameters
on_grndIs the aircraft on the ground?
setTouchDownTime[opt] If not NAN activates SetTouchDown(), and automatically resets it after the given time in seconds

◆ SetPitch()

void XPMP2::Aircraft::SetPitch ( float  _deg)
inline

pitch [degree]

◆ SetPropRotAngle()

void XPMP2::Aircraft::SetPropRotAngle ( float  _deg)
inline

Propellor rotation angle [degree].

◆ SetPropRotRad()

void XPMP2::Aircraft::SetPropRotRad ( float  _rad)
inline

< Propellor rotation speed [rad/s], also sets [rpm]

◆ SetPropRotRpm()

void XPMP2::Aircraft::SetPropRotRpm ( float  _rpm)
inline

< Propellor rotation speed [rpm], also sets [rad/s]

◆ SetRender()

void XPMP2::Aircraft::SetRender ( bool  _bRender)
virtual

Switch rendering of the CSL model on or off.

◆ SetReversDeployRatio()

void XPMP2::Aircraft::SetReversDeployRatio ( float  _f)
inline

Thrust reversers deploy ratio.

◆ SetRoll()

void XPMP2::Aircraft::SetRoll ( float  _deg)
inline

roll [degree]

◆ SetSlatRatio()

void XPMP2::Aircraft::SetSlatRatio ( float  _f)
inline

Slats deploy ratio.

◆ SetSpeedbrakeRatio()

void XPMP2::Aircraft::SetSpeedbrakeRatio ( float  _f)
inline

Speedbrakes deploy ratio.

◆ SetSpoilerRatio()

void XPMP2::Aircraft::SetSpoilerRatio ( float  _f)
inline

Spoilers deploy ratio.

◆ SetTcasTargetIdx()

virtual void XPMP2::Aircraft::SetTcasTargetIdx ( int  _idx)
inlineprotectedvirtual

Define the TCAS target index in use.

◆ SetThrustRatio()

void XPMP2::Aircraft::SetThrustRatio ( float  _f)
inline

Thrust ratio.

◆ SetThrustReversRatio()

void XPMP2::Aircraft::SetThrustReversRatio ( float  _f)
inline

Thrust reversers ratio.

◆ SetTireDeflection()

void XPMP2::Aircraft::SetTireDeflection ( float  _mtr)
inline

Vertical (main) gear deflection [meter].

◆ SetTireRotAngle()

void XPMP2::Aircraft::SetTireRotAngle ( float  _deg)
inline

Tire rotation angle [degree].

◆ SetTireRotRad()

void XPMP2::Aircraft::SetTireRotRad ( float  _rad)
inline

< Tire rotation speed [rad/s], also sets [rpm]

◆ SetTireRotRpm()

void XPMP2::Aircraft::SetTireRotRpm ( float  _rpm)
inline

< Tire rotation speed [rpm], also sets [rad/s]

◆ SetTouchDown()

void XPMP2::Aircraft::SetTouchDown ( bool  _b)
inline

Moment of touch down.

◆ SetVisible()

void XPMP2::Aircraft::SetVisible ( bool  _bVisible)
virtual

Make the plane (in)visible.

◆ SetWingArea()

void XPMP2::Aircraft::SetWingArea ( float  _m2)
inline

Wing area [m²].

◆ SetWingSpan()

void XPMP2::Aircraft::SetWingSpan ( float  _m)
inline

Wing span [m].

◆ SetWingSweepRatio()

void XPMP2::Aircraft::SetWingSweepRatio ( float  _f)
inline

Wing sweep ratio.

◆ SetYokeHeadingRatio()

void XPMP2::Aircraft::SetYokeHeadingRatio ( float  _f)
inline

Yoke heading ratio.

◆ SetYokePitchRatio()

void XPMP2::Aircraft::SetYokePitchRatio ( float  _f)
inline

Yoke pitch ratio.

◆ SetYokeRollRatio()

void XPMP2::Aircraft::SetYokeRollRatio ( float  _f)
inline

Yoke roll ratio.

◆ ShallDrawLabel()

bool XPMP2::Aircraft::ShallDrawLabel ( ) const
inline

Shall this aircraft's label be drawn?

◆ ShowAsAIPlane()

bool XPMP2::Aircraft::ShowAsAIPlane ( ) const
inline

Is this plane to be drawn on TCAS? (It will if transponder is not switched off)

◆ SoundGetName()

std::string XPMP2::Aircraft::SoundGetName ( SoundEventsTy  sndEvent,
float &  volAdj 
) const
virtual

Returns the name of the sound to play per event.

This standard implementation determines the engine sound via aircraft classification and returns constant names for the other sound types.

Note
Override in derived class if you want to assign (some) sounds yourself
Parameters
sndEventThe type of sound event, like engine or gear
[out]volAdjVolume adjustment factor, allows to make sound louder (>1.0) or quiter, defaults to 1.0
Returns
Name of the sound to play, empty string if no sound shall play

◆ SoundIsMuted()

bool XPMP2::Aircraft::SoundIsMuted ( ) const
inline

Are all sounds currently muted?

◆ SoundMuteAll()

void XPMP2::Aircraft::SoundMuteAll ( bool  bMute)

Mute/Unmute all sounds of the airplane temporarily.

◆ SoundPlay()

uint64_t XPMP2::Aircraft::SoundPlay ( const std::string &  sndName,
float  vol = 1.0f 
)

Play a sound; a looping sound plays until explicitely stopped.

Parameters
sndNameOne of the sounds available or registered with XPMP2, see XPMPSoundAdd() and XPMPSoundEnumerate()
vol[opt] Volume level. 0 = silent, 1 = full. Negative level inverts the signal. Values larger than 1 amplify the signal.
Returns
an internal id for the sound channel, or 0 if unsuccessful

◆ SoundRemoveAll()

void XPMP2::Aircraft::SoundRemoveAll ( )
protectedvirtual

Remove all sound, e.g. during destruction.

◆ SoundSetup()

void XPMP2::Aircraft::SoundSetup ( )
protectedvirtual

Sound-related initializations, called by Create() and ChangeModel()

◆ SoundStop()

void XPMP2::Aircraft::SoundStop ( uint64_t  chnId)

Stop a continuously playing sound.

Parameters
chnIdThe channel's id returned by SoundPlay()

◆ SoundUpdate()

void XPMP2::Aircraft::SoundUpdate ( )
protectedvirtual

Update sound, like position and volume, called once per frame.

◆ SoundVolume()

void XPMP2::Aircraft::SoundVolume ( uint64_t  chnId,
float  vol 
)

Sets the sound's volume (after applying master volume and Sound File's adjustments)

Parameters
chnIdThe channel's id returned by SoundPlay()
volVolume level. 0 = silent, 1 = full. Negative level inverts the signal. Values larger than 1 amplify the signal.

◆ UpdateDistBearingCamera()

void XPMP2::Aircraft::UpdateDistBearingCamera ( const XPLMCameraPosition_t &  posCam)
protected

Internal: Update the plane's distance/bearing from the camera location.

◆ UpdatePosition()

virtual void XPMP2::Aircraft::UpdatePosition ( float  _elapsedSinceLastCall,
int  _flCounter 
)
pure virtual

Called right before updating the aircraft's placement in the world.

Abstract virtual function. Override in derived classes and fill drawInfo, the v array of dataRefs by calling the Setters, label, and infoTexts with current values.

See also
See XPLMFlightLoop_f for background on the two passed-on parameters:
Parameters
_elapsedSinceLastCallThe wall time since last call
_flCounterA monotonically increasing counter, bumped once per flight loop dispatch from the sim.

Implemented in XPCAircraft.

◆ WakeApplyDefaults()

void XPMP2::Aircraft::WakeApplyDefaults ( bool  _bOverwriteAllFields = true)

Fill in default wake turbulence support data based on Doc8643 wake turbulence category.

Parameters
_bOverwriteAllFieldsIf false only overwrites NAN values in wakeTy

Friends And Related Function Documentation

◆ AIMultiUpdate

void AIMultiUpdate ( )
friend

Updates all TCAS target dataRefs, both standard X-Plane, as well as additional shared dataRefs for text publishing.

◆ AIUpdateMultiplayerDataRefs

size_t AIUpdateMultiplayerDataRefs ( )
friend

The old way: Update Multiplayer dataRefs directly.

Returns
Number of TCAS targets produced

◆ AIUpdateTCASTargets

size_t AIUpdateTCASTargets ( )
friend

The modern way: Use TCAS override and update TCAS targets.

Returns
Number of TCAS targets produced (incl. user's plane)

Member Data Documentation

◆ acIcaoAirline

std::string XPMP2::Aircraft::acIcaoAirline

ICAO Airline code of this plane.

◆ acIcaoType

std::string XPMP2::Aircraft::acIcaoType

ICAO aircraft type designator of this plane.

See also
https://www.icao.int/publications/DOC8643/Pages/Search.aspx

◆ acInfoTexts

XPMPInfoTexts_t XPMP2::Aircraft::acInfoTexts

Informational texts passed on via multiplayer shared dataRefs.

◆ acLivery

std::string XPMP2::Aircraft::acLivery

Livery code of this plane.

◆ acRadar

XPMPPlaneRadar_t XPMP2::Aircraft::acRadar

Current radar status.

Note
Only the condition mode != Standby is of interest to XPMP2 for considering the aircraft for TCAS display

◆ acRelGrp

int XPMP2::Aircraft::acRelGrp = 0
protected

related group, ie. line in related.txt in which this a/c appears, if any

◆ aiPrio

int XPMP2::Aircraft::aiPrio = 1

Priority for display in one of the limited number of TCAS target slots.

The lower the earlier will a plane be considered for TCAS. Increase this value if you want to make a plane less likely to occupy one of the limited TCAS slots.

◆ alt1s_ft

double XPMP2::Aircraft::alt1s_ft = NAN
protected

◆ aSndCh

SndChTy XPMP2::Aircraft::aSndCh[SND_NUM_EVENTS]
protected

Operational values per sound channel, that is triggered by a standard sound event.

◆ bChnMuted

bool XPMP2::Aircraft::bChnMuted = false
protected

Is sound for this aircraft currently muted?

◆ bClampToGround

bool XPMP2::Aircraft::bClampToGround = false

Shall this plane be clamped to ground (ie. never sink below ground)?

Note
This involves Y-Testing, which is a bit expensive, see SDK. If you know your plane is not close to the ground, you may want to avoid clamping by setting this to false.
See also
configuration item XPMP2_CFG_ITM_CLAMPALL

◆ bDrawLabel

bool XPMP2::Aircraft::bDrawLabel = true

Shall this aircraft's label be drawn?

◆ bOnGrnd

bool XPMP2::Aircraft::bOnGrnd = false

Is the aircraft on the ground?

◆ bRender

bool XPMP2::Aircraft::bRender = true
protected

Shall the CSL model be drawn in 3D world? (if !bRender && bVivile then still visible on TCAS/interfaces, Remote Client uses this for local senders' planes to take over TCAS but not drawing)

◆ bValid

bool XPMP2::Aircraft::bValid = true
protected

is this object valid? (Will be reset in case of exceptions)

◆ bVisible

bool XPMP2::Aircraft::bVisible = true
protected

Shall this plane be drawn at the moment and be visible to TCAS/interfaces?

◆ camBearing

float XPMP2::Aircraft::camBearing = 0.0f
protected

Bearing from camera in degrees (updated internally regularly)

◆ camDist

float XPMP2::Aircraft::camDist = 0.0f
protected

Distance to camera in meters (updated internally regularly)

◆ camTimLstUpd

float XPMP2::Aircraft::camTimLstUpd = 0.0f
protected

Timestamp of last update of camera dist/bearing.

◆ chnList

ChnListTy XPMP2::Aircraft::chnList
protected

List of channels produced via calls to SoundPlay()

◆ colLabel

float XPMP2::Aircraft::colLabel[4] = {1.0f,1.0f,0.0f,1.0f}

label base color (RGB)

◆ contrailDist_m

unsigned XPMP2::Aircraft::contrailDist_m = 5

distance between several contrails and to the aircraft's centerline, in meter

◆ contrailLifeTime

unsigned XPMP2::Aircraft::contrailLifeTime = 25

this aircraft's contrail's life time

◆ contrailNum

unsigned XPMP2::Aircraft::contrailNum = 0

number of contrails requested

◆ drawInfo

XPLMDrawInfo_t XPMP2::Aircraft::drawInfo

Holds position (in local coordinates!) and orientation (pitch, heading roll) of the aircraft.

This is where the plane will be placed in this drawing cycle.

Note
When filling y directly (instead of using SetLocation()) remember to add GetVertOfs() for accurate placement on the ground

◆ gearDeflectRatio

float XPMP2::Aircraft::gearDeflectRatio = 0.5f

By how much of the gear deflection shall the plane's altitude be reduced?

This is to keep the wheels on the ground when gear deflection is applied. Unfortunately, the exact factor is model-dependend. 0.5 seems an OK compromise.
If you know better, then overwrite.
If you don't want XPMP2 to correct for gear deflection, set 0.0.

◆ gs_kn

float XPMP2::Aircraft::gs_kn = 0.0f
protected

◆ hProbe

XPLMProbeRef XPMP2::Aircraft::hProbe = nullptr
protected

Y Probe for terrain testing, needed in ground clamping.

◆ label

std::string XPMP2::Aircraft::label

aircraft label shown in the 3D world next to the plane

◆ lat1s

double XPMP2::Aircraft::lat1s = NAN
protected

ground speed in [kn] based on above v_x/z

Reverse-engineered lat/lon/alt, updated only once per second

◆ listContrail

std::list<XPLMInstanceRef> XPMP2::Aircraft::listContrail

Contrail: list of objects for contrail generation.

◆ listInst

std::list<XPLMInstanceRef> XPMP2::Aircraft::listInst
protected

X-Plane instance handles for all objects making up the model.

◆ lon1s

double XPMP2::Aircraft::lon1s = NAN
protected

◆ mapIconCol

int XPMP2::Aircraft::mapIconCol = 0
protected

map icon coordinates, column

◆ mapIconRow

int XPMP2::Aircraft::mapIconRow = 0
protected

map icon coordinates, row

◆ mapLabel

std::string XPMP2::Aircraft::mapLabel
protected

label for map drawing

◆ mapX

float XPMP2::Aircraft::mapX = 0.0f
protected

temporary: map coordinates (NAN = not to be drawn)

◆ mapY

float XPMP2::Aircraft::mapY = 0.0f
protected

temporary: map coordinates (NAN = not to be drawn)

◆ matchQuality

int XPMP2::Aircraft::matchQuality = -1
protected

quality of the match with the CSL model

◆ modeS_id

XPMPPlaneID XPMP2::Aircraft::modeS_id = 0
protected

A plane is uniquely identified by a 24bit number [0x01..0xFFFFFF].

This number is directly used as modeS_id n the new TCAS override approach.

◆ pCSLMdl

XPMP2::CSLModel* XPMP2::Aircraft::pCSLMdl = nullptr
protected

the CSL model in use

◆ prev_ts

float XPMP2::Aircraft::prev_ts = 0.0f
protected

last update of prev_x/y/z in XP's network time

◆ prev_x

float XPMP2::Aircraft::prev_x = 0.0f
protected

◆ prev_y

float XPMP2::Aircraft::prev_y = 0.0f
protected

◆ prev_z

float XPMP2::Aircraft::prev_z = 0.0f
protected

◆ skipCounter

int XPMP2::Aircraft::skipCounter = 0
protected

Counts how often we skipped expensive computations.

◆ sndMinDist

int XPMP2::Aircraft::sndMinDist = 50

Minimum distance in [m] to play sound in full volume, the larger the 'louder' the aircraft.

Initialized based on engine type and numbers, overwrite in your constructor if you want to control "size" of aircraft in terms of its sound volume

◆ tcasTargetIdx

int XPMP2::Aircraft::tcasTargetIdx = -1
protected

Which sim/cockpit2/tcas/targets-index does this plane occupy? [1..63], -1 if none.

◆ tsResetTouchDown

float XPMP2::Aircraft::tsResetTouchDown = NAN
protected

Set by SetOnGrnd() with the timestamp when to reset SetTouchDown()

◆ v

std::vector<float> XPMP2::Aircraft::v

actual dataRef values to be provided to the CSL model

XPMP2 provides a minimum set of dataRefs and also getter/setter member functions, see below. This is the one place where current dataRef values are stored. This array is passed on directly to the XP instance.
The size of the vector can increase if adding user-defined dataRefs through XPMPAddModelDataRef().

◆ v_x

float XPMP2::Aircraft::v_x = 0.0f

Cartesian velocity in m/s per axis, updated at least once per second.

◆ v_y

float XPMP2::Aircraft::v_y = 0.0f

◆ v_z

float XPMP2::Aircraft::v_z = 0.0f

◆ vertOfsRatio

float XPMP2::Aircraft::vertOfsRatio = 1.0f

How much of the vertical offset shall be applied? (This allows phasing out the vertical offset in higher altitudes.) [0..1].

◆ wake

struct XPMP2::Aircraft::wakeTy XPMP2::Aircraft::wake

wake-support data


The documentation for this class was generated from the following files: