Panda3D
Loading...
Searching...
No Matches
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 */
19set_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 */
27INLINE PN_stdfloat DriveInterface::
28get_forward_speed() const {
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 */
37set_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 */
45INLINE PN_stdfloat DriveInterface::
46get_reverse_speed() const {
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 */
55set_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 */
64INLINE PN_stdfloat DriveInterface::
65get_rotate_speed() const {
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 */
76set_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 */
86INLINE 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 */
98set_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 */
108INLINE 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 */
119set_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 */
128INLINE 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 */
138set_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 */
146INLINE 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 */
156set_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 */
164INLINE 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 */
174set_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 */
182INLINE PN_stdfloat DriveInterface::
184 return _horizontal_ramp_down_time;
185}
186
187/**
188 * Returns the speed of the previous update in units/sec
189 */
190INLINE PN_stdfloat DriveInterface::
191get_speed() const {
192 return _speed;
193}
194
195/**
196 * Returns the rot_speed of the previous update in units/sec
197 */
198INLINE PN_stdfloat DriveInterface::
199get_rot_speed() const {
200 return _rot_speed;
201}
202
203/**
204 * Returns the driver's position.
205 */
206INLINE const LPoint3 &DriveInterface::
207get_pos() const {
208 return _xyz;
209}
210
211INLINE PN_stdfloat DriveInterface::
212get_x() const {
213 return _xyz[0];
214}
215
216INLINE PN_stdfloat DriveInterface::
217get_y() const {
218 return _xyz[1];
219}
220
221INLINE PN_stdfloat DriveInterface::
222get_z() const {
223 return _xyz[2];
224}
225
226
227/**
228 * Directly sets the driver's position.
229 */
231set_pos(const LVecBase3 &vec) {
232 _xyz = vec;
233}
234
235INLINE void DriveInterface::
236set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
237 _xyz.set(x, y, z);
238}
239
240INLINE void DriveInterface::
241set_x(PN_stdfloat x) {
242 _xyz[0] = x;
243}
244
245INLINE void DriveInterface::
246set_y(PN_stdfloat y) {
247 _xyz[1] = y;
248}
249
250INLINE void DriveInterface::
251set_z(PN_stdfloat z) {
252 _xyz[2] = z;
253}
254
255
256/**
257 * Returns the driver's orientation.
258 */
259INLINE const LVecBase3 &DriveInterface::
260get_hpr() const {
261 return _hpr;
262}
263
264INLINE PN_stdfloat DriveInterface::
265get_h() const {
266 return _hpr[0];
267}
268
269INLINE PN_stdfloat DriveInterface::
270get_p() const {
271 return _hpr[1];
272}
273
274INLINE PN_stdfloat DriveInterface::
275get_r() const {
276 return _hpr[2];
277}
278
279
280/**
281 * Directly sets the driver's orientation.
282 */
284set_hpr(const LVecBase3 &hpr) {
285 set_hpr(hpr[0], hpr[1], hpr[2]);
286}
287
288INLINE void DriveInterface::
289set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
290 set_h(h);
291 set_p(p);
292 set_r(r);
293}
294
295INLINE void DriveInterface::
296set_h(PN_stdfloat h) {
297 _hpr[0] = _hpr_quantize * floor(h / _hpr_quantize + 0.5f);
298}
299
300INLINE void DriveInterface::
301set_p(PN_stdfloat p) {
302 _hpr[1] = _hpr_quantize * floor(p / _hpr_quantize + 0.5f);
303}
304
305INLINE void DriveInterface::
306set_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 */
319set_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 */
328get_ignore_mouse() const {
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 */
337set_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 */
346get_force_mouse() const {
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 */
358set_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 */
367get_stop_this_frame() const {
368 return _stop_this_frame;
369}
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_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_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...
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...
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_speed() const
Returns the speed of the previous update in units/sec.
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...
bool get_ignore_mouse() const
Returns the current setting of the ignore_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_pos(const LVecBase3 &vec)
Directly sets the driver's position.
bool get_stop_this_frame() const
Returns the current setting of the stop_this_frame flag.
const LVecBase3 & get_hpr() const
Returns the driver's orientation.
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_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...
void set_force_mouse(bool force_mouse)
Changes the state of the force_mouse flag.
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_ignore_mouse(bool ignore_mouse)
Changes the state of the ignore_mouse flag.
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...
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_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...
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...
PN_stdfloat get_rot_speed() const
Returns the rot_speed of the previous update in units/sec.
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_reverse_speed() const
Returns the speed of full reverse motion, when the mouse is at the very bottom of the window.
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 ...
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 ...
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,...
bool get_force_mouse() const
Returns the current setting of the force_mouse flag.
void set_hpr(const LVecBase3 &hpr)
Directly sets the driver's orientation.