00001
00024 #ifndef _CAMERA_H_
00025 #define _CAMERA_H_
00026
00027 #include <stdio.h>
00028
00029 #include <stream.h>
00030
00031
00032 #include "vuDVector.h"
00033 #include "vuHWTimer.h"
00034 #include "vuSimpleTypes.h"
00035 #include "vuVector.h"
00036 #include "vuMisc/vuRay.h"
00037
00039
00046 class vuCamera
00047 {
00048 public:
00049
00050 enum vuCameraType {
00051 vuGENERIC_CAMERA,
00052 vuPARALLEL_CAMERA,
00053 vuPERSPECTIVE_CAMERA,
00054 };
00055
00056 virtual vuCameraType getType(void) {
00057 return vuGENERIC_CAMERA;
00058 }
00059
00060 public:
00062 vuCamera();
00068 vuCamera(const vuCamera& c);
00070 virtual ~vuCamera();
00071
00072 virtual void init(void) {};
00073 virtual vuRay getRay(float xpixel, float ypixel) {
00074 return vuRay();
00075 };
00076
00078 virtual vuCamera& operator=(const vuCamera& rhs);
00079
00081 void setPosition(const vuVector& pos);
00083 vuVector getPosition(void) const;
00085 void setUpVector(const vuVector& up);
00087 vuVector getUpVector(void) const;
00089 void setLookAtVector(const vuVector& lookat);
00091 vuVector getLookAtVector(void) const;
00092
00094 void setRightVector (const vuVector &right);
00096 vuVector getRightVector(void) const;
00097
00099 void gluLookAt(void);
00100
00101 virtual void glInit(void) {};
00102
00104 virtual void glViewport();
00105
00106 int getWidth(void) const;
00107 void setWidth(const int width);
00108
00109 int getHeight(void) const;
00110 void setHeight(const int height);
00111
00112
00114
00117 void rotateAboutUp(float theta);
00119 void rotateAboutLookAt(float theta);
00121 void rotateAboutRight(float theta);
00123 void translateV(const vuVector& t);
00125 void translateXYZ(float x, float y, float z);
00127 void transform(const vuMatrix &m);
00129 vuMatrix getViewMat();
00130
00131 public:
00132
00133
00135
00167 bool record (const char* record_to);
00168
00170 void TakeSnapShotBasic (char* Shot);
00171
00177 virtual void TakeSnapShot ();
00178
00181 virtual void TakeSnapShot (char* Shot);
00182
00184 int RestoreShotBasic (char* Shot);
00185
00188 virtual int RestoreShot (char* Shot);
00189
00198 virtual int RestoreNextShot ();
00208 virtual int RestorePreviousShot ();
00213 void stop_recording ();
00215
00220
00221
00223
00255 bool load (char* load_from);
00256
00260 void clear_lines ();
00261
00266 virtual bool verify_id (char* id);
00272 virtual char* get_id ();
00273
00275 friend ostream& operator<<(ostream& out, vuCamera &cam);
00276
00278 friend istream& operator>>(istream& in, vuCamera &cam);
00279
00286 bool IsNextAvailable ();
00287
00294 bool IsPreviousAvailable ();
00295
00298 bool IsRecording ();
00299
00304 virtual bool load_cameras (vuDVector <vuCamera> &vect, char *fname);
00305
00314 friend bool record_with_time (char* record_to, vuCamera &cam);
00315
00324 friend bool stop_recording (vuCamera &cam);
00325
00338 friend bool TakeSnapShotWithTime (float time, vuCamera &cam);
00339
00348 friend bool load_WithTime (char* load_from, vuCamera *cam, vuDVector <vuCamera*> &cameras, vuDVector <float> ×);
00349
00350 public:
00351
00357 char* getWithTime_id ();
00358
00363 bool verify_time_id (char* cmp);
00364
00368 virtual vuCamera* create_new ();
00369
00370 virtual vuCamera* set_equal_to_interp (vuCamera* cam1, vuCamera* cam2, float t1, float t2);
00371
00372
00373
00374
00375
00376
00377 public:
00378
00379
00380
00381
00382
00389 virtual vuCamera* operator* (float t);
00390
00395 virtual vuCamera* operator*= (float t);
00396
00404 virtual vuCamera* operator+ (vuCamera &rhs);
00405
00411 virtual vuCamera* operator+= (vuCamera &rhs);
00412
00418 virtual vuCamera* operator+ (vuCamera *rhs);
00419
00425 virtual vuCamera* operator+= (vuCamera *rhs);
00426
00430 virtual vuCamera* operator= (vuCamera *rhs);
00431
00438 friend vuCamera* operator*(float t, vuCamera &cam);
00439
00440 public:
00441
00445 bool IsChanged ();
00446
00447
00449 virtual void set_defaults ();
00450
00451 protected:
00453 vuVector m_Position;
00455 vuVector m_UpVector;
00457 vuVector m_LookAtVector;
00459 vuVector m_RightVector;
00460
00461 int m_Width;
00462 int m_Height;
00463
00464 bool m_IsChanged;
00467 public:
00468
00469 int m_IsRecording;
00470
00471 FILE *fp;
00472
00473 int line_number;
00474
00475
00476 vuDVector <char*> lines;
00477 };
00478
00482 int get_next_open (char* line)
00483 ;
00487 int get_next_close (char* line);
00488
00495 vuCamera* interpolate (vuCamera *cam1, vuCamera *cam2, float t, float t0, float tf);
00496 #endif
00497
00498
00499
00500