Panda3D
driveInterface.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file driveInterface.I
10  * @author drose
11  * @date 2002-03-12
12  */
13 
14 /**
15  * Sets the speed of full forward motion, when the mouse is at the very top of
16  * the window. This is in units (e.g. feet) per second.
17  */
18 INLINE void DriveInterface::
19 set_forward_speed(PN_stdfloat speed) {
20  _forward_speed = speed;
21 }
22 
23 /**
24  * Returns the speed of full forward motion, when the mouse is at the very top
25  * of the window. This is in units (e.g. feet) per second.
26  */
27 INLINE PN_stdfloat DriveInterface::
29  return _forward_speed;
30 }
31 
32 /**
33  * Sets the speed of full reverse motion, when the mouse is at the very bottom
34  * of the window. This is in units (e.g. feet) per second.
35  */
36 INLINE void DriveInterface::
37 set_reverse_speed(PN_stdfloat speed) {
38  _reverse_speed = speed;
39 }
40 
41 /**
42  * Returns the speed of full reverse motion, when the mouse is at the very
43  * bottom of the window. This is in units (e.g. feet) per second.
44  */
45 INLINE PN_stdfloat DriveInterface::
47  return _reverse_speed;
48 }
49 
50 /**
51  * Sets the maximum rate at which the user can rotate left or right, when the
52  * mouse is at the very edge of the window. This is in degrees per second.
53  */
54 INLINE void DriveInterface::
55 set_rotate_speed(PN_stdfloat speed) {
56  _rotate_speed = speed;
57 }
58 
59 /**
60  * Returns the maximum rate at which the user can rotate left or right, when
61  * the mouse is at the very edge of the window. This is in degrees per
62  * second.
63  */
64 INLINE PN_stdfloat DriveInterface::
66  return _rotate_speed;
67 }
68 
69 /**
70  * Sets the size of the horizontal bar in the center of the screen that
71  * represents the "dead zone" of vertical motion: the region in which the
72  * mouse does not report vertical motion. This is in a fraction of the window
73  * height, so 0.5 will set a dead zone as large as half the screen.
74  */
75 INLINE void DriveInterface::
76 set_vertical_dead_zone(PN_stdfloat speed) {
77  _vertical_dead_zone = speed;
78 }
79 
80 /**
81  * Returns the size of the horizontal bar in the center of the screen that
82  * represents the "dead zone" of vertical motion: the region in which the
83  * mouse does not report vertical motion. This is in a fraction of the window
84  * height, so 0.5 will set a dead zone as large as half the screen.
85  */
86 INLINE PN_stdfloat DriveInterface::
88  return _vertical_dead_zone;
89 }
90 
91 /**
92  * Sets the size of the vertical bar in the center of the screen that
93  * represents the "dead zone" of horizontal motion: the region in which the
94  * mouse does not report horizontal motion. This is in a fraction of the
95  * window width, so 0.5 will set a dead zone as large as half the screen.
96  */
97 INLINE void DriveInterface::
98 set_horizontal_dead_zone(PN_stdfloat speed) {
99  _horizontal_dead_zone = speed;
100 }
101 
102 /**
103  * Returns the size of the vertical bar in the center of the screen that
104  * represents the "dead zone" of horizontal motion: the region in which the
105  * mouse does not report horizontal motion. This is in a fraction of the
106  * window width, so 0.5 will set a dead zone as large as half the screen.
107  */
108 INLINE PN_stdfloat DriveInterface::
110  return _horizontal_dead_zone;
111 }
112 
113 /**
114  * Sets the amount of time, in seconds, it takes between the time an up or
115  * down arrow key is pressed and the time it registers full forward or
116  * backward motion.
117  */
118 INLINE void DriveInterface::
119 set_vertical_ramp_up_time(PN_stdfloat ramp_up_time) {
120  _vertical_ramp_up_time = ramp_up_time;
121 }
122 
123 /**
124  * Returns the amount of time, in seconds, it takes between the time an up or
125  * down arrow key is pressed and the time it registers full forward or
126  * backward motion.
127  */
128 INLINE PN_stdfloat DriveInterface::
130  return _vertical_ramp_up_time;
131 }
132 
133 /**
134  * Sets the amount of time, in seconds, it takes between the time an up or
135  * down arrow key is released and the time it registers no motion.
136  */
137 INLINE void DriveInterface::
138 set_vertical_ramp_down_time(PN_stdfloat ramp_down_time) {
139  _vertical_ramp_down_time = ramp_down_time;
140 }
141 
142 /**
143  * Returns the amount of time, in seconds, it takes between the time an up or
144  * down arrow key is released and the time it registers no motion.
145  */
146 INLINE PN_stdfloat DriveInterface::
148  return _vertical_ramp_down_time;
149 }
150 
151 /**
152  * Sets the amount of time, in seconds, it takes between the time a left or
153  * right arrow key is pressed and the time it registers full rotation.
154  */
155 INLINE void DriveInterface::
156 set_horizontal_ramp_up_time(PN_stdfloat ramp_up_time) {
157  _horizontal_ramp_up_time = ramp_up_time;
158 }
159 
160 /**
161  * Returns the amount of time, in seconds, it takes between the time a left or
162  * right arrow key is pressed and the time it registers full rotation.
163  */
164 INLINE PN_stdfloat DriveInterface::
166  return _horizontal_ramp_up_time;
167 }
168 
169 /**
170  * Sets the amount of time, in seconds, it takes between the time a left or
171  * right arrow key is released and the time it registers no motion.
172  */
173 INLINE void DriveInterface::
174 set_horizontal_ramp_down_time(PN_stdfloat ramp_down_time) {
175  _horizontal_ramp_down_time = ramp_down_time;
176 }
177 
178 /**
179  * Returns the amount of time, in seconds, it takes between the time a left or
180  * right arrow key is released and the time it registers no motion.
181  */
182 INLINE PN_stdfloat DriveInterface::
184  return _horizontal_ramp_down_time;
185 }
186 
187 /**
188  * Returns the speed of the previous update in units/sec
189  */
190 INLINE PN_stdfloat DriveInterface::
191 get_speed() const {
192  return _speed;
193 }
194 
195 /**
196  * Returns the rot_speed of the previous update in units/sec
197  */
198 INLINE PN_stdfloat DriveInterface::
199 get_rot_speed() const {
200  return _rot_speed;
201 }
202 
203 /**
204  * Returns the driver's position.
205  */
206 INLINE const LPoint3 &DriveInterface::
207 get_pos() const {
208  return _xyz;
209 }
210 
211 INLINE PN_stdfloat DriveInterface::
212 get_x() const {
213  return _xyz[0];
214 }
215 
216 INLINE PN_stdfloat DriveInterface::
217 get_y() const {
218  return _xyz[1];
219 }
220 
221 INLINE PN_stdfloat DriveInterface::
222 get_z() const {
223  return _xyz[2];
224 }
225 
226 
227 /**
228  * Directly sets the driver's position.
229  */
230 INLINE void DriveInterface::
231 set_pos(const LVecBase3 &vec) {
232  _xyz = vec;
233 }
234 
235 INLINE void DriveInterface::
236 set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
237  _xyz.set(x, y, z);
238 }
239 
240 INLINE void DriveInterface::
241 set_x(PN_stdfloat x) {
242  _xyz[0] = x;
243 }
244 
245 INLINE void DriveInterface::
246 set_y(PN_stdfloat y) {
247  _xyz[1] = y;
248 }
249 
250 INLINE void DriveInterface::
251 set_z(PN_stdfloat z) {
252  _xyz[2] = z;
253 }
254 
255 
256 /**
257  * Returns the driver's orientation.
258  */
259 INLINE const LVecBase3 &DriveInterface::
260 get_hpr() const {
261  return _hpr;
262 }
263 
264 INLINE PN_stdfloat DriveInterface::
265 get_h() const {
266  return _hpr[0];
267 }
268 
269 INLINE PN_stdfloat DriveInterface::
270 get_p() const {
271  return _hpr[1];
272 }
273 
274 INLINE PN_stdfloat DriveInterface::
275 get_r() const {
276  return _hpr[2];
277 }
278 
279 
280 /**
281  * Directly sets the driver's orientation.
282  */
283 INLINE void DriveInterface::
284 set_hpr(const LVecBase3 &hpr) {
285  set_hpr(hpr[0], hpr[1], hpr[2]);
286 }
287 
288 INLINE void DriveInterface::
289 set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
290  set_h(h);
291  set_p(p);
292  set_r(r);
293 }
294 
295 INLINE void DriveInterface::
296 set_h(PN_stdfloat h) {
297  _hpr[0] = _hpr_quantize * floor(h / _hpr_quantize + 0.5f);
298 }
299 
300 INLINE void DriveInterface::
301 set_p(PN_stdfloat p) {
302  _hpr[1] = _hpr_quantize * floor(p / _hpr_quantize + 0.5f);
303 }
304 
305 INLINE void DriveInterface::
306 set_r(PN_stdfloat r) {
307  _hpr[2] = _hpr_quantize * floor(r / _hpr_quantize + 0.5f);
308 }
309 
310 /**
311  * Changes the state of the ignore_mouse flag. If this flag is true, the
312  * DriveInterface will ignore mouse down button events (but still recognize
313  * mouse up button events); the user will not be able to start the
314  * DriveInterface going again if it is stopped, but if the user is currently
315  * holding down a mouse button it will not stop immediately until the user
316  * eventually releases the button.
317  */
318 INLINE void DriveInterface::
319 set_ignore_mouse(bool ignore_mouse) {
320  _ignore_mouse = ignore_mouse;
321 }
322 
323 /**
324  * Returns the current setting of the ignore_mouse flag. See
325  * set_ignore_mouse().
326  */
327 INLINE bool DriveInterface::
329  return _ignore_mouse;
330 }
331 
332 /**
333  * Changes the state of the force_mouse flag. If this flag is true, the mouse
334  * button need not be held down in order to drive the avatar around.
335  */
336 INLINE void DriveInterface::
337 set_force_mouse(bool force_mouse) {
338  _force_mouse = force_mouse;
339 }
340 
341 /**
342  * Returns the current setting of the force_mouse flag. See
343  * set_force_mouse().
344  */
345 INLINE bool DriveInterface::
347  return _force_mouse;
348 }
349 
350 /**
351  * If stop_this_frame is true, the next time the frame is computed no motion
352  * will be allowed, and then the flag is reset to false. This can be used to
353  * prevent too much movement when we know a long time has artificially
354  * elapsed, for instance when we take a screenshot, without munging the clock
355  * for everything else.
356  */
357 INLINE void DriveInterface::
358 set_stop_this_frame(bool stop_this_frame) {
359  _stop_this_frame = stop_this_frame;
360 }
361 
362 /**
363  * Returns the current setting of the stop_this_frame flag. See
364  * set_stop_this_frame().
365  */
366 INLINE bool DriveInterface::
368  return _stop_this_frame;
369 }
PN_stdfloat get_rot_speed() const
Returns the rot_speed of the previous update in units/sec.
void set_horizontal_dead_zone(PN_stdfloat zone)
Sets the size of the vertical bar in the center of the screen that represents the "dead zone" of hori...
PN_stdfloat get_vertical_dead_zone() const
Returns the size of the horizontal bar in the center of the screen that represents the "dead zone" of...
PN_stdfloat get_horizontal_ramp_up_time() const
Returns the amount of time, in seconds, it takes between the time a left or right arrow key is presse...
PN_stdfloat get_reverse_speed() const
Returns the speed of full reverse motion, when the mouse is at the very bottom of the window.
void set_pos(const LVecBase3 &vec)
Directly sets the driver's position.
void set_ignore_mouse(bool ignore_mouse)
Changes the state of the ignore_mouse flag.
void set_rotate_speed(PN_stdfloat speed)
Sets the maximum rate at which the user can rotate left or right, when the mouse is at the very edge ...
PN_stdfloat get_speed() const
Returns the speed of the previous update in units/sec.
PN_stdfloat get_horizontal_dead_zone() const
Returns the size of the vertical bar in the center of the screen that represents the "dead zone" of h...
bool get_force_mouse() const
Returns the current setting of the force_mouse flag.
void set_vertical_dead_zone(PN_stdfloat zone)
Sets the size of the horizontal bar in the center of the screen that represents the "dead zone" of ve...
bool get_stop_this_frame() const
Returns the current setting of the stop_this_frame flag.
void set_horizontal_ramp_down_time(PN_stdfloat ramp_down_time)
Sets the amount of time, in seconds, it takes between the time a left or right arrow key is released ...
void set_reverse_speed(PN_stdfloat speed)
Sets the speed of full reverse motion, when the mouse is at the very bottom of the window.
bool get_ignore_mouse() const
Returns the current setting of the ignore_mouse flag.
PN_stdfloat get_horizontal_ramp_down_time() const
Returns the amount of time, in seconds, it takes between the time a left or right arrow key is releas...
void set_hpr(const LVecBase3 &hpr)
Directly sets the driver's orientation.
void set_horizontal_ramp_up_time(PN_stdfloat ramp_up_time)
Sets the amount of time, in seconds, it takes between the time a left or right arrow key is pressed a...
PN_stdfloat get_rotate_speed() const
Returns the maximum rate at which the user can rotate left or right, when the mouse is at the very ed...
const LPoint3 & get_pos() const
Returns the driver's position.
void set_stop_this_frame(bool stop_this_frame)
If stop_this_frame is true, the next time the frame is computed no motion will be allowed,...
void set_forward_speed(PN_stdfloat speed)
Sets the speed of full forward motion, when the mouse is at the very top of the window.
const LVecBase3 & get_hpr() const
Returns the driver's orientation.
PN_stdfloat get_vertical_ramp_up_time() const
Returns the amount of time, in seconds, it takes between the time an up or down arrow key is pressed ...
void set_force_mouse(bool force_mouse)
Changes the state of the force_mouse flag.
PN_stdfloat get_vertical_ramp_down_time() const
Returns the amount of time, in seconds, it takes between the time an up or down arrow key is released...
void set_vertical_ramp_down_time(PN_stdfloat ramp_down_time)
Sets the amount of time, in seconds, it takes between the time an up or down arrow key is released an...
PN_stdfloat get_forward_speed() const
Returns the speed of full forward motion, when the mouse is at the very top of the window.
void set_vertical_ramp_up_time(PN_stdfloat ramp_up_time)
Sets the amount of time, in seconds, it takes between the time an up or down arrow key is pressed and...