00001 #ifndef CAM_FOCUS_H_IS_INCLUDED
00002 #define CAM_FOCUS_H_IS_INCLUDED
00003
00004 #include "disp/view.H"
00005
00006
00007
00008
00009
00010
00011 MAKE_PTR_SUBC(CamFocus, FRAMEobs);
00012 class CamFocus : public FRAMEobs {
00013 public :
00014
00015 CamFocus(VIEWptr v, CCAMptr &dest);
00016 CamFocus(VIEWptr v, mlib::CWpt& from, mlib::CWpt& at, mlib::CWpt& up,
00017 mlib::CWpt& center, double fw=0, double fh=0);
00018
00019 virtual ~CamFocus();
00020
00021
00022 VIEWptr view() const { return _view; }
00023 CAMptr cam() const { return _cam; }
00024
00025
00026
00027 static void cancel_cur();
00028
00029
00030 virtual int tick(void);
00031
00032 protected:
00033
00034 VIEWptr _view;
00035 CAMptr _cam;
00036
00037 double _width;
00038 double _height;
00039
00040 double _orig_time;
00041 double _last_time;
00042 double _duration;
00043
00044 double _speed;
00045 double _max_speed;
00046
00047
00048 mlib::Wpt _o1;
00049 mlib::Wpt _a1;
00050 mlib::Wvec _u1;
00051 mlib::Wpt _c1;
00052
00053
00054 mlib::Wpt _o2;
00055 mlib::Wpt _a2;
00056 mlib::Wvec _u2;
00057 mlib::Wpt _c2;
00058
00059
00060
00061 static CamFocusptr _cur;
00062
00063
00064
00065
00066 void schedule() {
00067 if (view()) {
00068 view()->save_cam();
00069 view()->schedule(this);
00070 }
00071 }
00072
00073
00074 void unschedule() {
00075 if (view())
00076 view()->unschedule(this);
00077 }
00078
00079 void set_cur(CamFocus* cf);
00080
00081
00082 double cur_time() const { return VIEW::peek()->frame_time(); }
00083 double elapsed_time() const { return cur_time() - _orig_time; }
00084 double t_param() const {
00085
00086
00087 return clamp(elapsed_time()/_duration, 0.0, 1.0);
00088 }
00089 double cartoon_t() const;
00090
00091
00092
00093 void setup(
00094 mlib::CWpt& o2, mlib::CWpt& a2, mlib::CWvec& u2, mlib::CWpt& c2
00095 );
00096 };
00097
00098
00099
00100
00101
00102
00103 MAKE_PTR_SUBC(CamBreathe, FRAMEobs);
00104 class CamBreathe : public FRAMEobs {
00105 protected:
00106 CAMptr _cam;
00107 mlib::Wpt _from;
00108 mlib::Wpt _at;
00109 mlib::Wpt _up;
00110 mlib::Wpt _cent;
00111 double _width,_height;
00112 double _min, _Kf, _Kc, _Ku;
00113 double _speed;
00114 static double _size;
00115 double _tick;
00116 bool _stop;
00117 bool _pause;
00118 const double kKf, kKc, kKu;
00119 static CamBreatheptr _breathe;
00120
00121 public :
00122 virtual ~CamBreathe();
00123 CamBreathe(CAMptr &p);
00124
00125
00126 virtual int tick(void);
00127 virtual void stop() { _stop = true; }
00128 virtual void pause() { _pause = true; }
00129 virtual void unpause(){ _pause = false; }
00130 virtual void set_speed(double s) {_speed = s; }
00131 static void grow(double s) { _size += s; }
00132
00133 virtual bool stopped() { return _stop; }
00134
00135 static CamBreatheptr &cur() { return _breathe; }
00136 };
00137
00138
00139
00140
00141
00142
00143 MAKE_PTR_SUBC(CamOrbit, FRAMEobs);
00144 class CamOrbit : public FRAMEobs {
00145 protected:
00146 CAMptr _cam;
00147 mlib::Wpt _from, _at,_up,_cent;
00148 double _width,_height;
00149 double _min;
00150 double _speed;
00151 double _tick;
00152 bool _pause;
00153 bool _stop;
00154 mlib::XYpt tp;
00155 mlib::XYpt te;
00156 static CamOrbitptr _orbit;
00157
00158 public :
00159 virtual ~CamOrbit();
00160 CamOrbit(CAMptr &p, mlib::Wpt center);
00161
00162
00163 virtual int tick(void);
00164 virtual void pause() { _pause = true; }
00165 virtual void unpause(){ _pause = false; }
00166 virtual void stop() { _stop = true; }
00167 virtual void set_target(mlib::Wpt p) { _cent = p;}
00168
00169 virtual void set_orbit(mlib::XYpt o, mlib::XYpt e)
00170 {
00171 _pause = false;
00172 tp = o;
00173 te = e;
00174 }
00175
00176 virtual bool stopped() { return _stop; }
00177 static CamOrbitptr &cur() { return _orbit; }
00178 };
00179
00180
00181
00182
00183
00184
00185 MAKE_PTR_SUBC(CamCruise, FRAMEobs);
00186 class CamCruise : public FRAMEobs {
00187 protected:
00188 CAMptr _cam;
00189 double _t;
00190 mlib::Wpt _from, _at,_up,_cent;
00191 double _width,_height;
00192 double _min;
00193 double _speed;
00194 double _tick;
00195 static double _size;
00196 bool _pause;
00197 bool _stop;
00198 bool _target;
00199 bool _travel;
00200 mlib::Wpt _start;
00201 mlib::Wpt _dest;
00202 mlib::XYpt _scale_pt;
00203 mlib::Wpt _down_pt;
00204 mlib::XYpt tp;
00205 mlib::XYpt te;
00206
00207 stop_watch _clock;
00208 static CamCruiseptr _cruise;
00209
00210 public :
00211 virtual ~CamCruise();
00212 CamCruise(CAMptr &p, mlib::Wpt center);
00213
00214
00215 virtual int tick(void);
00216 virtual void pause() { _pause = true; }
00217 virtual void unpause(){ _pause = false; }
00218 virtual void stop() { _stop = true; }
00219 virtual void speed(double i) { _speed = i; }
00220 static void grow(double s) { _size += s; }
00221
00222
00223 virtual void travel(mlib::Wpt p);
00224 virtual void set_cruise(mlib::XYpt o, mlib::XYpt e);
00225
00226
00227 virtual void set_scale_pt(mlib::XYpt s) { _scale_pt = s; }
00228 virtual void set_down_pt(mlib::Wpt d) { _down_pt = d; }
00229
00230 virtual double get_speed() {return _speed;}
00231 virtual bool stopped() { return _stop; }
00232 static CamCruiseptr &cur() { return _cruise; }
00233 };
00234
00235 #endif // CAM_FOCUS_H_IS_INCLUDED
00236
00237