00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TRACKBALL_H
00020 #define TRACKBALL_H
00021
00022 #include "pandabase.h"
00023
00024 #include "dataNode.h"
00025 #include "nodePath.h"
00026 #include "modifierButtons.h"
00027 #include "luse.h"
00028 #include "transformState.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class EXPCL_PANDA Trackball : public DataNode {
00045 PUBLISHED:
00046 Trackball(const string &name);
00047 ~Trackball();
00048
00049 void reset();
00050
00051 float get_forward_scale() const;
00052 void set_forward_scale(float fwdscale);
00053
00054
00055
00056 const LPoint3f &get_pos() const;
00057 float get_x() const;
00058 float get_y() const;
00059 float get_z() const;
00060 void set_pos(const LVecBase3f &vec);
00061 void set_pos(float x, float y, float z);
00062 void set_x(float x);
00063 void set_y(float y);
00064 void set_z(float z);
00065
00066
00067
00068 LVecBase3f get_hpr() const;
00069 float get_h() const;
00070 float get_p() const;
00071 float get_r() const;
00072 void set_hpr(const LVecBase3f &hpr);
00073 void set_hpr(float h, float p, float r);
00074 void set_h(float h);
00075 void set_p(float p);
00076 void set_r(float r);
00077
00078
00079
00080 void reset_origin_here();
00081 void move_origin(float x, float y, float z);
00082
00083 LPoint3f get_origin() const;
00084 void set_origin(const LVecBase3f &origin);
00085
00086
00087
00088 void set_invert(bool flag);
00089 bool get_invert() const;
00090
00091 void set_rel_to(const NodePath &_rel_to);
00092 const NodePath &get_rel_to() const;
00093
00094 void set_coordinate_system(CoordinateSystem cs);
00095 CoordinateSystem get_coordinate_system() const;
00096
00097 void set_mat(const LMatrix4f &mat);
00098 const LMatrix4f &get_mat() const;
00099 const LMatrix4f &get_trans_mat() const;
00100
00101
00102 private:
00103 void apply(double x, double y, int button);
00104
00105 void reextract();
00106 void recompute();
00107
00108
00109 float _lastx, _lasty;
00110
00111 float _rotscale;
00112 float _fwdscale;
00113
00114 LMatrix4f _rotation;
00115 LPoint3f _translation;
00116 LMatrix4f _mat, _orig;
00117 bool _invert;
00118 NodePath _rel_to;
00119 CoordinateSystem _cs;
00120
00121
00122 ModifierButtons _mods;
00123
00124
00125 protected:
00126
00127 virtual void do_transmit_data(const DataNodeTransmit &input,
00128 DataNodeTransmit &output);
00129
00130 private:
00131
00132 int _pixel_xy_input;
00133 int _button_events_input;
00134
00135
00136 int _transform_output;
00137
00138 PT(EventStoreTransform) _transform;
00139
00140 public:
00141 static TypeHandle get_class_type() {
00142 return _type_handle;
00143 }
00144 static void init_type() {
00145 DataNode::init_type();
00146 register_type(_type_handle, "Trackball",
00147 DataNode::get_class_type());
00148 }
00149 virtual TypeHandle get_type() const {
00150 return get_class_type();
00151 }
00152 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00153
00154 private:
00155 static TypeHandle _type_handle;
00156 };
00157
00158 #endif