This page probably requires more attention…
but there is a working sample plugin available in
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
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
Resourcesfolder under the plugin’s folder holding the 3 files from the
Resourcesfolder provided here with XPMP2,
Its source code
XPMP2-Sample.cpp includes a lot of comments explaining
what is happening. Read them!
Expected folder structure of the installation:
<X-Plane>/Resources/plugins/XPMP2-Sample/ lin_x64/XPMP2-Sample.xpl mac_x64/XPMP2-Sample.xpl Resources/ CSL/ <-- install models here Doc8643.txt MapIcons.png Obj8DataRefs.txt related.txt win_x64/XPMP2-Sample.xpl
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 using
XPMPLoadCSLPackageonce or multiple times, and
New plugin implementations are strongly advised to directly sub-class
from the new class
XPMP2::Aircraft, which is the actual aircraft representation.
SampleAircraft class defined in
for an example implementation.
In your class, override the abstract function
Setmember functions as needed, or
varray using the elements of
enum DR_VALSas indexes.
This way minimises the number of copy operations needed.
drawInfo and the
are directly passed on to the
Other values like
acInfoTexts can also be updated by your
UpdatePosition() implementation and are used when drawing labels
or providing information externally like via AI/multiplayer dataRefs.