*** empty log message ***

This commit is contained in:
David Rose 2001-02-13 04:26:34 +00:00
parent faa5570026
commit 0c1635d32c
12 changed files with 616 additions and 509 deletions

View File

@ -91,6 +91,16 @@ sort_entries() {
_entries.swap(sorted_entries);
}
////////////////////////////////////////////////////////////////////
// Function: CollisionHandlerQueue::clear_entries
// Access: Public
// Description: Removes all the entries from the queue.
////////////////////////////////////////////////////////////////////
void CollisionHandlerQueue::
clear_entries() {
_entries.clear();
}
////////////////////////////////////////////////////////////////////
// Function: CollisionHandlerQueue::get_num_entries
// Access: Public

View File

@ -30,6 +30,7 @@ public:
PUBLISHED:
void sort_entries();
void clear_entries();
int get_num_entries() const;
CollisionEntry *get_entry(int n) const;

View File

@ -80,8 +80,8 @@ set_projection(ProjectionNode *camera, const LPoint2f &point) {
bool success = true;
if (!proj->extrude(point, _origin, _direction)) {
_origin.set(0.0, 0.0, 0.0);
_direction.set(0.0, 0.0, 0.0);
_origin = LPoint3f::origin();
_direction = LVector3f::forward();
success = false;
}
mark_bound_stale();

View File

@ -117,3 +117,17 @@ INLINE const LPoint3f &CollisionSegment::
get_point_b() const {
return _b;
}
////////////////////////////////////////////////////////////////////
// Function: CollisionSegment::set_projection
// Access: Public
// Description: Accepts a ProjectionNode and a 2-d point in the range
// [-1,1]. Sets the CollisionSegment so that it begins at
// the ProjectionNode's near plane and extends to the
// far plane, making it suitable for picking objects
// from the screen given a camera and a mouse location.
////////////////////////////////////////////////////////////////////
INLINE bool CollisionSegment::
set_projection(ProjectionNode *camera, float px, float py) {
return set_projection(camera, LPoint2f(px, py));
}

View File

@ -12,6 +12,8 @@
#include <geomNode.h>
#include <geomLine.h>
#include <geometricBoundingVolume.h>
#include <projectionNode.h>
#include <projection.h>
TypeHandle CollisionSegment::_type_handle;
@ -60,6 +62,40 @@ output(ostream &out) const {
out << "segment, a (" << _a << "), b (" << _b << ")";
}
////////////////////////////////////////////////////////////////////
// Function: CollisionSegment::set_projection
// Access: Public
// Description: Accepts a ProjectionNode and a 2-d point in the range
// [-1,1]. Sets the CollisionSegment so that it begins at
// the ProjectionNode's near plane and extends to the
// far plane, making it suitable for picking objects
// from the screen given a camera and a mouse location.
//
// Returns true if the point was acceptable, false
// otherwise.
////////////////////////////////////////////////////////////////////
bool CollisionSegment::
set_projection(ProjectionNode *camera, const LPoint2f &point) {
Projection *proj = camera->get_projection();
bool success = true;
LPoint3f origin;
LVector3f direction;
if (!proj->extrude(point, origin, direction)) {
origin = LPoint3f::origin();
direction = LVector3f::forward();
success = false;
}
_a = origin;
_b = origin + direction;
mark_bound_stale();
mark_viz_stale();
return success;
}
////////////////////////////////////////////////////////////////////
// Function: CollisionSegment::recompute_bound
// Access: Protected, Virtual

View File

@ -52,6 +52,9 @@ PUBLISHED:
INLINE void set_point_b(float x, float y, float z);
INLINE const LPoint3f &get_point_b() const;
bool set_projection(ProjectionNode *camera, const LPoint2f &point);
INLINE bool set_projection(ProjectionNode *camera, float px, float py);
protected:
virtual void recompute_bound();

View File

@ -9,7 +9,7 @@
#include <pandabase.h>
class EXPCL_PANDA MathNumbers {
public:
PUBLISHED:
static const double pi;
static const double ln2;
};

View File

@ -363,7 +363,7 @@ find_all_matches(const string &path) const {
// transforms exist in the scene graph.
//
// This is a handy function for tracking down mysterious
// "tried in invert a singular matrix" errors, which are
// "tried to invert a singular matrix" errors, which are
// almost always caused by zero-scale transform matrices
// in the scene graph.
////////////////////////////////////////////////////////////////////

View File

@ -9,7 +9,7 @@
#define SOURCES \
buttonThrower.cxx buttonThrower.h config_tform.cxx config_tform.h \
dataValve.I dataValve.cxx dataValve.h \
dataValve.I dataValve.cxx dataValve.h driveInterface.I \
driveInterface.cxx driveInterface.h mouseWatcher.I mouseWatcher.cxx \
mouseWatcher.h mouseWatcherRegion.I mouseWatcherRegion.cxx \
mouseWatcherRegion.h planarSlider.cxx planarSlider.h trackball.cxx \
@ -18,7 +18,7 @@
#define INSTALL_HEADERS \
buttonThrower.h dataValve.I dataValve.h \
driveInterface.h mouseWatcher.I mouseWatcher.h \
driveInterface.I driveInterface.h mouseWatcher.I mouseWatcher.h \
mouseWatcherRegion.I mouseWatcherRegion.h planarSlider.h \
trackball.h transform2sg.h

View File

@ -0,0 +1,490 @@
// Filename: driveInterface.I
// Created by: drose (12Feb01)
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_forward_speed
// Access: Published
// Description: Sets the speed of full forward motion, when the mouse
// is at the very top of the window. This is in units
// (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_forward_speed(float speed) {
_forward_speed = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_forward_speed
// Access: Published
// Description: Returns the speed of full forward motion, when the
// mouse is at the very top of the window. This is in
// units (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_forward_speed() const {
return _forward_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_reverse_speed
// Access: Published
// Description: Sets the speed of full reverse motion, when the mouse
// is at the very bottom of the window. This is in
// units (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_reverse_speed(float speed) {
_reverse_speed = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_reverse_speed
// Access: Published
// Description: Returns the speed of full reverse motion, when the
// mouse is at the very bottom of the window. This is
// in units (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_reverse_speed() const {
return _reverse_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_rotate_speed
// Access: Published
// Description: Sets the maximum rate at which the user can rotate
// left or right, when the mouse is at the very edge of
// the window. This is in degrees per second.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_rotate_speed(float speed) {
_rotate_speed = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_rotate_speed
// Access: Published
// Description: Returns the maximum rate at which the user can rotate
// left or right, when the mouse is at the very edge of
// the window. This is in degrees per second.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_rotate_speed() const {
return _rotate_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_vertical_dead_zone
// Access: Published
// Description: Sets the size of the horizontal bar in the center of
// the screen that represents the "dead zone" of
// vertical motion: the region in which the mouse does
// not report vertical motion. This is in a fraction of
// the window height, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_vertical_dead_zone(float speed) {
_vertical_dead_zone = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_vertical_dead_zone
// Access: Published
// Description: Returns the size of the horizontal bar in the center
// of the screen that represents the "dead zone" of
// vertical motion: the region in which the mouse does
// not report vertical motion. This is in a fraction of
// the window height, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_vertical_dead_zone() const {
return _vertical_dead_zone;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_horizontal_dead_zone
// Access: Published
// Description: Sets the size of the vertical bar in the center of
// the screen that represents the "dead zone" of
// horizontal motion: the region in which the mouse does
// not report horizontal motion. This is in a fraction of
// the window width, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_horizontal_dead_zone(float speed) {
_horizontal_dead_zone = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_horizontal_dead_zone
// Access: Published
// Description: Returns the size of the vertical bar in the center
// of the screen that represents the "dead zone" of
// horizontal motion: the region in which the mouse does
// not report horizontal motion. This is in a fraction of
// the window width, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_horizontal_dead_zone() const {
return _horizontal_dead_zone;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_vertical_ramp_up_time
// Access: Published
// Description: Sets the amount of time, in seconds, it takes between
// the time an up or down arrow key is pressed and the
// time it registers full forward or backward motion.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_vertical_ramp_up_time(float ramp_up_time) {
_vertical_ramp_up_time = ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_vertical_ramp_up_time
// Access: Published
// Description: Returns the amount of time, in seconds, it takes
// between the time an up or down arrow key is pressed
// and the time it registers full forward or backward
// motion.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_vertical_ramp_up_time() const {
return _vertical_ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_vertical_ramp_down_time
// Access: Published
// Description: Sets the amount of time, in seconds, it takes between
// the time an up or down arrow key is released and the
// time it registers no motion.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_vertical_ramp_down_time(float ramp_down_time) {
_vertical_ramp_down_time = ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_vertical_ramp_down_time
// Access: Published
// Description: Returns the amount of time, in seconds, it takes
// between the time an up or down arrow key is released
// and the time it registers no motion.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_vertical_ramp_down_time() const {
return _vertical_ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_horizontal_ramp_up_time
// Access: Published
// Description: Sets the amount of time, in seconds, it takes between
// the time a left or right arrow key is pressed and the
// time it registers full rotation.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_horizontal_ramp_up_time(float ramp_up_time) {
_horizontal_ramp_up_time = ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_horizontal_ramp_up_time
// Access: Published
// Description: Returns the amount of time, in seconds, it takes
// between the time a left or right arrow key is pressed
// and the time it registers full rotation.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_horizontal_ramp_up_time() const {
return _horizontal_ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_horizontal_ramp_down_time
// Access: Published
// Description: Sets the amount of time, in seconds, it takes between
// the time a left or right arrow key is released and the
// time it registers no motion.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_horizontal_ramp_down_time(float ramp_down_time) {
_horizontal_ramp_down_time = ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_horizontal_ramp_down_time
// Access: Published
// Description: Returns the amount of time, in seconds, it takes
// between the time a left or right arrow key is released
// and the time it registers no motion.
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_horizontal_ramp_down_time() const {
return _horizontal_ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_speed
// Access: Published
// Description: Returns the speed of the previous update in units/sec
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_speed() const {
return _speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_rot_speed
// Access: Published
// Description: Returns the rot_speed of the previous update in units/sec
////////////////////////////////////////////////////////////////////
INLINE float DriveInterface::
get_rot_speed() const {
return _rot_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_pos
// Access: Published
// Description: Returns the driver's position.
////////////////////////////////////////////////////////////////////
INLINE const LPoint3f &DriveInterface::
get_pos() const {
return _xyz;
}
INLINE float DriveInterface::
get_x() const {
return _xyz[0];
}
INLINE float DriveInterface::
get_y() const {
return _xyz[1];
}
INLINE float DriveInterface::
get_z() const {
return _xyz[2];
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_pos
// Access: Published
// Description: Directly sets the driver's position.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_pos(const LVecBase3f &vec) {
_xyz = vec;
recompute();
}
INLINE void DriveInterface::
set_pos(float x, float y, float z) {
_xyz.set(x, y, z);
recompute();
}
INLINE void DriveInterface::
set_x(float x) {
_xyz[0] = x;
recompute();
}
INLINE void DriveInterface::
set_y(float y) {
_xyz[1] = y;
recompute();
}
INLINE void DriveInterface::
set_z(float z) {
_xyz[2] = z;
recompute();
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_hpr
// Access: Published
// Description: Returns the driver's orientation.
////////////////////////////////////////////////////////////////////
INLINE const LVecBase3f &DriveInterface::
get_hpr() const {
return _hpr;
}
INLINE float DriveInterface::
get_h() const {
return _hpr[0];
}
INLINE float DriveInterface::
get_p() const {
return _hpr[1];
}
INLINE float DriveInterface::
get_r() const {
return _hpr[2];
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_hpr
// Access: Published
// Description: Directly sets the driver's orientation.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_hpr(const LVecBase3f &hpr) {
_hpr = hpr;
recompute();
}
INLINE void DriveInterface::
set_hpr(float h, float p, float r) {
_hpr.set(h, p, r);
recompute();
if (_is_force_roll && r != _force_roll) {
reextract();
}
}
INLINE void DriveInterface::
set_h(float h) {
_hpr[0] = h;
recompute();
}
INLINE void DriveInterface::
set_p(float p) {
_hpr[1] = p;
recompute();
}
INLINE void DriveInterface::
set_r(float r) {
_hpr[2] = r;
recompute();
if (_is_force_roll && r != _force_roll) {
reextract();
}
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::is_force_roll
// Access: Published
// Description: Returns true if the force_roll state is in effect,
// e.g. because of a previous call to set_force_roll().
// In this state, the roll cannot be set to any value
// other than what the force_roll value indicates.
////////////////////////////////////////////////////////////////////
INLINE bool DriveInterface::
is_force_roll() const {
return _is_force_roll;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::clear_force_roll
// Access: Published
// Description: Disables the force_roll state. See set_force_roll().
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
clear_force_roll() {
_is_force_roll = false;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_coordinate_system
// Access: Published
// Description: Sets the coordinate system of the DriveInterface.
// Normally, this is the default coordinate system.
// This changes the plane the user drives around in;
// it's normally the horizontal plane (e.g. the X-Y
// plane in a Z-up coordinate system, or the X-Z plane
// in a Y-up coordinate system).
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_coordinate_system(CoordinateSystem cs) {
_cs = cs;
recompute();
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_coordinate_system
// Access: Published
// Description: Returns the coordinate system of the DriveInterface.
// See set_coordinate_system().
////////////////////////////////////////////////////////////////////
INLINE CoordinateSystem DriveInterface::
get_coordinate_system() const {
return _cs;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_ignore_mouse
// Access: Published
// Description: Changes the state of the ignore_mouse flag. If this
// flag is true, the DriveInterface will ignore mouse
// down button events (but still recognize mouse up
// button events); the user will not be able to start
// the DriveInterface going again if it is stopped, but
// if the user is currently holding down a mouse button
// it will not stop immediately until the user
// eventually releases the button.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_ignore_mouse(bool ignore_mouse) {
_ignore_mouse = ignore_mouse;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_ignore_mouse
// Access: Published
// Description: Returns the current setting of the ignore_mouse flag.
// See set_ignore_mouse().
////////////////////////////////////////////////////////////////////
INLINE bool DriveInterface::
get_ignore_mouse() const {
return _ignore_mouse;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_mat
// Access: Published
// Description: Stores the indicated transform in the driveInterface.
// This is a transform in global space, regardless of
// the rel_to node.
////////////////////////////////////////////////////////////////////
INLINE void DriveInterface::
set_mat(const LMatrix4f &mat) {
_mat = mat;
reextract();
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_mat
// Access: Published
// Description: Fills mat with the net transformation applied by the
// current state.
////////////////////////////////////////////////////////////////////
INLINE const LMatrix4f &DriveInterface::
get_mat() const {
return _mat;
}

View File

@ -93,7 +93,7 @@ operator < (const DriveInterface::KeyHeld &other) const {
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::Constructor
// Access: Public, Scheme
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
DriveInterface::
@ -121,6 +121,7 @@ DriveInterface(const string &name) : DataNode(name) {
_is_force_roll = true;
_cs = default_coordinate_system;
_ignore_mouse = false;
_mods.add_button(MouseButton::one());
_mods.add_button(MouseButton::two());
@ -135,265 +136,16 @@ DriveInterface(const string &name) : DataNode(name) {
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::Destructor
// Access: Public, Scheme
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
DriveInterface::
~DriveInterface() {
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_forward_speed
// Access: Public, Scheme
// Description: Sets the speed of full forward motion, when the mouse
// is at the very top of the window. This is in units
// (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_forward_speed(float speed) {
_forward_speed = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_forward_speed
// Access: Public, Scheme
// Description: Returns the speed of full forward motion, when the
// mouse is at the very top of the window. This is in
// units (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_forward_speed() const {
return _forward_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_reverse_speed
// Access: Public, Scheme
// Description: Sets the speed of full reverse motion, when the mouse
// is at the very bottom of the window. This is in
// units (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_reverse_speed(float speed) {
_reverse_speed = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_reverse_speed
// Access: Public, Scheme
// Description: Returns the speed of full reverse motion, when the
// mouse is at the very bottom of the window. This is
// in units (e.g. feet) per second.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_reverse_speed() const {
return _reverse_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_rotate_speed
// Access: Public, Scheme
// Description: Sets the maximum rate at which the user can rotate
// left or right, when the mouse is at the very edge of
// the window. This is in degrees per second.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_rotate_speed(float speed) {
_rotate_speed = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_rotate_speed
// Access: Public, Scheme
// Description: Returns the maximum rate at which the user can rotate
// left or right, when the mouse is at the very edge of
// the window. This is in degrees per second.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_rotate_speed() const {
return _rotate_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_vertical_dead_zone
// Access: Public, Scheme
// Description: Sets the size of the horizontal bar in the center of
// the screen that represents the "dead zone" of
// vertical motion: the region in which the mouse does
// not report vertical motion. This is in a fraction of
// the window height, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_vertical_dead_zone(float speed) {
_vertical_dead_zone = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_vertical_dead_zone
// Access: Public, Scheme
// Description: Returns the size of the horizontal bar in the center
// of the screen that represents the "dead zone" of
// vertical motion: the region in which the mouse does
// not report vertical motion. This is in a fraction of
// the window height, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_vertical_dead_zone() const {
return _vertical_dead_zone;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_horizontal_dead_zone
// Access: Public, Scheme
// Description: Sets the size of the vertical bar in the center of
// the screen that represents the "dead zone" of
// horizontal motion: the region in which the mouse does
// not report horizontal motion. This is in a fraction of
// the window width, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_horizontal_dead_zone(float speed) {
_horizontal_dead_zone = speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_horizontal_dead_zone
// Access: Public, Scheme
// Description: Returns the size of the vertical bar in the center
// of the screen that represents the "dead zone" of
// horizontal motion: the region in which the mouse does
// not report horizontal motion. This is in a fraction of
// the window width, so 0.5 will set a dead zone as
// large as half the screen.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_horizontal_dead_zone() const {
return _horizontal_dead_zone;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_vertical_ramp_up_time
// Access: Public, Scheme
// Description: Sets the amount of time, in seconds, it takes between
// the time an up or down arrow key is pressed and the
// time it registers full forward or backward motion.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_vertical_ramp_up_time(float ramp_up_time) {
_vertical_ramp_up_time = ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_vertical_ramp_up_time
// Access: Public, Scheme
// Description: Returns the amount of time, in seconds, it takes
// between the time an up or down arrow key is pressed
// and the time it registers full forward or backward
// motion.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_vertical_ramp_up_time() const {
return _vertical_ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_vertical_ramp_down_time
// Access: Public, Scheme
// Description: Sets the amount of time, in seconds, it takes between
// the time an up or down arrow key is released and the
// time it registers no motion.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_vertical_ramp_down_time(float ramp_down_time) {
_vertical_ramp_down_time = ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_vertical_ramp_down_time
// Access: Public, Scheme
// Description: Returns the amount of time, in seconds, it takes
// between the time an up or down arrow key is released
// and the time it registers no motion.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_vertical_ramp_down_time() const {
return _vertical_ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_horizontal_ramp_up_time
// Access: Public, Scheme
// Description: Sets the amount of time, in seconds, it takes between
// the time a left or right arrow key is pressed and the
// time it registers full rotation.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_horizontal_ramp_up_time(float ramp_up_time) {
_horizontal_ramp_up_time = ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_horizontal_ramp_up_time
// Access: Public, Scheme
// Description: Returns the amount of time, in seconds, it takes
// between the time a left or right arrow key is pressed
// and the time it registers full rotation.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_horizontal_ramp_up_time() const {
return _horizontal_ramp_up_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_horizontal_ramp_down_time
// Access: Public, Scheme
// Description: Sets the amount of time, in seconds, it takes between
// the time a left or right arrow key is released and the
// time it registers no motion.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_horizontal_ramp_down_time(float ramp_down_time) {
_horizontal_ramp_down_time = ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_horizontal_ramp_down_time
// Access: Public, Scheme
// Description: Returns the amount of time, in seconds, it takes
// between the time a left or right arrow key is released
// and the time it registers no motion.
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_horizontal_ramp_down_time() const {
return _horizontal_ramp_down_time;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_speed
// Access: Public, Scheme
// Description: Returns the speed of the previous update in units/sec
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_speed() const {
return _speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_rot_speed
// Access: Public, Scheme
// Description: Returns the rot_speed of the previous update in units/sec
////////////////////////////////////////////////////////////////////
float DriveInterface::
get_rot_speed() const {
return _rot_speed;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::reset
// Access: Public, Scheme
// Access: Published
// Description: Reinitializes the driver to the origin.
////////////////////////////////////////////////////////////////////
void DriveInterface::
@ -409,140 +161,9 @@ reset() {
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_pos
// Access: Public, Scheme
// Description: Returns the driver's position.
////////////////////////////////////////////////////////////////////
const LPoint3f &DriveInterface::
get_pos() const {
return _xyz;
}
float DriveInterface::
get_x() const {
return _xyz[0];
}
float DriveInterface::
get_y() const {
return _xyz[1];
}
float DriveInterface::
get_z() const {
return _xyz[2];
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_pos
// Access: Public, Scheme
// Description: Directly sets the driver's position.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_pos(const LVecBase3f &vec) {
_xyz = vec;
recompute();
}
void DriveInterface::
set_pos(float x, float y, float z) {
_xyz.set(x, y, z);
recompute();
}
void DriveInterface::
set_x(float x) {
_xyz[0] = x;
recompute();
}
void DriveInterface::
set_y(float y) {
_xyz[1] = y;
recompute();
}
void DriveInterface::
set_z(float z) {
_xyz[2] = z;
recompute();
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_hpr
// Access: Public, Scheme
// Description: Returns the driver's orientation.
////////////////////////////////////////////////////////////////////
const LVecBase3f &DriveInterface::
get_hpr() const {
return _hpr;
}
float DriveInterface::
get_h() const {
return _hpr[0];
}
float DriveInterface::
get_p() const {
return _hpr[1];
}
float DriveInterface::
get_r() const {
return _hpr[2];
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_hpr
// Access: Public, Scheme
// Description: Directly sets the driver's orientation.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_hpr(const LVecBase3f &hpr) {
_hpr = hpr;
recompute();
}
void DriveInterface::
set_hpr(float h, float p, float r) {
_hpr.set(h, p, r);
recompute();
if (_is_force_roll && r != _force_roll) {
reextract();
}
}
void DriveInterface::
set_h(float h) {
_hpr[0] = h;
recompute();
}
void DriveInterface::
set_p(float p) {
_hpr[1] = p;
recompute();
}
void DriveInterface::
set_r(float r) {
_hpr[2] = r;
recompute();
if (_is_force_roll && r != _force_roll) {
reextract();
}
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_force_roll
// Access: Public, Scheme
// Access: Published
// Description: Sets the force_roll state. In this state, roll is
// always fixed to a particular value (typically zero),
// regardless of what it is explicitly set to via
@ -564,82 +185,6 @@ set_force_roll(float force_roll) {
}
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::is_force_roll
// Access: Public, Scheme
// Description: Returns true if the force_roll state is in effect,
// e.g. because of a previous call to set_force_roll().
// In this state, the roll cannot be set to any value
// other than what the force_roll value indicates.
////////////////////////////////////////////////////////////////////
bool DriveInterface::
is_force_roll() const {
return _is_force_roll;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::clear_force_roll
// Access: Public, Scheme
// Description: Disables the force_roll state. See set_force_roll().
////////////////////////////////////////////////////////////////////
void DriveInterface::
clear_force_roll() {
_is_force_roll = false;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_coordinate_system
// Access: Public, Scheme
// Description: Sets the coordinate system of the DriveInterface.
// Normally, this is the default coordinate system.
// This changes the plane the user drives around in;
// it's normally the horizontal plane (e.g. the X-Y
// plane in a Z-up coordinate system, or the X-Z plane
// in a Y-up coordinate system).
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_coordinate_system(CoordinateSystem cs) {
_cs = cs;
recompute();
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_coordinate_system
// Access: Public, Scheme
// Description: Returns the coordinate system of the DriveInterface.
// See set_coordinate_system().
////////////////////////////////////////////////////////////////////
CoordinateSystem DriveInterface::
get_coordinate_system() const {
return _cs;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::set_mat
// Access: Public, Scheme
// Description: Stores the indicated transform in the driveInterface.
// This is a transform in global space, regardless of
// the rel_to node.
////////////////////////////////////////////////////////////////////
void DriveInterface::
set_mat(const LMatrix4f &mat) {
_mat = mat;
reextract();
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::get_mat
// Access: Public, Scheme
// Description: Fills mat with the net transformation applied by the
// current state.
////////////////////////////////////////////////////////////////////
const LMatrix4f &DriveInterface::
get_mat() const {
return _mat;
}
////////////////////////////////////////////////////////////////////
// Function: DriveInterface::force_dgraph
// Access: Public
@ -854,7 +399,9 @@ transmit_data(NodeAttributes &data) {
ButtonEventDataAttribute::const_iterator bi;
for (bi = b->begin(); bi != b->end(); ++bi) {
const ButtonEvent &be = (*bi);
_mods.add_event(be);
if (!(_ignore_mouse && be._down)) {
_mods.add_event(be);
}
if (be._button == KeyboardButton::up()) {
_up_arrow.set_key(be._down);

View File

@ -31,61 +31,64 @@ PUBLISHED:
DriveInterface(const string &name = "");
~DriveInterface();
void set_forward_speed(float speed);
float get_forward_speed() const;
void set_reverse_speed(float speed);
float get_reverse_speed() const;
void set_rotate_speed(float speed);
float get_rotate_speed() const;
void set_vertical_dead_zone(float zone);
float get_vertical_dead_zone() const;
void set_horizontal_dead_zone(float zone);
float get_horizontal_dead_zone() const;
INLINE void set_forward_speed(float speed);
INLINE float get_forward_speed() const;
INLINE void set_reverse_speed(float speed);
INLINE float get_reverse_speed() const;
INLINE void set_rotate_speed(float speed);
INLINE float get_rotate_speed() const;
INLINE void set_vertical_dead_zone(float zone);
INLINE float get_vertical_dead_zone() const;
INLINE void set_horizontal_dead_zone(float zone);
INLINE float get_horizontal_dead_zone() const;
void set_vertical_ramp_up_time(float ramp_up_time);
float get_vertical_ramp_up_time() const;
void set_vertical_ramp_down_time(float ramp_down_time);
float get_vertical_ramp_down_time() const;
void set_horizontal_ramp_up_time(float ramp_up_time);
float get_horizontal_ramp_up_time() const;
void set_horizontal_ramp_down_time(float ramp_down_time);
float get_horizontal_ramp_down_time() const;
INLINE void set_vertical_ramp_up_time(float ramp_up_time);
INLINE float get_vertical_ramp_up_time() const;
INLINE void set_vertical_ramp_down_time(float ramp_down_time);
INLINE float get_vertical_ramp_down_time() const;
INLINE void set_horizontal_ramp_up_time(float ramp_up_time);
INLINE float get_horizontal_ramp_up_time() const;
INLINE void set_horizontal_ramp_down_time(float ramp_down_time);
INLINE float get_horizontal_ramp_down_time() const;
float get_speed() const;
float get_rot_speed() const;
INLINE float get_speed() const;
INLINE float get_rot_speed() const;
void reset();
/// **** Translation ****
const LPoint3f &get_pos() const;
float get_x() const;
float get_y() const;
float get_z() const;
void set_pos(const LVecBase3f &vec);
void set_pos(float x, float y, float z);
void set_x(float x);
void set_y(float y);
void set_z(float z);
INLINE const LPoint3f &get_pos() const;
INLINE float get_x() const;
INLINE float get_y() const;
INLINE float get_z() const;
INLINE void set_pos(const LVecBase3f &vec);
INLINE void set_pos(float x, float y, float z);
INLINE void set_x(float x);
INLINE void set_y(float y);
INLINE void set_z(float z);
/// **** Rotation ****
const LVecBase3f &get_hpr() const;
float get_h() const;
float get_p() const;
float get_r() const;
void set_hpr(const LVecBase3f &hpr);
void set_hpr(float h, float p, float r);
void set_h(float h);
void set_p(float p);
void set_r(float r);
INLINE const LVecBase3f &get_hpr() const;
INLINE float get_h() const;
INLINE float get_p() const;
INLINE float get_r() const;
INLINE void set_hpr(const LVecBase3f &hpr);
INLINE void set_hpr(float h, float p, float r);
INLINE void set_h(float h);
INLINE void set_p(float p);
INLINE void set_r(float r);
void set_force_roll(float force_roll);
bool is_force_roll() const;
void clear_force_roll();
INLINE bool is_force_roll() const;
INLINE void clear_force_roll();
void set_coordinate_system(CoordinateSystem cs);
CoordinateSystem get_coordinate_system() const;
INLINE void set_coordinate_system(CoordinateSystem cs);
INLINE CoordinateSystem get_coordinate_system() const;
INLINE void set_ignore_mouse(bool ignore_mouse);
INLINE bool get_ignore_mouse() const;
void set_mat(const LMatrix4f &mat);
const LMatrix4f &get_mat() const;
@ -122,6 +125,7 @@ private:
float _force_roll;
bool _is_force_roll;
CoordinateSystem _cs;
bool _ignore_mouse;
// Remember which mouse buttons are being held down.
ModifierButtons _mods;
@ -177,4 +181,6 @@ private:
static TypeHandle _type_handle;
};
#include "driveInterface.I"
#endif