How to Use XPMP2

This page probably requires more attention… but there is a working sample plugin available in the XPMP2-Sample folder for you to study:

Sample Plugin

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

Its source code XPMP2-Sample.cpp includes a lot of comments explaining what is happening. Read them!

Expected folder structure of the installation:

      CSL/                 <-- install models here

Binaries and Header Files

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.

Anatomy of Your Plugin using XPMP2

Generically you should probably use XPMP2 as follows:

Subclass XPMP2::Aircraft

New 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

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.