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