XPMP2
X-Plane multiplayer library 2 - using instancing
|
Actual representation of all aircraft in XPMP2. More...
#include <XPMPAircraft.h>
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... | |
Aircraft & | operator= (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::CSLModel * | GetModel () 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 | |
| |
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 | |
| |
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 | |
| |
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) | |
| |
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::CSLModel * | pCSLMdl = 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... | |
Actual representation of all aircraft in XPMP2.
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() |
typedef std::list<uint64_t> XPMP2::Aircraft::ChnListTy |
List of sound channel ids, also beyond sounds created for 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 |
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.
XPMP2::XPMP2Error | Mode S id invalid or duplicate, no model found during model matching |
_icaoType | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
_icaoAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
_livery | Special 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) |
XPMP2::Aircraft::Aircraft | ( | ) |
Default constructor creates an empty, invalid(!) and invisible shell; call XPMP2::Aircraft::Create() to actually create a plane.
|
virtual |
Destructor cleans up all resources acquired.
|
delete |
Aircraft must not be copied as they reference non-copyable resources like XP instances.
bool XPMP2::Aircraft::AssignModel | ( | const std::string & | _cslId, |
CSLModel * | _pCSLModel = nullptr |
||
) |
Assigns the given model.
_cslId | Search for this id (package/short) |
_pCSLModel | (optional) If given use this model and don't search |
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
_icaoType | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
_icaoAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
_livery | Special livery designator, can be an empty string |
|
protected |
Clamp to ground: Make sure the plane is not below ground, corrects Aircraft::drawInfo if needed.
|
protectedvirtual |
Put together the map label.
Called about once a second. Label depends on tcasTargetIdx
|
protected |
Internal: (Re)Assess if contrails are to be created.
|
protected |
Internal: Create/move contrails, implemented in Contrail.cpp.
void XPMP2::Aircraft::ContrailRemove | ( | ) |
Remove all contrail objects.
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
num | Number of contrails. Keep performance impact in mind, 1 might be sufficient. Passing 0 will cause the contrails to be removed. |
dist_m | If 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 |
lifeTime | is 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 |
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().
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.
Tried | on already defined object; XPMP2::XPMP2Error Mode S id invalid or duplicate, no model found during model matching |
_icaoType | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
_icaoAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
_livery | Special 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) |
|
protected |
Create the instances required to represent the plane, return if successful.
|
protected |
Destroy all instances.
|
protected |
Internal: Processes once every second only stuff that doesn't require being computed every flight loop.
|
protected |
Internal: This puts the instance into XP's sky and makes it move.
|
staticprotected |
Internal: Flight loop callback function controlling update and movement of all planes.
|
inlinevirtual |
Angle of Attach, returns pitch (but you can override in your class)
|
inline |
Bearing from camera [°].
|
inline |
Distance to camera [m].
|
inline |
Engine rotation angle [degree].
|
inline |
< Engine rotation angle [degree] for engine idx
(1..4)
|
inline |
Engine rotation speed [rad/s].
|
inline |
< Engine rotation speed [rad/s] for engine idx
(1..4)
|
inline |
Engine rotation speed [rpm].
|
inline |
< Engine rotation speed [rpm] for engine idx
(1..4)
|
inline |
Flaps deploy ratio.
|
virtual |
Return a value for dataRef .../tcas/target/flight_id.
|
inline |
Gear deploy ratio.
|
inline |
Rough estimate of a ground speed based on v_x/z
|
inline |
heading [degree]
|
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.
|
inline |
Beacon lights.
|
inline |
Landing lights.
|
inline |
Navigation lights.
|
inline |
Strobe lights.
|
inline |
Taxi lights.
|
inline |
Gets all location info (including local coordinates)
void XPMP2::Aircraft::GetLocation | ( | double & | lat, |
double & | lon, | ||
double & | alt_ft | ||
) | const |
Converts aircraft's local coordinates to lat/lon values.
|
inline |
Mass [kg].
|
inline |
quality of the match with the CSL model
|
inline |
return a pointer to the CSL model in use (Note: The CSLModel structure is not public.)
|
inline |
return an information structure for the CSL model associated with the aircraft
const std::string & XPMP2::Aircraft::GetModelName | ( | ) | const |
return the name of the CSL model in use
|
inline |
return the XPMP2 plane id
|
inline |
Vertical nose gear deflection [meter].
|
inline |
Nose Wheel angle in degrees.
|
inline |
pitch [degree]
|
inline |
Propellor rotation angle [degree].
|
inline |
Propellor rotation speed [rad/s].
|
inline |
Propellor rotation speed [rpm].
|
inline |
Thrust reversers deploy ratio.
|
inline |
roll [degree]
|
inline |
Slats deploy ratio.
|
inline |
Speedbrakes deploy ratio.
|
inline |
Spoilers deploy ratio.
|
inline |
return the current TCAS target index (into sim/cockpit2/tcas/targets
), 1-based, -1
if not used
|
inline |
Thrust ratio.
|
inline |
Thrust reversers ratio.
|
inline |
Vertical (main) gear deflection [meter].
|
inline |
Tire rotation angle [degree].
|
inline |
Tire rotation speed [rad/s].
|
inline |
Tire rotation speed [rpm].
|
inline |
Moment of touch down.
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.
VERT_OFFSET
, which pushes the plane up on the tarmac onto its gearint XPMP2::Aircraft::GetWakeCat | ( | ) | const |
Category between 0=light and 3=Super, derived from WTC.
|
inline |
Wing area [m²].
|
inline |
Wing span [m].
|
inline |
Wing sweep ratio.
|
inline |
Yoke heading ratio.
|
inline |
Yoke pitch ratio.
|
inline |
Yoke roll ratio.
bool XPMP2::Aircraft::IsCurrentlyShownAsAI | ( | ) | const |
Is this plane currently also being tracked by X-Plane's classic AI/multiplayer?
|
inline |
Is this plane currently also being tracked as a TCAS target, ie. will appear on TCAS?
|
inline |
Is this object a glider?
bool XPMP2::Aircraft::IsGroundVehicle | ( | ) | const |
Is this object a ground vehicle? (related to glob.carIcaoType
)
|
inline |
Are instances created for this aircraft?
|
inline |
Is the aircraft on the ground?
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)
_icaoType | ICAO aircraft type designator, to which *this is compared |
For example, IsRelatedTo("GLID")
returns if *this
is a glider
|
inline |
Is this plane to be rendered?
|
inline |
Is the a/c object valid?
|
inline |
Is the plane visible?
void XPMP2::Aircraft::MapDrawIcon | ( | XPLMMapLayerID | inLayer, |
float | acSize | ||
) |
Actually draw the map icon.
void XPMP2::Aircraft::MapDrawLabel | ( | XPLMMapLayerID | inLayer, |
float | yOfs | ||
) |
Actually draw the map label.
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
void XPMP2::Aircraft::MapPreparePos | ( | XPLMMapProjectionID | projection, |
const float | boundsLTRB[4] | ||
) |
Prepare map coordinates.
Aircraft must not be copied as they reference non-copyable resources like XP instances.
|
inline |
Finds a match again, using the existing parameters, eg. after more models have been loaded.
|
inline |
Reset TCAS target slot index to -1
|
inline |
Define if this aircraft's label is to be drawn (provided label drawing is enabled globally)
void XPMP2::Aircraft::SetEngineRotAngle | ( | float | _deg | ) |
Engine rotation angle [degree], also sets engines 1..4.
void XPMP2::Aircraft::SetEngineRotAngle | ( | size_t | idx, |
float | _deg | ||
) |
Engine rotation angle [degree] for engine idx
(1..4)
void XPMP2::Aircraft::SetEngineRotRad | ( | float | _rad | ) |
Engine rotation speed [rad/s], also sets [rpm] and engines 1..4.
void XPMP2::Aircraft::SetEngineRotRad | ( | size_t | idx, |
float | _rad | ||
) |
Engine rotation speed [rad/s] for engine idx
(1..4), also sets [rpm].
void XPMP2::Aircraft::SetEngineRotRpm | ( | float | _rpm | ) |
Engine rotation speed [rpm], also sets [rad/s] and engines 1..4.
void XPMP2::Aircraft::SetEngineRotRpm | ( | size_t | idx, |
float | _rpm | ||
) |
Engine rotation speed [rpm] for engine idx
(1..4), also sets [rad/s].
|
inline |
Flaps deploy ratio.
|
inline |
Gear deploy ratio.
|
inline |
heading [degree]
|
virtual |
Mark the plane invalid, e.g. after exceptions occured on the data.
|
inline |
Beacon lights.
|
inline |
Landing lights.
|
inline |
Navigation lights.
|
inline |
Strobe lights.
|
inline |
Taxi lights.
|
inline |
Sets location in local world coordinates.
void XPMP2::Aircraft::SetLocation | ( | double | lat, |
double | lon, | ||
double | alt_ft | ||
) |
Legacy version of above version of SetLocatiion(), here without setting ground flag.
|
inline |
Converts world coordinates to local coordinates, writes to Aircraft::drawInfo.
lat | Latitude in degress -90..90 |
lon | Longitude in degrees -180..180 |
alt_ft | Altitude in feet above MSL |
on_grnd | Is the aircraft on the ground? |
setTouchDownTime | [opt] If not NAN activates SetTouchDown(), and automatically resets it after the given time in seconds |
|
inline |
Mass [kg].
|
inline |
Vertical nose gear deflection [meter].
|
inline |
Nose Wheel angle in degrees.
void XPMP2::Aircraft::SetOnGrnd | ( | bool | on_grnd, |
float | setTouchDownTime = NAN |
||
) |
Set if the aircraft is on the ground.
on_grnd | Is the aircraft on the ground? |
setTouchDownTime | [opt] If not NAN activates SetTouchDown(), and automatically resets it after the given time in seconds |
|
inline |
pitch [degree]
|
inline |
Propellor rotation angle [degree].
|
inline |
< Propellor rotation speed [rad/s], also sets [rpm]
|
inline |
< Propellor rotation speed [rpm], also sets [rad/s]
|
virtual |
Switch rendering of the CSL model on or off.
|
inline |
Thrust reversers deploy ratio.
|
inline |
roll [degree]
|
inline |
Slats deploy ratio.
|
inline |
Speedbrakes deploy ratio.
|
inline |
Spoilers deploy ratio.
|
inlineprotectedvirtual |
Define the TCAS target index in use.
|
inline |
Thrust ratio.
|
inline |
Thrust reversers ratio.
|
inline |
Vertical (main) gear deflection [meter].
|
inline |
Tire rotation angle [degree].
|
inline |
< Tire rotation speed [rad/s], also sets [rpm]
|
inline |
< Tire rotation speed [rpm], also sets [rad/s]
|
inline |
Moment of touch down.
|
virtual |
Make the plane (in)visible.
|
inline |
Wing area [m²].
|
inline |
Wing span [m].
|
inline |
Wing sweep ratio.
|
inline |
Yoke heading ratio.
|
inline |
Yoke pitch ratio.
|
inline |
Yoke roll ratio.
|
inline |
Shall this aircraft's label be drawn?
|
inline |
Is this plane to be drawn on TCAS? (It will if transponder is not switched off)
|
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.
sndEvent | The type of sound event, like engine or gear | |
[out] | volAdj | Volume adjustment factor, allows to make sound louder (>1.0) or quiter, defaults to 1.0 |
|
inline |
Are all sounds currently muted?
void XPMP2::Aircraft::SoundMuteAll | ( | bool | bMute | ) |
Mute/Unmute all sounds of the airplane temporarily.
uint64_t XPMP2::Aircraft::SoundPlay | ( | const std::string & | sndName, |
float | vol = 1.0f |
||
) |
Play a sound; a looping sound plays until explicitely stopped.
sndName | One 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. |
0
if unsuccessful
|
protectedvirtual |
Remove all sound, e.g. during destruction.
|
protectedvirtual |
Sound-related initializations, called by Create() and ChangeModel()
void XPMP2::Aircraft::SoundStop | ( | uint64_t | chnId | ) |
Stop a continuously playing sound.
chnId | The channel's id returned by SoundPlay() |
|
protectedvirtual |
Update sound, like position and volume, called once per frame.
void XPMP2::Aircraft::SoundVolume | ( | uint64_t | chnId, |
float | vol | ||
) |
Sets the sound's volume (after applying master volume and Sound File's adjustments)
chnId | The channel's id returned by SoundPlay() |
vol | Volume level. 0 = silent, 1 = full. Negative level inverts the signal. Values larger than 1 amplify the signal. |
|
protected |
Internal: Update the plane's distance/bearing from the camera location.
|
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 Set
ters, label
, and infoTexts
with current values.
_elapsedSinceLastCall | The wall time since last call |
_flCounter | A monotonically increasing counter, bumped once per flight loop dispatch from the sim. |
Implemented in XPCAircraft.
void XPMP2::Aircraft::WakeApplyDefaults | ( | bool | _bOverwriteAllFields = true | ) |
|
friend |
Updates all TCAS target dataRefs, both standard X-Plane, as well as additional shared dataRefs for text publishing.
|
friend |
The old way: Update Multiplayer dataRefs directly.
|
friend |
The modern way: Use TCAS override and update TCAS targets.
std::string XPMP2::Aircraft::acIcaoAirline |
ICAO Airline code of this plane.
std::string XPMP2::Aircraft::acIcaoType |
ICAO aircraft type designator of this plane.
XPMPInfoTexts_t XPMP2::Aircraft::acInfoTexts |
Informational texts passed on via multiplayer shared dataRefs.
std::string XPMP2::Aircraft::acLivery |
Livery code of this plane.
XPMPPlaneRadar_t XPMP2::Aircraft::acRadar |
Current radar status.
mode != Standby
is of interest to XPMP2 for considering the aircraft for TCAS display
|
protected |
related group, ie. line in related.txt
in which this a/c appears, if any
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.
|
protected |
|
protected |
Operational values per sound channel, that is triggered by a standard sound event.
|
protected |
Is sound for this aircraft currently muted?
bool XPMP2::Aircraft::bClampToGround = false |
Shall this plane be clamped to ground (ie. never sink below ground)?
false
. XPMP2_CFG_ITM_CLAMPALL
bool XPMP2::Aircraft::bDrawLabel = true |
Shall this aircraft's label be drawn?
bool XPMP2::Aircraft::bOnGrnd = false |
Is the aircraft on the ground?
|
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)
|
protected |
is this object valid? (Will be reset in case of exceptions)
|
protected |
Shall this plane be drawn at the moment and be visible to TCAS/interfaces?
|
protected |
Bearing from camera in degrees (updated internally regularly)
|
protected |
Distance to camera in meters (updated internally regularly)
|
protected |
Timestamp of last update of camera dist/bearing.
|
protected |
List of channels produced via calls to SoundPlay()
float XPMP2::Aircraft::colLabel[4] = {1.0f,1.0f,0.0f,1.0f} |
label base color (RGB)
unsigned XPMP2::Aircraft::contrailDist_m = 5 |
distance between several contrails and to the aircraft's centerline, in meter
unsigned XPMP2::Aircraft::contrailLifeTime = 25 |
this aircraft's contrail's life time
unsigned XPMP2::Aircraft::contrailNum = 0 |
number of contrails requested
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.
y
directly (instead of using SetLocation()) remember to add GetVertOfs() for accurate placement on the ground 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
.
|
protected |
|
protected |
Y Probe for terrain testing, needed in ground clamping.
std::string XPMP2::Aircraft::label |
aircraft label shown in the 3D world next to the plane
|
protected |
ground speed in [kn] based on above v_x/z
Reverse-engineered lat/lon/alt, updated only once per second
std::list<XPLMInstanceRef> XPMP2::Aircraft::listContrail |
Contrail: list of objects for contrail generation.
|
protected |
X-Plane instance handles for all objects making up the model.
|
protected |
|
protected |
map icon coordinates, column
|
protected |
map icon coordinates, row
|
protected |
label for map drawing
|
protected |
temporary: map coordinates (NAN = not to be drawn)
|
protected |
temporary: map coordinates (NAN = not to be drawn)
|
protected |
quality of the match with the CSL model
|
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.
|
protected |
the CSL model in use
|
protected |
last update of prev_x/y/z
in XP's network time
|
protected |
|
protected |
|
protected |
|
protected |
Counts how often we skipped expensive computations.
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
|
protected |
Which sim/cockpit2/tcas/targets
-index does this plane occupy? [1..63], -1
if none.
|
protected |
Set by SetOnGrnd() with the timestamp when to reset SetTouchDown()
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().
float XPMP2::Aircraft::v_x = 0.0f |
Cartesian velocity in m/s per axis, updated at least once per second.
float XPMP2::Aircraft::v_y = 0.0f |
float XPMP2::Aircraft::v_z = 0.0f |
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].
struct XPMP2::Aircraft::wakeTy XPMP2::Aircraft::wake |
wake-support data