Panda3D

driveInterface.I

00001 // Filename: driveInterface.I
00002 // Created by:  drose (12Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: DriveInterface::set_forward_speed
00018 //       Access: Published
00019 //  Description: Sets the speed of full forward motion, when the mouse
00020 //               is at the very top of the window.  This is in units
00021 //               (e.g. feet) per second.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE void DriveInterface::
00024 set_forward_speed(PN_stdfloat speed) {
00025   _forward_speed = speed;
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: DriveInterface::get_forward_speed
00030 //       Access: Published
00031 //  Description: Returns the speed of full forward motion, when the
00032 //               mouse is at the very top of the window.  This is in
00033 //               units (e.g. feet) per second.
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE PN_stdfloat DriveInterface::
00036 get_forward_speed() const {
00037   return _forward_speed;
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: DriveInterface::set_reverse_speed
00042 //       Access: Published
00043 //  Description: Sets the speed of full reverse motion, when the mouse
00044 //               is at the very bottom of the window.  This is in
00045 //               units (e.g. feet) per second.
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE void DriveInterface::
00048 set_reverse_speed(PN_stdfloat speed) {
00049   _reverse_speed = speed;
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: DriveInterface::get_reverse_speed
00054 //       Access: Published
00055 //  Description: Returns the speed of full reverse motion, when the
00056 //               mouse is at the very bottom of the window.  This is
00057 //               in units (e.g. feet) per second.
00058 ////////////////////////////////////////////////////////////////////
00059 INLINE PN_stdfloat DriveInterface::
00060 get_reverse_speed() const {
00061   return _reverse_speed;
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: DriveInterface::set_rotate_speed
00066 //       Access: Published
00067 //  Description: Sets the maximum rate at which the user can rotate
00068 //               left or right, when the mouse is at the very edge of
00069 //               the window.  This is in degrees per second.
00070 ////////////////////////////////////////////////////////////////////
00071 INLINE void DriveInterface::
00072 set_rotate_speed(PN_stdfloat speed) {
00073   _rotate_speed = speed;
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: DriveInterface::get_rotate_speed
00078 //       Access: Published
00079 //  Description: Returns the maximum rate at which the user can rotate
00080 //               left or right, when the mouse is at the very edge of
00081 //               the window.  This is in degrees per second.
00082 ////////////////////////////////////////////////////////////////////
00083 INLINE PN_stdfloat DriveInterface::
00084 get_rotate_speed() const {
00085   return _rotate_speed;
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: DriveInterface::set_vertical_dead_zone
00090 //       Access: Published
00091 //  Description: Sets the size of the horizontal bar in the center of
00092 //               the screen that represents the "dead zone" of
00093 //               vertical motion: the region in which the mouse does
00094 //               not report vertical motion.  This is in a fraction of
00095 //               the window height, so 0.5 will set a dead zone as
00096 //               large as half the screen.
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE void DriveInterface::
00099 set_vertical_dead_zone(PN_stdfloat speed) {
00100   _vertical_dead_zone = speed;
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: DriveInterface::get_vertical_dead_zone
00105 //       Access: Published
00106 //  Description: Returns the size of the horizontal bar in the center
00107 //               of the screen that represents the "dead zone" of
00108 //               vertical motion: the region in which the mouse does
00109 //               not report vertical motion.  This is in a fraction of
00110 //               the window height, so 0.5 will set a dead zone as
00111 //               large as half the screen.
00112 ////////////////////////////////////////////////////////////////////
00113 INLINE PN_stdfloat DriveInterface::
00114 get_vertical_dead_zone() const {
00115   return _vertical_dead_zone;
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: DriveInterface::set_horizontal_dead_zone
00120 //       Access: Published
00121 //  Description: Sets the size of the vertical bar in the center of
00122 //               the screen that represents the "dead zone" of
00123 //               horizontal motion: the region in which the mouse does
00124 //               not report horizontal motion.  This is in a fraction of
00125 //               the window width, so 0.5 will set a dead zone as
00126 //               large as half the screen.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE void DriveInterface::
00129 set_horizontal_dead_zone(PN_stdfloat speed) {
00130   _horizontal_dead_zone = speed;
00131 }
00132 
00133 ////////////////////////////////////////////////////////////////////
00134 //     Function: DriveInterface::get_horizontal_dead_zone
00135 //       Access: Published
00136 //  Description: Returns the size of the vertical bar in the center
00137 //               of the screen that represents the "dead zone" of
00138 //               horizontal motion: the region in which the mouse does
00139 //               not report horizontal motion.  This is in a fraction of
00140 //               the window width, so 0.5 will set a dead zone as
00141 //               large as half the screen.
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE PN_stdfloat DriveInterface::
00144 get_horizontal_dead_zone() const {
00145   return _horizontal_dead_zone;
00146 }
00147 
00148 ////////////////////////////////////////////////////////////////////
00149 //     Function: DriveInterface::set_vertical_ramp_up_time
00150 //       Access: Published
00151 //  Description: Sets the amount of time, in seconds, it takes between
00152 //               the time an up or down arrow key is pressed and the
00153 //               time it registers full forward or backward motion.
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE void DriveInterface::
00156 set_vertical_ramp_up_time(PN_stdfloat ramp_up_time) {
00157   _vertical_ramp_up_time = ramp_up_time;
00158 }
00159 
00160 ////////////////////////////////////////////////////////////////////
00161 //     Function: DriveInterface::get_vertical_ramp_up_time
00162 //       Access: Published
00163 //  Description: Returns the amount of time, in seconds, it takes
00164 //               between the time an up or down arrow key is pressed
00165 //               and the time it registers full forward or backward
00166 //               motion.
00167 ////////////////////////////////////////////////////////////////////
00168 INLINE PN_stdfloat DriveInterface::
00169 get_vertical_ramp_up_time() const {
00170   return _vertical_ramp_up_time;
00171 }
00172 
00173 ////////////////////////////////////////////////////////////////////
00174 //     Function: DriveInterface::set_vertical_ramp_down_time
00175 //       Access: Published
00176 //  Description: Sets the amount of time, in seconds, it takes between
00177 //               the time an up or down arrow key is released and the
00178 //               time it registers no motion.
00179 ////////////////////////////////////////////////////////////////////
00180 INLINE void DriveInterface::
00181 set_vertical_ramp_down_time(PN_stdfloat ramp_down_time) {
00182   _vertical_ramp_down_time = ramp_down_time;
00183 }
00184 
00185 ////////////////////////////////////////////////////////////////////
00186 //     Function: DriveInterface::get_vertical_ramp_down_time
00187 //       Access: Published
00188 //  Description: Returns the amount of time, in seconds, it takes
00189 //               between the time an up or down arrow key is released
00190 //               and the time it registers no motion.
00191 ////////////////////////////////////////////////////////////////////
00192 INLINE PN_stdfloat DriveInterface::
00193 get_vertical_ramp_down_time() const {
00194   return _vertical_ramp_down_time;
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: DriveInterface::set_horizontal_ramp_up_time
00199 //       Access: Published
00200 //  Description: Sets the amount of time, in seconds, it takes between
00201 //               the time a left or right arrow key is pressed and the
00202 //               time it registers full rotation.
00203 ////////////////////////////////////////////////////////////////////
00204 INLINE void DriveInterface::
00205 set_horizontal_ramp_up_time(PN_stdfloat ramp_up_time) {
00206   _horizontal_ramp_up_time = ramp_up_time;
00207 }
00208 
00209 ////////////////////////////////////////////////////////////////////
00210 //     Function: DriveInterface::get_horizontal_ramp_up_time
00211 //       Access: Published
00212 //  Description: Returns the amount of time, in seconds, it takes
00213 //               between the time a left or right arrow key is pressed
00214 //               and the time it registers full rotation.
00215 ////////////////////////////////////////////////////////////////////
00216 INLINE PN_stdfloat DriveInterface::
00217 get_horizontal_ramp_up_time() const {
00218   return _horizontal_ramp_up_time;
00219 }
00220 
00221 ////////////////////////////////////////////////////////////////////
00222 //     Function: DriveInterface::set_horizontal_ramp_down_time
00223 //       Access: Published
00224 //  Description: Sets the amount of time, in seconds, it takes between
00225 //               the time a left or right arrow key is released and the
00226 //               time it registers no motion.
00227 ////////////////////////////////////////////////////////////////////
00228 INLINE void DriveInterface::
00229 set_horizontal_ramp_down_time(PN_stdfloat ramp_down_time) {
00230   _horizontal_ramp_down_time = ramp_down_time;
00231 }
00232 
00233 ////////////////////////////////////////////////////////////////////
00234 //     Function: DriveInterface::get_horizontal_ramp_down_time
00235 //       Access: Published
00236 //  Description: Returns the amount of time, in seconds, it takes
00237 //               between the time a left or right arrow key is released
00238 //               and the time it registers no motion.
00239 ////////////////////////////////////////////////////////////////////
00240 INLINE PN_stdfloat DriveInterface::
00241 get_horizontal_ramp_down_time() const {
00242   return _horizontal_ramp_down_time;
00243 }
00244 
00245 ////////////////////////////////////////////////////////////////////
00246 //     Function: DriveInterface::get_speed
00247 //       Access: Published
00248 //  Description: Returns the speed of the previous update in units/sec
00249 ////////////////////////////////////////////////////////////////////
00250 INLINE PN_stdfloat DriveInterface::
00251 get_speed() const {
00252   return _speed;
00253 }
00254 
00255 ////////////////////////////////////////////////////////////////////
00256 //     Function: DriveInterface::get_rot_speed
00257 //       Access: Published
00258 //  Description: Returns the rot_speed of the previous update in units/sec
00259 ////////////////////////////////////////////////////////////////////
00260 INLINE PN_stdfloat DriveInterface::
00261 get_rot_speed() const {
00262   return _rot_speed;
00263 }
00264 
00265 ////////////////////////////////////////////////////////////////////
00266 //     Function: DriveInterface::get_pos
00267 //       Access: Published
00268 //  Description: Returns the driver's position.
00269 ////////////////////////////////////////////////////////////////////
00270 INLINE const LPoint3 &DriveInterface::
00271 get_pos() const {
00272   return _xyz;
00273 }
00274 
00275 INLINE PN_stdfloat DriveInterface::
00276 get_x() const {
00277   return _xyz[0];
00278 }
00279 
00280 INLINE PN_stdfloat DriveInterface::
00281 get_y() const {
00282   return _xyz[1];
00283 }
00284 
00285 INLINE PN_stdfloat DriveInterface::
00286 get_z() const {
00287   return _xyz[2];
00288 }
00289 
00290 
00291 ////////////////////////////////////////////////////////////////////
00292 //     Function: DriveInterface::set_pos
00293 //       Access: Published
00294 //  Description: Directly sets the driver's position.
00295 ////////////////////////////////////////////////////////////////////
00296 INLINE void DriveInterface::
00297 set_pos(const LVecBase3 &vec) {
00298   _xyz = vec;
00299 }
00300 
00301 INLINE void DriveInterface::
00302 set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00303   _xyz.set(x, y, z);
00304 }
00305 
00306 INLINE void DriveInterface::
00307 set_x(PN_stdfloat x) {
00308   _xyz[0] = x;
00309 }
00310 
00311 INLINE void DriveInterface::
00312 set_y(PN_stdfloat y) {
00313   _xyz[1] = y;
00314 }
00315 
00316 INLINE void DriveInterface::
00317 set_z(PN_stdfloat z) {
00318   _xyz[2] = z;
00319 }
00320 
00321 
00322 ////////////////////////////////////////////////////////////////////
00323 //     Function: DriveInterface::get_hpr
00324 //       Access: Published
00325 //  Description: Returns the driver's orientation.
00326 ////////////////////////////////////////////////////////////////////
00327 INLINE const LVecBase3 &DriveInterface::
00328 get_hpr() const {
00329   return _hpr;
00330 }
00331 
00332 INLINE PN_stdfloat DriveInterface::
00333 get_h() const {
00334   return _hpr[0];
00335 }
00336 
00337 INLINE PN_stdfloat DriveInterface::
00338 get_p() const {
00339   return _hpr[1];
00340 }
00341 
00342 INLINE PN_stdfloat DriveInterface::
00343 get_r() const {
00344   return _hpr[2];
00345 }
00346 
00347 
00348 ////////////////////////////////////////////////////////////////////
00349 //     Function: DriveInterface::set_hpr
00350 //       Access: Published
00351 //  Description: Directly sets the driver's orientation.
00352 ////////////////////////////////////////////////////////////////////
00353 INLINE void DriveInterface::
00354 set_hpr(const LVecBase3 &hpr) {
00355   set_hpr(hpr[0], hpr[1], hpr[2]);
00356 }
00357 
00358 INLINE void DriveInterface::
00359 set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
00360   set_h(h);
00361   set_p(p);
00362   set_r(r);
00363 }
00364 
00365 INLINE void DriveInterface::
00366 set_h(PN_stdfloat h) {
00367   _hpr[0] = _hpr_quantize * floor(h / _hpr_quantize + 0.5f);
00368 }
00369 
00370 INLINE void DriveInterface::
00371 set_p(PN_stdfloat p) {
00372   _hpr[1] = _hpr_quantize * floor(p / _hpr_quantize + 0.5f);
00373 }
00374 
00375 INLINE void DriveInterface::
00376 set_r(PN_stdfloat r) {
00377   _hpr[2] = _hpr_quantize * floor(r / _hpr_quantize + 0.5f);
00378 }
00379 
00380 ////////////////////////////////////////////////////////////////////
00381 //     Function: DriveInterface::set_ignore_mouse
00382 //       Access: Published
00383 //  Description: Changes the state of the ignore_mouse flag.  If this
00384 //               flag is true, the DriveInterface will ignore mouse
00385 //               down button events (but still recognize mouse up
00386 //               button events); the user will not be able to start
00387 //               the DriveInterface going again if it is stopped, but
00388 //               if the user is currently holding down a mouse button
00389 //               it will not stop immediately until the user
00390 //               eventually releases the button.
00391 ////////////////////////////////////////////////////////////////////
00392 INLINE void DriveInterface::
00393 set_ignore_mouse(bool ignore_mouse) {
00394   _ignore_mouse = ignore_mouse;
00395 }
00396 
00397 ////////////////////////////////////////////////////////////////////
00398 //     Function: DriveInterface::get_ignore_mouse
00399 //       Access: Published
00400 //  Description: Returns the current setting of the ignore_mouse flag.
00401 //               See set_ignore_mouse().
00402 ////////////////////////////////////////////////////////////////////
00403 INLINE bool DriveInterface::
00404 get_ignore_mouse() const {
00405   return _ignore_mouse;
00406 }
00407 
00408 ////////////////////////////////////////////////////////////////////
00409 //     Function: DriveInterface::set_force_mouse
00410 //       Access: Published
00411 //  Description: Changes the state of the force_mouse flag.  If this
00412 //               flag is true, the mouse button need not be held down
00413 //               in order to drive the avatar around.
00414 ////////////////////////////////////////////////////////////////////
00415 INLINE void DriveInterface::
00416 set_force_mouse(bool force_mouse) {
00417   _force_mouse = force_mouse;
00418 }
00419 
00420 ////////////////////////////////////////////////////////////////////
00421 //     Function: DriveInterface::get_force_mouse
00422 //       Access: Published
00423 //  Description: Returns the current setting of the force_mouse flag.
00424 //               See set_force_mouse().
00425 ////////////////////////////////////////////////////////////////////
00426 INLINE bool DriveInterface::
00427 get_force_mouse() const {
00428   return _force_mouse;
00429 }
00430 
00431 ////////////////////////////////////////////////////////////////////
00432 //     Function: DriveInterface::set_stop_this_frame
00433 //       Access: Published
00434 //  Description: If stop_this_frame is true, the next time the frame
00435 //               is computed no motion will be allowed, and then the
00436 //               flag is reset to false.  This can be used to prevent
00437 //               too much movement when we know a long time has
00438 //               artificially elapsed, for instance when we take a
00439 //               screenshot, without munging the clock for everything
00440 //               else.
00441 ////////////////////////////////////////////////////////////////////
00442 INLINE void DriveInterface::
00443 set_stop_this_frame(bool stop_this_frame) {
00444   _stop_this_frame = stop_this_frame;
00445 }
00446 
00447 ////////////////////////////////////////////////////////////////////
00448 //     Function: DriveInterface::get_stop_this_frame
00449 //       Access: Published
00450 //  Description: Returns the current setting of the stop_this_frame
00451 //               flag.  See set_stop_this_frame().
00452 ////////////////////////////////////////////////////////////////////
00453 INLINE bool DriveInterface::
00454 get_stop_this_frame() const {
00455   return _stop_this_frame;
00456 }
 All Classes Functions Variables Enumerations