00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef DRIVEINTERFACE_H
00020 #define DRIVEINTERFACE_H
00021
00022 #include "pandabase.h"
00023
00024 #include "dataNode.h"
00025 #include "modifierButtons.h"
00026 #include "luse.h"
00027 #include "linmath_events.h"
00028 #include "transformState.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class EXPCL_PANDA DriveInterface : public DataNode {
00039 PUBLISHED:
00040 DriveInterface(const string &name = "");
00041 ~DriveInterface();
00042
00043 INLINE void set_forward_speed(float speed);
00044 INLINE float get_forward_speed() const;
00045 INLINE void set_reverse_speed(float speed);
00046 INLINE float get_reverse_speed() const;
00047 INLINE void set_rotate_speed(float speed);
00048 INLINE float get_rotate_speed() const;
00049 INLINE void set_vertical_dead_zone(float zone);
00050 INLINE float get_vertical_dead_zone() const;
00051 INLINE void set_horizontal_dead_zone(float zone);
00052 INLINE float get_horizontal_dead_zone() const;
00053
00054 INLINE void set_vertical_ramp_up_time(float ramp_up_time);
00055 INLINE float get_vertical_ramp_up_time() const;
00056 INLINE void set_vertical_ramp_down_time(float ramp_down_time);
00057 INLINE float get_vertical_ramp_down_time() const;
00058 INLINE void set_horizontal_ramp_up_time(float ramp_up_time);
00059 INLINE float get_horizontal_ramp_up_time() const;
00060 INLINE void set_horizontal_ramp_down_time(float ramp_down_time);
00061 INLINE float get_horizontal_ramp_down_time() const;
00062
00063 INLINE float get_speed() const;
00064 INLINE float get_rot_speed() const;
00065
00066 void reset();
00067
00068
00069
00070 INLINE const LPoint3f &get_pos() const;
00071 INLINE float get_x() const;
00072 INLINE float get_y() const;
00073 INLINE float get_z() const;
00074 INLINE void set_pos(const LVecBase3f &vec);
00075 INLINE void set_pos(float x, float y, float z);
00076 INLINE void set_x(float x);
00077 INLINE void set_y(float y);
00078 INLINE void set_z(float z);
00079
00080
00081
00082 INLINE const LVecBase3f &get_hpr() const;
00083 INLINE float get_h() const;
00084 INLINE float get_p() const;
00085 INLINE float get_r() const;
00086 INLINE void set_hpr(const LVecBase3f &hpr);
00087 INLINE void set_hpr(float h, float p, float r);
00088 INLINE void set_h(float h);
00089 INLINE void set_p(float p);
00090 INLINE void set_r(float r);
00091
00092 void set_force_roll(float force_roll);
00093
00094 INLINE void set_ignore_mouse(bool ignore_mouse);
00095 INLINE bool get_ignore_mouse() const;
00096
00097 INLINE void set_force_mouse(bool force_mouse);
00098 INLINE bool get_force_mouse() const;
00099
00100 INLINE void set_stop_this_frame(bool stop_this_frame);
00101 INLINE bool get_stop_this_frame() const;
00102
00103 void set_mat(const LMatrix4f &mat);
00104 const LMatrix4f &get_mat();
00105
00106 void force_dgraph();
00107
00108 private:
00109 void apply(double x, double y, bool any_button);
00110
00111 float _forward_speed;
00112 float _reverse_speed;
00113 float _rotate_speed;
00114 float _vertical_dead_zone;
00115 float _horizontal_dead_zone;
00116 float _vertical_center;
00117 float _horizontal_center;
00118
00119
00120
00121 float _vertical_ramp_up_time;
00122 float _vertical_ramp_down_time;
00123 float _horizontal_ramp_up_time;
00124 float _horizontal_ramp_down_time;
00125
00126 float _speed;
00127 float _rot_speed;
00128
00129 LPoint3f _xyz;
00130 LVecBase3f _hpr;
00131 LVector3f _vel;
00132 bool _ignore_mouse;
00133 bool _force_mouse;
00134 bool _stop_this_frame;
00135
00136
00137 LMatrix4f _mat;
00138
00139
00140 ModifierButtons _mods;
00141
00142
00143
00144 class KeyHeld {
00145 public:
00146 KeyHeld();
00147 float get_effect(float ramp_up_time, float ramp_down_time);
00148 void set_key(bool down);
00149 void clear();
00150 bool operator < (const KeyHeld &other) const;
00151
00152 float _effect;
00153 bool _down;
00154 double _changed_time;
00155 float _effect_at_change;
00156 };
00157 KeyHeld _up_arrow, _down_arrow;
00158 KeyHeld _left_arrow, _right_arrow;
00159
00160
00161 protected:
00162
00163 virtual void do_transmit_data(const DataNodeTransmit &input,
00164 DataNodeTransmit &output);
00165
00166 private:
00167
00168 int _xy_input;
00169 int _button_events_input;
00170
00171
00172 int _transform_output;
00173 int _velocity_output;
00174
00175 PT(EventStoreTransform) _transform;
00176 PT(EventStoreVec3) _velocity;
00177
00178
00179
00180
00181
00182
00183 static const float _hpr_quantize;
00184
00185 public:
00186 static TypeHandle get_class_type() {
00187 return _type_handle;
00188 }
00189 static void init_type() {
00190 DataNode::init_type();
00191 register_type(_type_handle, "DriveInterface",
00192 DataNode::get_class_type());
00193 }
00194 virtual TypeHandle get_type() const {
00195 return get_class_type();
00196 }
00197 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00198
00199 private:
00200 static TypeHandle _type_handle;
00201 };
00202
00203 #include "driveInterface.I"
00204
00205 #endif