XPMP2
X-Plane multiplayer library 2 - using instancing
|
Initialization and general control functions for XPMP2. More...
#include <string>
#include <cmath>
#include "XPLMDefs.h"
Go to the source code of this file.
Classes | |
struct | XPMPPlanePosition_t |
This data structure contains the basic position info for an aircraft. More... | |
union | xpmp_LightStatus |
Defines, which lights of the aircraft are on. More... | |
struct | XPMPPlaneSurfaces_t |
External physical configuration of the plane. More... | |
struct | XPMPPlaneRadar_t |
defines information about an aircraft visible to radar. More... | |
struct | XPMPInfoTexts_t |
Textual information of planes to be passed on via shared dataRefs to other plugins. More... | |
struct | xpmp_LightStatus.__unnamed2__ |
Namespaces | |
XPMP2 | |
Macros | |
Configuration Sections | |
Config section is defined for legacy reasons only | |
#define | XPMP_CFG_SEC_MODELS "models" |
Config section "models". More... | |
#define | XPMP_CFG_SEC_PLANES "planes" |
Config section "planes". More... | |
#define | XPMP_CFG_SEC_SOUND "sound" |
Config section "sound". More... | |
#define | XPMP_CFG_SEC_DEBUG "debug" |
Config section "debug". More... | |
Configuration Items | |
Configuration Items are unique in itself even without considering the configuration section | |
#define | XPMP_CFG_ITM_REPLDATAREFS "replace_datarefs" |
Config key: Replace dataRefs in OBJ8 files upon load, creating new OBJ8 files for XPMP2 (defaults to OFF!) More... | |
#define | XPMP_CFG_ITM_REPLTEXTURE "replace_texture" |
Config key: Replace textures in OBJ8 files upon load if needed (specified on the OBJ8 line in xsb_aircraft.txt), creating new OBJ8 files. More... | |
#define | XPMP_CFG_ITM_CLAMPALL "clamp_all_to_ground" |
Config key: Ensure no plane sinks below ground, no matter of XPMP2::Aircraft::bClampToGround. More... | |
#define | XPMP_CFG_ITM_HANDLE_DUP_ID "handle_dup_id" |
Config key: Boolean: If XPMP2::Aircraft::modeS_id already exists then assign a new unique one, overwrites XPMP2::Aircraft::modeS_id. More... | |
#define | XPMP_CFG_ITM_SUPPORT_REMOTE "support_remote" |
Config key: Support remote connections? <0 force off, 0 default: on if in a networked or multiplayer setup, >0 force on. More... | |
#define | XPMP_CFG_ITM_CONTR_MIN_ALT "contrail_min_alt" |
Config key: Minimum altitude in feet for automatic contrail generation. More... | |
#define | XPMP_CFG_ITM_CONTR_MAX_ALT "contrail_max_alt" |
Config key: Maximum altitude in feet for automatic contrail generation, set both min and max altitude to 0 to switch off automatic contrails. More... | |
#define | XPMP_CFG_ITM_CONTR_LIFE "contrail_life_time" |
Config key: Default maximum lifetime of contrail puffs in seconds, determines contrail length. More... | |
#define | XPMP_CFG_ITM_CONTR_MULTI "contrail_multiple" |
Config key: Boolean: Shall multiple contrails be auto-created (one per engine), or just one (to safe FPS)? More... | |
#define | XPMP_CFG_ITM_ACTIVATE_SOUND "activate_sound" |
Config key: Activate Sound upon initial startup? (No effect later) More... | |
#define | XPMP_CFG_ITM_FMOD_INSTANCE "force_fmod_instance" |
Config key: Never use XP's FMOD instance, always create our own. More... | |
#define | XPMP_CFG_ITM_MUTE_ON_PAUSE "mute_on_pause" |
Config key: Mute all sound temporarily while X-Plane is in a paused state? More... | |
#define | XPMP_CFG_ITM_LOGLEVEL "log_level" |
Config key: General level of logging into Log.txt (0 = Debug, 1 = Info, 2 = Warning, 3 = Error, 4 = Fatal) More... | |
#define | XPMP_CFG_ITM_MODELMATCHING "model_matching" |
Config key: Write information on model matching and sound selection into Log.txt More... | |
Sound Macros | |
#define | XP_SOUND_ELECTRIC "Electric" |
#define | XP_SOUND_HIBYPASSJET "HiBypassJet" |
#define | XP_SOUND_LOBYPASSJET "LoBypassJet" |
#define | XP_SOUND_TURBOPROP "Turboprop" |
#define | XP_SOUND_PROP_AIRPLANE "PropAirplane" |
#define | XP_SOUND_PROP_HELI "PropHeli" |
#define | XP_SOUND_REVERSE_THRUST "ReverseThrust" |
#define | XP_SOUND_ROLL_RUNWAY "RollRunway" |
#define | XP_SOUND_FLAP "Flap" |
#define | XP_SOUND_GEAR "Gear" |
Typedefs | |
typedef unsigned int | XPMPLightsPattern |
Light flash pattern (unused in XPMP2) More... | |
typedef unsigned | XPMPPlaneID |
Unique ID for an aircraft created by a plugin. More... | |
typedef int(* | XPMPIntPrefsFuncTy) (const char *_section, const char *_key, int _default) |
Definition for the type of configuration callback function. More... | |
typedef XPMPPlaneCallbackResult(* | XPMPPlaneData_f) (XPMPPlaneID inPlane, XPMPPlaneDataType inDataType, void *ioData, void *inRefcon) |
Callback function your plugin provides to return updated plane data. More... | |
typedef void(* | XPMPPlaneNotifier_f) (XPMPPlaneID inPlaneID, XPMPPlaneNotification inNotification, void *inRefcon) |
Type of the callback function you provide, called when one of the events defined in XPMPPlaneNotification happens. More... | |
typedef void(* | XPMPRenderPlanes_f) (int inIsBlend, void *inRef) |
The original libxplanemp allowed to override rendering; no longer supported. More... | |
Functions | |
Initialization | |
const char * | XPMPMultiplayerInitLegacyData (const char *inCSLFolder, const char *inPluginName, const char *resourceDir, XPMPIntPrefsFuncTy inIntPrefsFunc=nullptr, const char *inDefaultICAO=nullptr, const char *inPluginLogAcronym=nullptr) |
Deprecated legacy initialization of XPMP2. More... | |
const char * | XPMPMultiplayerInit (const char *inPluginName, const char *resourceDir, XPMPIntPrefsFuncTy inIntPrefsFunc=nullptr, const char *inDefaultICAO=nullptr, const char *inPluginLogAcronym=nullptr) |
Initializes the XPMP2 library. This shall be your first call to the library. More... | |
void | XPMPSetPluginName (const char *inPluginName, const char *inPluginLogAcronym=nullptr) |
Overrides the plugin's name to be used in Log output. More... | |
void | XPMPMultiplayerCleanup () |
Clean up the multiplayer library. More... | |
bool | XPMPContrailsAutoEnabled () |
Are automatic Contrails enabled? More... | |
bool | XPMPContrailsAvailable () |
Are Contrails available? More... | |
const char * | XPMPMultiplayerOBJ7SupportEnable (const char *inTexturePath) |
Used to set the light textures for old OBJ7 models. More... | |
Sound | |
bool | XPMPSoundEnable (bool bEnable=true) |
Enable/Disable Sound. More... | |
bool | XPMPSoundIsEnabled () |
Is Sound enabled? More... | |
void | XPMPSoundSetMasterVolume (float fVol=1.0f) |
Set Master Volume. More... | |
void | XPMPSoundMute (bool bMute) |
Mute all sounds (temporarily) More... | |
const char * | XPMPSoundAdd (const char *sName, const char *filePath, bool bLoop, float coneDir=NAN, float conePitch=NAN, float coneInAngle=NAN, float coneOutAngle=NAN, float coneOutVol=NAN) |
Add a sound that can later be referenced from an XPMP2::Aircraft. More... | |
const char * | XPMPSoundEnumerate (const char *prevName, const char **ppFilePath=nullptr) |
Enumerate all sounds, including the internal ones. More... | |
AI / Multiplayer plane control | |
const char * | XPMPMultiplayerEnable (void(*_callback)(void *)=nullptr, void *_refCon=nullptr) |
Tries to grab control of TCAS targets (formerly known as AI/multiplayer) from X-Plane. More... | |
void | XPMPMultiplayerDisable () |
Release TCAS targets control. More... | |
bool | XPMPHasControlOfAIAircraft () |
Has XPMP2 control of TCAS targets? More... | |
CSL Package Handling | |
const char * | XPMPLoadCSLPackage (const char *inCSLFolder) |
Loads CSL packages from the given folder, searching up to 5 folder levels deep. More... | |
void | XPMPLoadPlanesIfNecessary () |
Legacy function only provided for backwards compatibility. Does not actually do anything. More... | |
int | XPMPGetNumberOfInstalledModels () |
Returns the number of loaded CSL models. More... | |
void | XPMPGetModelInfo (int inIndex, const char **outModelName, const char **outIcao, const char **outAirline, const char **outLivery) |
Fetch information about a CSL model identified by an index. More... | |
void | XPMPGetModelInfo2 (int inIndex, std::string &outModelName, std::string &outIcao, std::string &outAirline, std::string &outLivery) |
Fetch information about a CSL model identified by an index. More... | |
int | XPMPModelMatchQuality (const char *inICAO, const char *inAirline, const char *inLivery) |
Tests model match quality based on the given parameters. More... | |
bool | XPMPIsICAOValid (const char *inICAO) |
Is inICAO a valid ICAO aircraft type designator? More... | |
size_t | XPMPAddModelDataRef (const std::string &dataRef) |
Add a user-defined dataRef to the list of dataRefs supported by every plane. More... | |
Plane Creation API | |
XPMPPlaneID | XPMPCreatePlane (const char *inICAOCode, const char *inAirline, const char *inLivery, XPMPPlaneData_f inDataFunc, void *inRefcon, XPMPPlaneID inModeS_id=0) |
Creates a new plane. More... | |
XPMPPlaneID | XPMPCreatePlaneWithModelName (const char *inModelName, const char *inICAOCode, const char *inAirline, const char *inLivery, XPMPPlaneData_f inDataFunc, void *inRefcon, XPMPPlaneID inModeS_id=0) |
Creates a new plane, providing a specific CSL model name. More... | |
void | XPMPDestroyPlane (XPMPPlaneID _id) |
[Deprecated] Removes a plane previously created with XPMPCreatePlane() More... | |
void | XPMPSetPlaneVisibility (XPMPPlaneID _id, bool _bVisible) |
Show/Hide the aircraft temporarily without destroying the object. More... | |
int | XPMPChangePlaneModel (XPMPPlaneID inPlaneID, const char *inICAOCode, const char *inAirline, const char *inLivery) |
Perform model matching again and change the CSL model to the resulting match. More... | |
int | XPMPGetPlaneModelName (XPMPPlaneID inPlaneID, char *outTxtBuf, int outTxtBufSize) |
Return the name of the model, with which the given plane is rendered. More... | |
void | XPMPGetPlaneICAOAndLivery (XPMPPlaneID inPlane, char *outICAOCode, char *outLivery) |
Returns ICAO aircraft type designator and livery of the given plane. More... | |
XPMPPlaneCallbackResult | XPMPGetPlaneData (XPMPPlaneID inPlane, XPMPPlaneDataType inDataType, void *outData) |
Unsupported, don't use. More... | |
int | XPMPGetPlaneModelQuality (XPMPPlaneID inPlane) |
Returns the match quality of the currently used model, or -1 if inPlane is invalid. More... | |
long | XPMPCountPlanes (void) |
Returns the number of planes in existence. More... | |
XPMPPlaneID | XPMPGetNthPlane (long index) |
Returns the plane ID of the Nth plane. More... | |
XPMP2::Aircraft * | XPMPGetAircraft (XPMPPlaneID _id) |
Returns the underlying aircraft object, or nullptr if _id is invalid. More... | |
void | XPMPSetDefaultPlaneICAO (const char *_acIcaoType, const char *_carIcaoType=nullptr) |
Define default aircraft and ground vehicle ICAO types. More... | |
Plane Observation API | |
void | XPMPRegisterPlaneNotifierFunc (XPMPPlaneNotifier_f inFunc, void *inRefcon) |
Registers a callback, which is called when one of the events defined in XPMPPlaneNotification happens. More... | |
void | XPMPUnregisterPlaneNotifierFunc (XPMPPlaneNotifier_f inFunc, void *inRefcon) |
Unregisters a notification callback. Both function pointer and refcon must match what was registered. More... | |
Plane Rendering API | |
void | XPMPSetPlaneRenderer (XPMPRenderPlanes_f inRenderer, void *inRef) |
The original libxplanemp allowed to override rendering; no longer supported. More... | |
void | XPMPDumpOneCycle (void) |
Legacy debug-support function, no longer supported. More... | |
void | XPMPEnableAircraftLabels (bool _enable=true) |
Enable or disable drawing of labels with the aircraft. More... | |
void | XPMPDisableAircraftLabels () |
Disable drawing of labels with the aircraft. More... | |
bool | XPMPDrawingAircraftLabels () |
Returns if labels are currently configured to be drawn. More... | |
void | XPMPSetAircraftLabelDist (float _dist_nm, bool _bCutOffAtVisibility=true) |
void | XPMPEnableMap (bool _bEnable, bool _bLabels=true) |
Enable or disable the drawing of aircraft icons on X-Plane's map. More... | |
Variables | |
constexpr XPMPPlaneID | MIN_MODE_S_ID = 0x00000001 |
Minimum allowed XPMPPlaneID / mode S id. More... | |
constexpr XPMPPlaneID | MAX_MODE_S_ID = 0x00FFFFFF |
Maximum allowed XPMPPlaneID / mode S id. More... | |
Initialization and general control functions for XPMP2.
This is one of two main header files for using XPMP2. (The other is XPMPAircraft.h
). XPMP2 is a library allowing an X-Plane plugin to have planes rendered in X-Plane's 3D world based on OBJ8 CSL models, which need to be installed separately. The plugin shall subclass XPMP2::Aircraft and override the abstract virtual function XPMP2::Aircraft::UpdatePosition() to provide updated position and attitude information. XPMP2 takes care of reading and initializaing CSL models, instanciating and updating the aircraft objects in X-Plane, display in a map layer, provisioning information via X-Plane's TCAS targets and AI/multiplayer (and more) dataRefs.
INCLUDE_FMOD_SOUND=1
then Audio Engine is FMOD Core API by Firelight Technologies Pty Ltd. Understand FMOD licensing and attribution requirements first!struct XPMPPlanePosition_t |
This data structure contains the basic position info for an aircraft.
XPMPPosition_t
Class Members | ||
---|---|---|
int | aiPrio | Priority for AI/TCAS consideration, the lower the earlier. |
bool | clampToGround | enables ground-clamping for this aircraft (can be expensive, see XPMP2::Aircraft::bClampToGround) |
double | elevation | current altitude of aircraft [ft above MSL] |
float | heading | heading [degrees] |
char | label[32] | label to show with the aircraft |
float | label_color[4] | label base color (RGB), defaults to yellow |
double | lat | current position of aircraft (latitude) |
double | lon | current position of aircraft (longitude) |
int | multiIdx |
OUT: set by XPMP2 to inform application about TCAS target index in use [1..63], with [1..19] also being available via classic multiplayer dataRefs, < 1 means 'none'. |
float | offsetScale | how much of the surface contact correction offset should be applied [0..1] |
float | pitch | pitch [degrees, psitive up] |
float | roll | roll [degrees, positive right] |
long | size | size of structure |
union xpmp_LightStatus |
Defines, which lights of the aircraft are on.
Class Members | ||
---|---|---|
struct xpmp_LightStatus | __unnamed__ | |
unsigned int | lightFlags | this defaults to taxi | beacon | nav lights on |
struct XPMPPlaneSurfaces_t |
External physical configuration of the plane.
This data structure will contain information about the external physical configuration of the plane, things you would notice if you are seeing it from outside. This includes flap position, gear position, etc.
Class Members | ||
---|---|---|
float | engRotDegree | engine rotation angle (degrees 0..360) |
float | engRotRpm | engine rotation speed (rpm) |
float | flapRatio | flap extension ratio [0..1] |
float | gearPosition | gear position [0..1] |
xpmp_LightStatus | lights | status of lights |
float | propRotDegree | prop rotation angle (degrees 0..360) |
float | propRotRpm | prop rotation speed (rpm) |
float | reversRatio | thrust reversers ratio |
long | size | structure size |
float | slatRatio | slats extension ratio [0..1] |
float | speedBrakeRatio | speed brake extension ratio [0..1] |
float | spoilerRatio | spoiler extension ratio [0..1] |
float | thrust | thrust ratio [0..1] |
float | tireDeflect | tire deflection (meters) |
float | tireRotDegree | tire rotation angle (degrees 0..360) |
float | tireRotRpm | tire rotation speed (rpm) |
bool | touchDown | just now is moment of touch down? |
float | wingSweep | wing sweep ratio [0..1] |
float | yokeHeading | yoke heading ratio [0..1] |
float | yokePitch | yoke pitch ratio [0..1] |
float | yokeRoll | yoke roll ratio [0..1] |
struct XPMPPlaneRadar_t |
defines information about an aircraft visible to radar.
Class Members | ||
---|---|---|
long | code |
current radar code, published via dataRef sim/cockpit2/tcas/targets/modeC_code |
XPMPTransponderMode | mode |
current radar mode, if not xpmpTransponderMode_Standby then is plane considered for TCAS display |
long | size | structure size |
struct XPMPInfoTexts_t |
Textual information of planes to be passed on via shared dataRefs to other plugins.
The texts are not used within XPMP2 in any way, just passed on to dataRefs
struct xpmp_LightStatus.__unnamed2__ |
Class Members | ||
---|---|---|
unsigned int | bcnLights: 1 | beacon on? |
XPMPLightsPattern | flashPattern: 4 | light pattern (unused in XPMP2) |
unsigned int | landLights: 1 | landing lights on? |
unsigned int | navLights: 1 | navigation lights on? |
unsigned int | strbLights: 1 | strobe lights on? |
unsigned int | taxiLights: 1 | taxi lights on? |
unsigned int | timeOffset: 16 | time offset to avoid lights across planes blink in sync (unused in XPMP2) |
#define XP_SOUND_ELECTRIC "Electric" |
#define XP_SOUND_FLAP "Flap" |
#define XP_SOUND_GEAR "Gear" |
#define XP_SOUND_HIBYPASSJET "HiBypassJet" |
#define XP_SOUND_LOBYPASSJET "LoBypassJet" |
#define XP_SOUND_PROP_AIRPLANE "PropAirplane" |
#define XP_SOUND_PROP_HELI "PropHeli" |
#define XP_SOUND_REVERSE_THRUST "ReverseThrust" |
#define XP_SOUND_ROLL_RUNWAY "RollRunway" |
#define XP_SOUND_TURBOPROP "Turboprop" |
#define XPMP_CFG_ITM_ACTIVATE_SOUND "activate_sound" |
Config key: Activate Sound upon initial startup? (No effect later)
#define XPMP_CFG_ITM_CLAMPALL "clamp_all_to_ground" |
Config key: Ensure no plane sinks below ground, no matter of XPMP2::Aircraft::bClampToGround.
#define XPMP_CFG_ITM_CONTR_LIFE "contrail_life_time" |
Config key: Default maximum lifetime of contrail puffs in seconds, determines contrail length.
#define XPMP_CFG_ITM_CONTR_MAX_ALT "contrail_max_alt" |
Config key: Maximum altitude in feet for automatic contrail generation, set both min and max altitude to 0
to switch off automatic contrails.
#define XPMP_CFG_ITM_CONTR_MIN_ALT "contrail_min_alt" |
Config key: Minimum altitude in feet for automatic contrail generation.
#define XPMP_CFG_ITM_CONTR_MULTI "contrail_multiple" |
Config key: Boolean: Shall multiple contrails be auto-created (one per engine), or just one (to safe FPS)?
#define XPMP_CFG_ITM_FMOD_INSTANCE "force_fmod_instance" |
Config key: Never use XP's FMOD instance, always create our own.
#define XPMP_CFG_ITM_HANDLE_DUP_ID "handle_dup_id" |
Config key: Boolean: If XPMP2::Aircraft::modeS_id already exists then assign a new unique one, overwrites XPMP2::Aircraft::modeS_id.
#define XPMP_CFG_ITM_LOGLEVEL "log_level" |
Config key: General level of logging into Log.txt
(0 = Debug, 1 = Info, 2 = Warning, 3 = Error, 4 = Fatal)
#define XPMP_CFG_ITM_MODELMATCHING "model_matching" |
Config key: Write information on model matching and sound selection into Log.txt
#define XPMP_CFG_ITM_MUTE_ON_PAUSE "mute_on_pause" |
Config key: Mute all sound temporarily while X-Plane is in a paused state?
#define XPMP_CFG_ITM_REPLDATAREFS "replace_datarefs" |
Config key: Replace dataRefs in OBJ8 files upon load, creating new OBJ8 files for XPMP2 (defaults to OFF!)
#define XPMP_CFG_ITM_REPLTEXTURE "replace_texture" |
Config key: Replace textures in OBJ8 files upon load if needed (specified on the OBJ8 line in xsb_aircraft.txt), creating new OBJ8 files.
#define XPMP_CFG_ITM_SUPPORT_REMOTE "support_remote" |
Config key: Support remote connections? <0
force off, 0
default: on if in a networked or multiplayer setup, >0
force on.
#define XPMP_CFG_SEC_DEBUG "debug" |
Config section "debug".
#define XPMP_CFG_SEC_MODELS "models" |
Config section "models".
#define XPMP_CFG_SEC_PLANES "planes" |
Config section "planes".
#define XPMP_CFG_SEC_SOUND "sound" |
Config section "sound".
typedef int(* XPMPIntPrefsFuncTy) (const char *_section, const char *_key, int _default) |
Definition for the type of configuration callback function.
The plugin using XPMP2 can provide such a callback function via XPMPMultiplayerInit(). It will be called max. every 2s to fetch each of the following configuration values:
section | key | type | default | description
------- | ------------------- | ---- | ------- | -------------------------------------------------------------------------
models | replace_datarefs | int | 0 | Replace dataRefs in OBJ8 files upon load, creating new OBJ8 files for XPMP2 (defaults to OFF!)
models | replace_texture | int | 1 | Replace textures in OBJ8 files upon load if needed (specified on the OBJ8 line in xsb_aircraft.txt), creating new OBJ8 files
planes | clamp_all_to_ground | int | 1 | Ensure no plane sinks below ground, no matter of XPMP2::Aircraft::bClampToGround
planes | handle_dup_id | int | 0 | Boolean: If XPMP2::Aircraft::modeS_id already exists then assign a new unique one, overwrites XPMP2::Aircraft::modeS_id
planes | support_remote | int | 0 | 3-state integer: Support remote connections? <0 force off, 0 default: on if in a networked or multiplayer setup, >0 force on
planes | contrail_min_alt | int | 25000 | Minimum altitude in feet for automatic contrail generation
planes | contrail_max_alt | int | 45000 | Maximum altitude in feet for automatic contrail generation, set both min and max altitude to 0 to switch off automatic contrails
planes | contrail_life_time | int | 25 | Default maximum lifetime of contrail puffs in seconds, determines contrail length
planes | contrail_multiple | int | 0 | Boolean: Shall multiple contrails be auto-created (one per engine), or just one (to safe FPS)?
sound | activate_sound | int | 1 | Activate Sound upon initial startup? (No effect later)
sound | force_fmod_instance | int | 0 | Never use XP's FMOD instance, always create our own
sound | mute_on_pause | int | 1 | Mute all sound temporarily while X-Plane is in a paused state?
debug | log_level | int | 2 | General level of logging into Log.txt (0 = Debug, 1 = Info, 2 = Warning, 3 = Error, 4 = Fatal)
debug | model_matching | int | 0 | Write information on model matching and sound selection into Log.txt
_section
in your implementation. _key
by itself is unique. Compare it with any of the XPMP_CFG_ITM_*
values and return your value. _section | Configuration section, ie. group of values, any of the XPMP_CFG_SEC_... values |
_key | Any of the XPMP_CFG_ITM_* values to indicate which config value is to be returned. |
_default | A default provided by XPMP2. Have your callback return _default if you don't want to explicitely set a value or don't know the _key . |
_key
typedef unsigned int XPMPLightsPattern |
Light flash pattern (unused in XPMP2)
typedef XPMPPlaneCallbackResult(* XPMPPlaneData_f) (XPMPPlaneID inPlane, XPMPPlaneDataType inDataType, void *ioData, void *inRefcon) |
Callback function your plugin provides to return updated plane data.
This functions is called by XPMP2 once per cycle per plane per data type. Your implementation returns the requested data, so that XPMP2 can move and update the associated aircraft instance.
inPlane | ID of the plane, for which data is requested | |
inDataType | The type of data that is requested, see XPMPPlaneDataType | |
[out] | ioData | A pointer to a structure XPMP2 provides, for you to fill the data into. For its type see XPMPPlaneDataType. |
inRefcon | The refcon value you provided when creating the plane |
typedef unsigned XPMPPlaneID |
Unique ID for an aircraft created by a plugin.
modeS_id
in the new TCAS override approach. typedef void(* XPMPPlaneNotifier_f) (XPMPPlaneID inPlaneID, XPMPPlaneNotification inNotification, void *inRefcon) |
Type of the callback function you provide, called when one of the events defined in XPMPPlaneNotification happens.
inPlaneID | Identifies the affected plane |
inNotification | The event that took place |
inRefcon | A refcon that you provided in XPMPRegisterPlaneNotifierFunc() |
typedef void(* XPMPRenderPlanes_f) (int inIsBlend, void *inRef) |
The original libxplanemp allowed to override rendering; no longer supported.
anonymous enum |
Light flash patterns.
Definfes the different responses to asking for information.
Enumerator | |
---|---|
xpmpData_Unavailable | |
xpmpData_Unchanged | |
xpmpData_NewData |
enum XPMPPlaneDataType |
This enum defines the different categories of aircraft information we can query about.
Enumerator | |
---|---|
xpmpDataType_Position | position data in XPMPPlanePosition_t |
xpmpDataType_Surfaces | physical appearance in XPMPPlaneSurfaces_t |
xpmpDataType_Radar | radar information in XPMPPlaneRadar_t |
xpmpDataType_InfoTexts | informational texts in XPMPInfoTexts_t |
enum XPMPTransponderMode |
These enumerations define the way the transponder of a given plane is operating.
"mode != xpmpTransponderMode_Standby"
, in which case the plane is considered for TCAS display. size_t XPMPAddModelDataRef | ( | const std::string & | dataRef | ) |
Add a user-defined dataRef to the list of dataRefs supported by every plane.
All planes created by XPMP2 define the same set of dataRefs. See XPMP2::DR_VALS for the definitions that come pre-defined with XPMP2. Here you can add more dataRefs that you want to set in your XPMP2::Aircraft::UpdatePosition() implementation.
0
when an error occured. 0
if called while planes exist. 0
if called from a worker thread. int XPMPChangePlaneModel | ( | XPMPPlaneID | inPlaneID, |
const char * | inICAOCode, | ||
const char * | inAirline, | ||
const char * | inLivery | ||
) |
Perform model matching again and change the CSL model to the resulting match.
inPlaneID | Which plane to change? |
inICAOCode | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
inAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
inLivery | Special livery designator, can be an empty string |
inPlaneID
is invalid bool XPMPContrailsAutoEnabled | ( | ) |
Are automatic Contrails enabled?
Configured in a consistent way to automatically show contrails? (Max Altitude > Min Altitude) If off, use XPMP2::Aircraft::ContrailTrigger() or XPMP2::Aircraft::ContrailRequest().
bool XPMPContrailsAvailable | ( | ) |
Are Contrails available?
Could return false
e.g. if Resources/Contrail/Contrail.obj
could not be found or loaded.
long XPMPCountPlanes | ( | void | ) |
Returns the number of planes in existence.
XPMPPlaneID XPMPCreatePlane | ( | const char * | inICAOCode, |
const char * | inAirline, | ||
const char * | inLivery, | ||
XPMPPlaneData_f | inDataFunc, | ||
void * | inRefcon, | ||
XPMPPlaneID | inModeS_id = 0 |
||
) |
Creates a new plane.
Effectively calls XPMPCreatePlaneWithModelName() with inModelName = nullptr
inICAOCode | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
inAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
inLivery | Special livery designator, can be an empty string |
inDataFunc | Callback function called by XPMP2 to fetch updated data |
inRefcon | A refcon value passed back to you in all calls to the inDataFunc |
inModeS_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 |
XPMPPlaneID XPMPCreatePlaneWithModelName | ( | const char * | inModelName, |
const char * | inICAOCode, | ||
const char * | inAirline, | ||
const char * | inLivery, | ||
XPMPPlaneData_f | inDataFunc, | ||
void * | inRefcon, | ||
XPMPPlaneID | inModeS_id = 0 |
||
) |
Creates a new plane, providing a specific CSL model name.
inModelName | CSL Model name (id) to use, or nullptr if normal matching using the next 3 parameters shall be applied |
inICAOCode | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
inAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
inLivery | Special livery designator, can be an empty string |
inDataFunc | Callback function called by XPMP2 to fetch updated data |
inRefcon | A refcon value passed back to you in all calls to the inDataFunc |
inModeS_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 |
void XPMPDestroyPlane | ( | XPMPPlaneID | _id | ) |
[Deprecated] Removes a plane previously created with XPMPCreatePlane()
void XPMPDisableAircraftLabels | ( | ) |
Disable drawing of labels with the aircraft.
Effectively calls XPMPEnableAircraftLabels()
bool XPMPDrawingAircraftLabels | ( | ) |
Returns if labels are currently configured to be drawn.
void XPMPDumpOneCycle | ( | void | ) |
Legacy debug-support function, no longer supported.
void XPMPEnableAircraftLabels | ( | bool | _enable = true | ) |
Enable or disable drawing of labels with the aircraft.
void XPMPEnableMap | ( | bool | _bEnable, |
bool | _bLabels = true |
||
) |
Enable or disable the drawing of aircraft icons on X-Plane's map.
_bEnable | Enable or disable entire map functionality |
_bLabels | If map is enabled, shall also labels be drawn? |
XPMP2 creates a separate Map Layer named after the plugin for this purposes. By default, the map functionality is enabled including label writing.
XPMP2::Aircraft* XPMPGetAircraft | ( | XPMPPlaneID | _id | ) |
Returns the underlying aircraft object, or nullptr
if _id
is invalid.
void XPMPGetModelInfo | ( | int | inIndex, |
const char ** | outModelName, | ||
const char ** | outIcao, | ||
const char ** | outAirline, | ||
const char ** | outLivery | ||
) |
Fetch information about a CSL model identified by an index.
inIndex | Number between 0 and `XPMPGetNumberOfInstalledModels()-1 | |
[out] | outModelName | Receives pointer to model name (id). Optional, can be nullptr. |
[out] | outIcao | Receives pointer to ICAO aircraft type designator. Optional, can be nullptr . |
[out] | outAirline | Receives pointer to ICAO airline code. Optional, can be nullptr . |
[out] | outLivery | Receives pointer to special livery string. Optional, can be nullptr . |
void XPMPGetModelInfo2 | ( | int | inIndex, |
std::string & | outModelName, | ||
std::string & | outIcao, | ||
std::string & | outAirline, | ||
std::string & | outLivery | ||
) |
Fetch information about a CSL model identified by an index.
inIndex | Number between 0 and `XPMPGetNumberOfInstalledModels()-1 | |
[out] | outModelName | Receives model name (id) |
[out] | outIcao | Receives ICAO aircraft designator |
[out] | outAirline | Receives ICAO airline code |
[out] | outLivery | Receives special livery string |
XPMPPlaneID XPMPGetNthPlane | ( | long | index | ) |
Returns the plane ID of the Nth plane.
int XPMPGetNumberOfInstalledModels | ( | ) |
Returns the number of loaded CSL models.
XPMPPlaneCallbackResult XPMPGetPlaneData | ( | XPMPPlaneID | inPlane, |
XPMPPlaneDataType | inDataType, | ||
void * | outData | ||
) |
Unsupported, don't use.
xpmpData_Unavailable
void XPMPGetPlaneICAOAndLivery | ( | XPMPPlaneID | inPlane, |
char * | outICAOCode, | ||
char * | outLivery | ||
) |
Returns ICAO aircraft type designator and livery of the given plane.
int XPMPGetPlaneModelName | ( | XPMPPlaneID | inPlaneID, |
char * | outTxtBuf, | ||
int | outTxtBufSize | ||
) |
Return the name of the model, with which the given plane is rendered.
inPlaneID | Identifies the plane | |
[out] | outTxtBuf | (optional) Points to a character array to hold the model name. The returned C string is guaranteed to be zero-terminated. Pass in NULL to just receive the string's length |
outTxtBufSize | Size of that buffer |
inPlaneID
is invalid int XPMPGetPlaneModelQuality | ( | XPMPPlaneID | inPlane | ) |
Returns the match quality of the currently used model, or -1
if inPlane
is invalid.
bool XPMPHasControlOfAIAircraft | ( | ) |
Has XPMP2 control of TCAS targets?
bool XPMPIsICAOValid | ( | const char * | inICAO | ) |
Is inICAO
a valid ICAO aircraft type designator?
const char* XPMPLoadCSLPackage | ( | const char * | inCSLFolder | ) |
Loads CSL packages from the given folder, searching up to 5 folder levels deep.
This function mainly searches the given folder for packages. It traverses all folders in search for xsb_aircraft.txt
files. It will find all xsb_aircraft.txt
files situated at or below the given root path, up to 5 levels deep.
As soon as such a file is found it is read and processed. Depth search then ends. (But searching parallel folders may still continue.)
The xsb_aircraft.txt
is loaded and processed. Duplicate models (by package and CSL model name, tags EXPORT_NAME
and OBJ8_AIRCRAFT
) are ignored. For others the existence of the .obj
file is validated, but not the existence of files in turn needed by the .obj
file, like textures. If validated successfully the model is added to an internal catalogue.
Actual loading of objects is done later and asynchronously only when needed during aircraft creation.
inCSLFolder | Root folder to start the search. |
void XPMPLoadPlanesIfNecessary | ( | ) |
Legacy function only provided for backwards compatibility. Does not actually do anything.
int XPMPModelMatchQuality | ( | const char * | inICAO, |
const char * | inAirline, | ||
const char * | inLivery | ||
) |
Tests model match quality based on the given parameters.
inICAO | ICAO aircraft type designator, optional, can be nullptr |
inAirline | ICAO airline code, optional, can be nullptr |
inLivery | Special livery text, optional, can be nullptr |
void XPMPMultiplayerCleanup | ( | ) |
void XPMPMultiplayerDisable | ( | ) |
Release TCAS targets control.
Afterwards, XPMP2's aircraft will no longer appear on TCAS or on 3rd-party plugins relying on TCAS targets dataRefs.
Is called during XPMPMultiplayerCleanup() automatically.
const char* XPMPMultiplayerEnable | ( | void(*)(void *) | _callback = nullptr , |
void * | _refCon = nullptr |
||
) |
Tries to grab control of TCAS targets (formerly known as AI/multiplayer) from X-Plane.
Only one plugin can have TCAS targets control at any one time. So be prepared to properly handle an non-empty response that indicates that you did not get control now. The returned message includes the name of the plugin currently having control.
If successful, XPMP2's aircraft will appear on TCAS and are available to 3rd-party plugins relying on TCAS tagrtes or multiplayer dataRefs.
Typically, a plugin calls this function just before the first aircraft are created. But it could also be bound to a menu item, for example.
_callback | (optional) You can provide a callback function, which is called directly by X-Plane when control of TCAS targets is not successful now but becomes available later. |
_refCon | (optional) A value just passed through to the callback. |
const char* XPMPMultiplayerInit | ( | const char * | inPluginName, |
const char * | resourceDir, | ||
XPMPIntPrefsFuncTy | inIntPrefsFunc = nullptr , |
||
const char * | inDefaultICAO = nullptr , |
||
const char * | inPluginLogAcronym = nullptr |
||
) |
Initializes the XPMP2 library. This shall be your first call to the library.
inPluginName | Your plugin's name, mainly used as map layer name and for logging |
resourceDir | The directory where XPMP2 finds all required supplemental files (Doc8643.txt , MapIcons.png , related.txt , optionally Obj8DataRefs.txt ) |
inIntPrefsFunc | (optional) A pointer to a callback function providing integer config values. See XPMPIntPrefsFuncTy for details. |
inDefaultICAO | (optional) A fallback aircraft type if no type can be deduced otherwise for an aircraft. |
inPluginLogAcronym | (optional) A short text to be used in log output. If not given then inPluginName is used also for this purpose. |
Assume that this is XP's main thread
const char* XPMPMultiplayerInitLegacyData | ( | const char * | inCSLFolder, |
const char * | inPluginName, | ||
const char * | resourceDir, | ||
XPMPIntPrefsFuncTy | inIntPrefsFunc = nullptr , |
||
const char * | inDefaultICAO = nullptr , |
||
const char * | inPluginLogAcronym = nullptr |
||
) |
Deprecated legacy initialization of XPMP2.
Effectively calls, in this order, XPMPMultiplayerInit() and XPMPLoadCSLPackage().
const char* XPMPMultiplayerOBJ7SupportEnable | ( | const char * | inTexturePath | ) |
Used to set the light textures for old OBJ7 models.
void XPMPRegisterPlaneNotifierFunc | ( | XPMPPlaneNotifier_f | inFunc, |
void * | inRefcon | ||
) |
Registers a callback, which is called when one of the events defined in XPMPPlaneNotification happens.
inFunc | Pointer to your callback function |
inRefcon | A refcon passed through to your callback |
void XPMPSetAircraftLabelDist | ( | float | _dist_nm, |
bool | _bCutOffAtVisibility = true |
||
) |
Configure maximum label distance and if labels shall be cut off at reported visibility
_dist_nm | Maximum label distance in nm, default is 3, minimum is 1 |
_bCutOffAtVisibility | Shall labels not be drawn further away than XP's reported visibility? |
void XPMPSetDefaultPlaneICAO | ( | const char * | _acIcaoType, |
const char * | _carIcaoType = nullptr |
||
) |
Define default aircraft and ground vehicle ICAO types.
_acIcaoType | Default ICAO aircraft type designator, used when matching returns nothing |
_carIcaoType | Type used to identify ground vehicels (internally defaults to "ZZZC") |
void XPMPSetPlaneRenderer | ( | XPMPRenderPlanes_f | inRenderer, |
void * | inRef | ||
) |
The original libxplanemp allowed to override rendering; no longer supported.
void XPMPSetPlaneVisibility | ( | XPMPPlaneID | _id, |
bool | _bVisible | ||
) |
Show/Hide the aircraft temporarily without destroying the object.
void XPMPSetPluginName | ( | const char * | inPluginName, |
const char * | inPluginLogAcronym = nullptr |
||
) |
Overrides the plugin's name to be used in Log output.
The same as providing a plugin name with XPMPMultiplayerInit(). If no name is provided, it defaults to the plugin's name as set in XPluginStart().
XPMP_CLIENT_LONGNAME
needed in libxplanemp
. inPluginName | Your plugin's name, used as map layer name, and as folder name under Aircraft |
inPluginLogAcronym | (optional) A short text to be used in log output. If not given then inPluginName is used also for this purpse. |
const char* XPMPSoundAdd | ( | const char * | sName, |
const char * | filePath, | ||
bool | bLoop, | ||
float | coneDir = NAN , |
||
float | conePitch = NAN , |
||
float | coneInAngle = NAN , |
||
float | coneOutAngle = NAN , |
||
float | coneOutVol = NAN |
||
) |
Add a sound that can later be referenced from an XPMP2::Aircraft.
XPMP2 loads a number of default sounds from what X-Plane ships. This function allows to add your own. It will try to load the sound immediately.
sName | A descriptive name, used as a key to refer to this sound later |
filePath | Path to the sound file; a relative path is relative to resourceDir as set by XPMPMultiplayerInit() |
bLoop | Is this sound to be played in a loop? |
coneDir | [opt] Which direction relative to plane's heading does the cone point to? (180 would be typical for jet engines) |
conePitch | [opt] Which pitch does the cone point to (up/down)? (0 would be typical, ie. level with the plane) |
coneInAngle | [opt] Inside cone angle. This is the angle spread within which the sound is unattenuated. |
coneOutAngle | [opt] Outside cone angle. This is the angle spread outside of which the sound is attenuated to its coneOutVol . |
coneOutVol | [opt] Cone outside volume. |
bool XPMPSoundEnable | ( | bool | bEnable = true | ) |
Enable/Disable Sound.
Enable or disable sound support. The default on startup is controlled by the configuration item sound / activate_sound
, which in turn defaults to 1
.
false
even in case of activation if there was a problem during sound initialization or if it was too early too link into XP's sound system) const char* XPMPSoundEnumerate | ( | const char * | prevName, |
const char ** | ppFilePath = nullptr |
||
) |
Enumerate all sounds, including the internal ones.
prevName | nullptr or empty string to start from beginning, last returned name to continue with next sound | |
[out] | ppFilePath | (optional) Receives pointer to file path |
bool XPMPSoundIsEnabled | ( | ) |
Is Sound enabled?
void XPMPSoundMute | ( | bool | bMute | ) |
Mute all sounds (temporarily)
bMute | Mute (true ) or unmute (false )? |
void XPMPSoundSetMasterVolume | ( | float | fVol = 1.0f | ) |
Set Master Volume.
fVol | Volume level. 0 = silent, 1 = full. Negative level inverts the signal. Values larger than 1 amplify the signal. |
void XPMPUnregisterPlaneNotifierFunc | ( | XPMPPlaneNotifier_f | inFunc, |
void * | inRefcon | ||
) |
Unregisters a notification callback. Both function pointer and refcon must match what was registered.
inFunc | Pointer to your callback function |
inRefcon | A refcon passed through to your callback |
|
constexpr |
Maximum allowed XPMPPlaneID / mode S id.
|
constexpr |
Minimum allowed XPMPPlaneID / mode S id.