1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
{
Copyright 2005-2012 Sandy Barbour and Ben Supnik
All rights reserved. See license.txt for usage.
X-Plane SDK Version: 2.1.1
}
UNIT XPLMCamera;
INTERFACE
{
XPLMCamera - THEORY OF OPERATION The XPLMCamera APIs allow plug-ins to
control the camera angle in X-Plane. This has a number of applications,
including but not limited to:
- Creating new views (including dynamic/user-controllable views) for the
user.
- Creating applications that use X-Plane as a renderer of scenery,
aircrafts, or both.
The camera is controlled via six parameters: a location in OpenGL
coordinates and pitch, roll and yaw, similar to an airplane's position.
OpenGL coordinate info is described in detail in the XPLMGraphics
documentation; generally you should use the XPLMGraphics routines to
convert from world to local coordinates. The camera's orientation starts
facing level with the ground directly up the negative-Z axis
(approximately north) with the horizon horizontal. It is then rotated
clockwise for yaw, pitched up for positive pitch, and rolled clockwise
around the vector it is looking along for roll.
You control the camera either either until the user selects a new view or
permanently (the later being similar to how UDP camera control works). You
control the camera by registering a callback per frame from which you
calculate the new camera positions. This guarantees smooth camera motion.
Use the XPLMDataAccess APIs to get information like the position of the
aircraft, etc. for complex camera positioning.
}
USES XPLMDefs;
{$A4}
{$IFDEF MSWINDOWS}
{$DEFINE DELPHI}
{$ENDIF}
{___________________________________________________________________________
* CAMERA CONTROL
___________________________________________________________________________}
{
}
{
XPLMCameraControlDuration
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.
}
TYPE
XPLMCameraControlDuration = (
{ Control the camera until the user picks a new view. }
xplm_ControlCameraUntilViewChanges = 1
{ Control the camera until your plugin is disabled or another plugin forcably }
{ takes control. }
,xplm_ControlCameraForever = 2
);
PXPLMCameraControlDuration = ^XPLMCameraControlDuration;
{
XPLMCameraPosition_t
This structure contains a full specification of the camera. X, Y, and Z
are the camera's position in OpenGL coordiantes; 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).
}
XPLMCameraPosition_t = RECORD
x : single;
y : single;
z : single;
pitch : single;
heading : single;
roll : single;
zoom : single;
END;
PXPLMCameraPosition_t = ^XPLMCameraPosition_t;
{
XPLMCameraControl_f
You use an XPLMCameraControl function to provide continuous control over
the camera. You are passed in a structure in which to put the new camera
position; modify it and return 1 to reposition the camera. Return 0 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 1 and ioCameraPosition NULL.
}
XPLMCameraControl_f = FUNCTION(
outCameraPosition : PXPLMCameraPosition_t; { Can be nil }
inIsLosingControl : integer;
inRefcon : pointer) : integer; cdecl;
{
XPLMControlCamera
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 key is pressed).
}
PROCEDURE XPLMControlCamera(
inHowLong : XPLMCameraControlDuration;
inControlFunc : XPLMCameraControl_f;
inRefcon : pointer);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMDontControlCamera
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.
}
PROCEDURE XPLMDontControlCamera;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMIsCameraBeingControlled
This routine returns 1 if the camera is being controlled, zero 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.
}
FUNCTION XPLMIsCameraBeingControlled(
outCameraControlDuration: PXPLMCameraControlDuration) : integer; { Can be nil }
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMReadCameraPosition
This function reads the current camera position.
}
PROCEDURE XPLMReadCameraPosition(
outCameraPosition : PXPLMCameraPosition_t);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
IMPLEMENTATION
END.
|