|
XPMP2
X-Plane multiplayer library 2 - using instancing
|
This page probably requires more attention... but there is a working sample plugin available in the XPMP2-Sample folder for you to study:
This package comes with a sample plugin in the XPMP2-Sample folder. It is a complete plugin including build projects and CMake setup. It displays 3 aircraft flying circles in front of the user's plane. Each of the 3 aircraft is using a different technology: the now recommended way of subclassing XPMP2::Aircraft, the legacy way of subclassing XPCAircraft (as used by LiveTraffic v1.x), and by calling standard C functions.
For the sample plugin to work you need to follow instruction in Deploying XPMP2-based Plugins for
Resources folder under the plugin's folder holding the 3 files from the Resources folder provided here with XPMP2,Resources folder.Its source code XPMP2-Sample.cpp includes a lot of comments explaining what is happening. Read them!
Expected folder structure of the installation:
You don't need to build the library yourself if you don't want. Archives with headers and release/debug builds are available in the Release section here on GitHub.
Generically you should probably use XPMP2 as follows:
XPluginEnable: Initialize XPMP2 usingXPMPMultiplayerInit,XPMPLoadCSLPackage once or multiple times, andXPMPMultiplayerEnable.XPMP2::AircraftXPluginDisable:XPMPMultiplayerDisable andXPMPMultiplayerCleanupNew plugin implementations are strongly advised to directly sub-class from the new class XPMP2::Aircraft, which is the actual aircraft representation.
See the SampleAircraft class defined in XPMP2-Sample/XPMP2-Sample.cpp for an example implementation.
In your class, override the abstract function UpdatePosition() and
SetLocation(), ordrawInfo;Get/Set member functions as needed, orv array using the elements of enum DR_VALS as indexes.This way minimises the number of copy operations needed. drawInfo and the v array are directly passed on to the XPLMInstanceSetPosition call.
Other values like label, aiPrio, or acInfoTexts can also be updated by your UpdatePosition() implementation and are used when drawing labels or providing information externally like via AI/multiplayer dataRefs.