XPMP2
X-Plane multiplayer library 2 - using instancing
Public Member Functions | Protected Attributes | List of all members
XPMP2::LegacyAircraft Class Reference

This class helps creating aircraft via the legacy global functions. It provides standard implementations of the abstract callbacks. More...

#include <Aircraft.h>

+ Inheritance diagram for XPMP2::LegacyAircraft:

Public Member Functions

 LegacyAircraft (const char *inICAOCode, const char *inAirline, const char *inLivery, XPMPPlaneData_f inDataFunc, void *inRefcon, XPMPPlaneID inModeS_id=0, const char *inModelName=nullptr)
 Constructor accepts the very same parameters as XPMPCreatePlane() and XPMPCreatePlaneWithModelName() More...
 
virtual XPMPPlaneCallbackResult GetPlanePosition (XPMPPlanePosition_t *outPosition)
 Just calls dataFunc More...
 
virtual XPMPPlaneCallbackResult GetPlaneSurfaces (XPMPPlaneSurfaces_t *outSurfaces)
 Just calls dataFunc More...
 
virtual XPMPPlaneCallbackResult GetPlaneRadar (XPMPPlaneRadar_t *outRadar)
 Just calls dataFunc More...
 
virtual XPMPPlaneCallbackResult GetInfoTexts (XPMPInfoTexts_t *outInfoTexts)
 Just calls dataFunc More...
 
- Public Member Functions inherited from XPCAircraft
 XPCAircraft (const char *_icaoType, const char *_icaoAirline, const char *_livery, XPMPPlaneID _modeS_id=0, const char *_modelId=nullptr)
 Legacy constructor creates a plane and puts it under control of XPlaneMP. More...
 
virtual void UpdatePosition (float _elapsedSinceLastCall, int _flCounter)
 Just calls all 4 previous Get... functions and copies the provided values into drawInfo and v More...
 
- Public Member Functions inherited from 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. 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 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...
 
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...
 
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...
 
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...
 
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...
 
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 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...
 
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...
 
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...
 
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...
 

Protected Attributes

XPMPPlaneData_f dataFunc = nullptr
 Points to the callback function provided by caller to XPMPCreatePlane() More...
 
void * refcon = nullptr
 The refcon provided by caller to XPMPCreatePlane() More...
 
- Protected Attributes inherited from XPMP2::Aircraft
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...
 

Additional Inherited Members

- Public Types inherited from XPMP2::Aircraft
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 Attributes inherited from XPCAircraft
XPMPPlanePosition_t acPos
 Last position data. GetPlanePosition() passes a pointer to this member variable. More...
 
XPMPPlaneSurfaces_t acSurfaces
 Last surface data. GetPlaneSurfaces() passes a pointer to this member variable. More...
 
- Public Attributes inherited from XPMP2::Aircraft
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 inherited from XPMP2::Aircraft
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...
 
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 inherited from XPMP2::Aircraft
static float FlightLoopCB (float, float, int, void *)
 Internal: Flight loop callback function controlling update and movement of all planes. More...
 

Detailed Description

This class helps creating aircraft via the legacy global functions. It provides standard implementations of the abstract callbacks.

Constructor & Destructor Documentation

◆ LegacyAircraft()

XPMP2::LegacyAircraft::LegacyAircraft ( const char *  inICAOCode,
const char *  inAirline,
const char *  inLivery,
XPMPPlaneData_f  inDataFunc,
void *  inRefcon,
XPMPPlaneID  inModeS_id = 0,
const char *  inModelName = nullptr 
)

Constructor accepts the very same parameters as XPMPCreatePlane() and XPMPCreatePlaneWithModelName()

Member Function Documentation

◆ GetInfoTexts()

XPMPPlaneCallbackResult XPMP2::LegacyAircraft::GetInfoTexts ( XPMPInfoTexts_t outInfoTexts)
virtual

Just calls dataFunc

Reimplemented from XPCAircraft.

◆ GetPlanePosition()

XPMPPlaneCallbackResult XPMP2::LegacyAircraft::GetPlanePosition ( XPMPPlanePosition_t outPosition)
virtual

Just calls dataFunc

Implements XPCAircraft.

◆ GetPlaneRadar()

XPMPPlaneCallbackResult XPMP2::LegacyAircraft::GetPlaneRadar ( XPMPPlaneRadar_t outRadar)
virtual

Just calls dataFunc

Implements XPCAircraft.

◆ GetPlaneSurfaces()

XPMPPlaneCallbackResult XPMP2::LegacyAircraft::GetPlaneSurfaces ( XPMPPlaneSurfaces_t outSurfaces)
virtual

Just calls dataFunc

Implements XPCAircraft.

Member Data Documentation

◆ dataFunc

XPMPPlaneData_f XPMP2::LegacyAircraft::dataFunc = nullptr
protected

Points to the callback function provided by caller to XPMPCreatePlane()

◆ refcon

void* XPMP2::LegacyAircraft::refcon = nullptr
protected

The refcon provided by caller to XPMPCreatePlane()


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