XPMP2
X-Plane multiplayer library 2 - using instancing
Public Member Functions | Public Attributes | Protected Member Functions | 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:

Public Member Functions

 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...
 
XPMPPlaneID GetModeS_ID () const
 return the XPMP2 plane id More...
 
bool IsGroundVehicle () const
 Is this object a ground vehicle? 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...
 
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...
 
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...
 
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...
 
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...
 
void SetLocation (double lat, double lon, double alt_ft)
 Converts world coordinates to local coordinates, writes to Aircraft::drawInfo. 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 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...
 
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...
 

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...
 
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...
 
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...
 
XPMPInfoTexts_t acInfoTexts
 Informational texts passed on via multiplayer shared dataRefs. More...
 

Protected Member Functions

void DoMove ()
 Internal: This puts the instance into XP's sky and makes it move. 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...
 

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...
 
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...
 

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.

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

◆ 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.

◆ 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.

◆ 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.

◆ GetHeading()

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

heading [degree]

◆ 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.

◆ 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.

◆ 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?

◆ IsGroundVehicle()

bool XPMP2::Aircraft::IsGroundVehicle ( ) const

Is this object a ground vehicle?

◆ IsInstanciated()

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

Are instances created for this aircraft?

◆ 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

◆ 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()

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

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

◆ 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.

◆ 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.

◆ 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.

◆ ShowAsAIPlane()

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

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

◆ 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 RemoteAC, SampleAircraft, and XPCAircraft.

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.

◆ 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

◆ 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.

◆ colLabel

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

label base color (RGB)

◆ 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.

◆ 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

◆ listInst

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

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

◆ 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

◆ tcasTargetIdx

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

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

◆ 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().

◆ 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].


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