XPMP2
X-Plane multiplayer library 2 - using instancing
Public Member Functions | List of all members
SampleAircraft Class Reference

Subclassing XPMP2::Aircraft to create our own class. More...

+ Inheritance diagram for SampleAircraft:

Public Member Functions

 SampleAircraft (const std::string &_icaoType, const std::string &_icaoAirline, const std::string &_livery, XPMPPlaneID _modeS_id=0, const std::string &_cslId="")
 Constructor just passes on all parameters to library. More...
 
virtual void UpdatePosition (float, int)
 Custom implementation for the virtual function providing updates values. 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 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...
 
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...
 

Additional Inherited Members

- 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...
 
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 inherited from XPMP2::Aircraft
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 inherited from XPMP2::Aircraft
static float FlightLoopCB (float, float, int, void *)
 Internal: Flight loop callback function controlling update and movement of all planes. 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...
 
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...
 

Detailed Description

Subclassing XPMP2::Aircraft to create our own class.

Constructor & Destructor Documentation

◆ SampleAircraft()

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

Constructor just passes on all parameters to library.

Member Function Documentation

◆ UpdatePosition()

virtual void SampleAircraft::UpdatePosition ( float  ,
int   
)
inlinevirtual

Custom implementation for the virtual function providing updates values.

Implements XPMP2::Aircraft.


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