Camera Control


XPLMCameraControlDuration

enum

This enumeration states how long you want to retain control of the camera. You can retain it indefinitely or until the user selects a new view.

Name Value Description
xplm_ControlCameraUntilViewChanges 1 Control the camera until the user picks a new view.
xplm_ControlCameraForever 2 Control the camera until your plugin is disabled or another plugin forcibly takes control.

XPLMCameraPosition_t

struct

This structure contains a full specification of the camera. X, Y, and Z are the camera's position in OpenGL coordinates; pitch, roll, and yaw are rotations from a camera facing flat north in degrees. Positive pitch means nose up, positive roll means roll right, and positive yaw means yaw right, all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 magnifying by 2x (objects appear larger).

typedef struct {
     float                     x;
     float                     y;
     float                     z;
     float                     pitch;
     float                     heading;
     float                     roll;
     float                     zoom;
} XPLMCameraPosition_t;

XPLMCameraControl_f

callback

You use an XPLMCameraControl function to provide continuous control over the camera. You are passed a structure in which to put the new camera position; modify it and return true to reposition the camera. Return false to surrender control of the camera; camera control will be handled by X-Plane on this draw loop. The contents of the structure as you are called are undefined.

If X-Plane is taking camera control away from you, this function will be called with inIsLosingControl set to true and ioCameraPosition NULL.

typedef int (* XPLMCameraControl_f)(
                         XPLMCameraPosition_t * outCameraPosition,    /* Can be NULL */
                         int                  inIsLosingControl,
                         void *               inRefcon
                    );

XPLMControlCamera

function

This function repositions the camera on the next drawing cycle. You must pass a non-null control function. Specify in inHowLong how long you'd like control (indefinitely or until a new view mode is set by the user).

XPLM_API void       XPLMControlCamera(
                         XPLMCameraControlDuration inHowLong,
                         XPLMCameraControl_f  inControlFunc,
                         void *               inRefcon
                    );

XPLMDontControlCamera

function

This function stops you from controlling the camera. If you have a camera control function, it will not be called with an inIsLosingControl flag. X-Plane will control the camera on the next cycle.

For maximum compatibility you should not use this routine unless you are in posession of the camera.

XPLM_API void       XPLMDontControlCamera(void);

XPLMIsCameraBeingControlled

function

This routine returns true if the camera is being controlled, false if it is not. If it is and you pass in a pointer to a camera control duration, the current control duration will be returned.

XPLM_API int        XPLMIsCameraBeingControlled(
                         XPLMCameraControlDuration * outCameraControlDuration    /* Can be NULL */
                    );

XPLMReadCameraPosition

function

This function reads the current camera position.

XPLM_API void       XPLMReadCameraPosition(
                         XPLMCameraPosition_t * outCameraPosition
                    );