Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuCamera.cpp

Go to the documentation of this file.
00001 #ifdef WIN32
00002 #include <windows.h>
00003 #endif
00004 
00005 #include <GL/gl.h>
00006 #include <stdlib.h>
00007 #include <GL/glu.h>
00008 #include <math.h>
00009 #include "vuCamera.h"
00010 #include "vuMatrix.h"
00011 
00012 #define PI_OVER_180 0.01745329251994
00013 
00014 vuCamera::vuCamera() : m_Position(0.0, 0.0, 256.0),
00015                    m_UpVector(0.0, 1.0, 0.0),
00016                    m_LookAtVector(0.0, 0.0, -1.0),
00017                    m_RightVector(1.0, 0.0, 0.0),
00018                    m_Width(320),
00019                    m_Height(240),
00020                    m_IsChanged(true),
00021                    m_IsRecording (0),
00022                    fp (NULL),
00023                    line_number (0)
00024 {
00025 }
00026 
00027 void vuCamera::set_defaults ()
00028 
00029 {
00030         vuVector m_Pos (0.0, 0.0, 256.0);
00031         m_Position = m_Pos;
00032         vuVector m_Up (0.0, 1.0, 0.0);
00033         m_UpVector = m_Up;
00034         vuVector m_Loo (0.0, 0.0, -1.0);
00035         m_LookAtVector = m_Loo;
00036         vuVector m_Rig (1.0, 0.0, 0.0);
00037         m_RightVector = m_Rig;
00038 
00039         m_IsChanged = true;
00040 }
00041 
00042 vuCamera::vuCamera(const vuCamera& c)
00043 {
00044     m_Position      = c.m_Position;
00045     m_UpVector      = c.m_UpVector;
00046     m_LookAtVector  = c.m_LookAtVector;
00047     m_RightVector   = c.m_RightVector;
00048 
00049     m_Width         = c.m_Width;
00050     m_Height        = c.m_Height;
00051 
00052     fp = NULL;
00053     line_number = 0;
00054 
00055     m_IsRecording = 0;
00056 
00057     m_IsChanged = true;
00058 }
00059 
00060 vuCamera::~vuCamera()
00061 {
00062         clear_lines ();
00063 }
00064 
00065 vuCamera& vuCamera::operator=(const vuCamera& rhs)
00066 {
00067     if (this != &rhs)
00068     {
00069         m_Position      = rhs.m_Position;
00070         m_UpVector      = rhs.m_UpVector;
00071         m_LookAtVector  = rhs.m_LookAtVector;
00072         m_RightVector   = rhs.m_RightVector;
00073         m_Width         = rhs.m_Width;
00074         m_Height        = rhs.m_Height;
00075 
00076         m_IsRecording = 0;
00077     }
00078 
00079     m_IsChanged = true;
00080 
00081     return *this;
00082 }
00083 
00084 void vuCamera::setPosition(const vuVector& pos)
00085 {
00086     m_Position = pos;
00087 
00088     m_IsChanged = true;
00089 }
00090 
00091 vuVector vuCamera::getPosition(void) const
00092 {
00093     return m_Position;
00094 }
00095 
00096 void vuCamera::setUpVector(const vuVector& up)
00097 {
00098     m_UpVector = up;
00099     m_UpVector.makeUnit();
00100     m_RightVector = m_LookAtVector.cross(m_UpVector);
00101 
00102     m_IsChanged = true;
00103 }
00104 
00105 vuVector vuCamera::getUpVector(void) const
00106 {
00107     return m_UpVector;
00108 }
00109 
00110 void vuCamera::setLookAtVector(const vuVector& lookat)
00111 {
00112     m_LookAtVector = lookat;
00113     m_LookAtVector.makeUnit();
00114     m_RightVector = m_LookAtVector.cross(m_UpVector);
00115 
00116     m_IsChanged = true;
00117 }
00118 
00119 vuVector vuCamera::getLookAtVector(void) const
00120 {
00121     return m_LookAtVector;
00122 }
00123 
00124 vuVector vuCamera::getRightVector(void) const
00125 {
00126     return m_RightVector;
00127 }
00128 
00129 void vuCamera::setRightVector (const vuVector &right)
00130 {
00131   m_RightVector = right;
00132   m_RightVector.makeUnit ();
00133 }
00134 
00135 // Set up OpenGL viewport using width and height.
00136 void vuCamera::gluLookAt(void)
00137 {
00138     vuVector reference = m_Position + m_LookAtVector;
00139     ::gluLookAt(m_Position[0], m_Position[1], m_Position[2],
00140                 reference[0],  reference[1],  reference[2], 
00141                 m_UpVector[0], m_UpVector[1], m_UpVector[2]);
00142 }
00143 
00144 void vuCamera::glViewport()
00145 {
00146     ::glViewport(0, 0, m_Width, m_Height);
00147 }
00148 
00149 // Get the pixel width
00150 int vuCamera::getWidth(void) const
00151 {
00152     return m_Width;
00153 }
00154 
00155 // Set the pixel width
00156 void vuCamera::setWidth(int width)
00157 {
00158     m_Width = (width < 0) ? -width : width;
00159 
00160     m_IsChanged = true;
00161 }
00162 
00163 // Get the pixel height
00164 int vuCamera::getHeight(void) const
00165 {
00166     return m_Height;
00167 }
00168 
00169 // Set the pixel height
00170 void vuCamera::setHeight(int height)
00171 {
00172     m_Height = (height < 0) ? -height : height;
00173 
00174     m_IsChanged = true;
00175 }
00176 
00177 
00178 void vuCamera::rotateAboutUp(float theta)
00179 {
00180     vuMatrix rot;
00181 
00182     rot.makeRotate(m_UpVector, theta);
00183 
00184     transform(rot);
00185     /*
00186     m_LookAtVector = rot*m_LookAtVector;
00187     m_RightVector = rot*m_RightVector;
00188 
00189     m_LookAtVector.makeUnit();
00190     m_RightVector.makeUnit();*/
00191 }
00192 
00193 void vuCamera::rotateAboutLookAt(float theta)
00194 {
00195     vuMatrix rot;
00196 
00197     rot.makeRotate(m_LookAtVector, theta);
00198 
00199     transform(rot);
00200 /*    m_UpVector = rot*m_UpVector;
00201     m_RightVector = rot*m_RightVector;
00202 
00203     m_UpVector.makeUnit();
00204     m_RightVector.makeUnit();
00205 */}
00206 
00207 void vuCamera::rotateAboutRight(float theta)
00208 {
00209     vuMatrix rot;
00210 
00211     rot.makeRotate(m_RightVector, theta);
00212 
00213     transform(rot);
00214 
00215 /*    m_UpVector = rot*m_UpVector;
00216     m_LookAtVector = rot*m_LookAtVector;
00217 
00218     m_UpVector.makeUnit();
00219     m_LookAtVector.makeUnit();
00220 */
00221 }
00222 
00223 void vuCamera::translateV(const vuVector& t)
00224 {
00225     if (t[0])
00226         m_Position += m_RightVector*t[0];
00227     if (t[1])
00228         m_Position += m_UpVector*t[1];
00229     if (t[2])
00230         m_Position += m_LookAtVector*t[2];
00231 
00232     m_IsChanged = true;
00233 }
00234 
00235 void vuCamera::translateXYZ(float x, float y, float z)
00236 {
00237     if (x)
00238         m_Position += m_RightVector*x;
00239     if (y)
00240         m_Position += m_UpVector*y;
00241     if (z)
00242         m_Position += m_LookAtVector*z;
00243 
00244     m_IsChanged = true;
00245 }
00246 
00247 void vuCamera::transform(const vuMatrix &m)
00248 {
00249     m_UpVector = m*m_UpVector;
00250     m_LookAtVector = m*m_LookAtVector;
00251     m_RightVector = m*m_RightVector;
00252 
00253     m_UpVector.makeUnit();
00254     m_LookAtVector.makeUnit();
00255     m_RightVector.makeUnit();
00256 
00257     m_IsChanged = true;
00258 }
00259 
00260 vuMatrix vuCamera::getViewMat()
00261 {
00262   vuMatrix cam;
00263   cam[3][3] = 1;
00264   memcpy(cam[0],m_RightVector.getData(),sizeof(float)*3);
00265   memcpy(cam[1],m_UpVector.getData(),sizeof(float)*3);
00266   memcpy(cam[2],m_LookAtVector.getData(),sizeof(float)*3);
00267 
00268   return cam;
00269 }
00270 
00271 
00272 bool vuCamera::record (const char* record_to)
00273 
00274 {
00275         if (fp != NULL)
00276                 return false;
00277 
00278         fp = fopen (record_to, "w");
00279 
00280         fputs (get_id (), fp);
00281         fputc ('\n', fp);
00282 
00283         m_IsRecording = 1;
00284 
00285         return true;
00286 }
00287 
00288 void vuCamera::TakeSnapShotBasic (char* Shot)
00289 
00290 {
00291         if (m_IsRecording)
00292 
00293         {
00294                 char temp [100];
00295 
00296                 strcpy (Shot, "(\0");
00297                 m_Position.save (temp);
00298                 strcat (Shot, temp);
00299                 strcat (Shot, "), (");
00300 
00301                 m_UpVector.save (temp);
00302                 strcat (Shot, temp);
00303                 strcat (Shot, "), (");
00304 
00305                 m_LookAtVector.save (temp);
00306                 strcat (Shot, temp);
00307                 strcat (Shot, "), (");
00308 
00309                 m_RightVector.save (temp);
00310                 strcat (Shot, temp);
00311                 strcat (Shot, ") \0");
00312         }
00313 }
00314 
00315 void vuCamera::TakeSnapShot ()
00316 
00317 {
00318         char Shot [1000];
00319 
00320         if (m_IsRecording)
00321 
00322         {
00323                 TakeSnapShotBasic (Shot);
00324 
00325                 strcat (Shot, "\n");
00326 
00327                 fputs (Shot, fp);
00328         }
00329 }
00330 
00331 void vuCamera::TakeSnapShot (char* Shot)
00332 
00333 {
00334         TakeSnapShotBasic (Shot);
00335 }
00336 
00337 int get_next_open (char* line)
00338 
00339 {
00340         int position = 0;
00341 
00342         while ((line [position] != '(') && (line [position] != '\0'))
00343                 position++;
00344 
00345         return position;
00346 }
00347 
00348 int get_next_close (char* line)
00349 
00350 {
00351         int position = 0;
00352 
00353         while ((line [position] != ')') && (line [position] != '\0'))
00354                 position++;
00355 
00356         return position;
00357 }
00358 
00359 int vuCamera::RestoreShotBasic (char* Shot)
00360 
00361 {
00362         int position = -1;
00363 
00364         if (Shot [0] != '\0');
00365 
00366         {
00367 
00368                 position = get_next_open (Shot) + 1;
00369                 m_Position.load (&(Shot [position]));
00370                 position += get_next_close (&(Shot [position])) + 1;
00371 
00372                 position += get_next_open (&(Shot [position])) + 1;
00373                 m_UpVector.load (&(Shot [position]));
00374                 position += get_next_close (&(Shot [position])) + 1;
00375 
00376                 position += get_next_open (&(Shot [position])) + 1;
00377                 m_LookAtVector.load (&(Shot [position]));
00378                 position += get_next_close (&(Shot [position])) + 1;
00379 
00380                 position += get_next_open (&(Shot [position])) + 1;
00381                 m_RightVector.load (&(Shot [position]));
00382                 position += get_next_close (&(Shot [position])) + 1;
00383         }
00384 
00385         m_IsChanged = true;
00386 
00387         return position;
00388 }
00389 
00390 int vuCamera::RestoreShot (char* Shot)
00391 
00392 {
00393         return RestoreShotBasic (Shot);
00394 }
00395 
00396 int vuCamera::RestoreNextShot ()
00397 
00398 {
00399 //      if (++line_number < int (lines.size ()))
00400 
00401         if (IsNextAvailable ())
00402                 return RestoreShotBasic (lines [++line_number]);
00403 
00404         return -1;
00405 }
00406 
00407 int vuCamera::RestorePreviousShot ()
00408 
00409 {
00410         if (IsPreviousAvailable ())
00411                 return RestoreShotBasic (lines [--line_number]);
00412 
00413         return -1;
00414 }
00415 
00416 void vuCamera::stop_recording ()
00417 
00418 {
00419         fclose (fp);
00420 
00421         m_IsRecording = 0;
00422 
00423         fp = NULL;
00424 }
00425 /*
00426 float vuCamera::play (char* play_from)
00427 
00428 {
00429         fp = fopen (play_from, "r");
00430 
00431         vuHWTimer timer;
00432 
00433         timer.getElapsedTimeFloat ();
00434 
00435         char temp [256];
00436 
00437         temp [0] = 'a';
00438 
00439         while (temp [0] != '\0')
00440 
00441         {
00442                 fgets (temp, 256, fp);
00443 
00444                 if (temp [0] != '\0');
00445 
00446                 {
00447                         int position = m_Position.load (temp);
00448                         position += m_UpVector.load (&(temp [position]));
00449                         position += m_LookAtVector.load (&(temp [position]));
00450                         position += m_RightVector.load (&(temp [position]));
00451 
00452                         gluLookAt ();
00453                 }
00454         }
00455 
00456         fclose (fp);
00457         return timer.getElapsedTimeFloat ();
00458 }*/
00459 
00460 bool vuCamera::load (char* load_from)
00461 
00462 {
00463         clear_lines ();
00464 
00465         char temp [1000];
00466         char* hithere;
00467 
00468         fp = fopen (load_from, "r");
00469 
00470         line_number = -1;
00471 
00472         if (fp == NULL)
00473                 return false;
00474 
00475         fgets (temp, 100, fp);
00476 
00477         if (!(this->verify_id (temp)))
00478                 return false;
00479 
00480         char* not_NULL = temp;
00481 
00482         while (not_NULL)
00483 
00484         {
00485                 not_NULL = fgets (temp, 1000, fp);
00486 
00487                 hithere = new char [strlen (temp) + 5];
00488                 strcpy (hithere, temp);
00489 
00490                 if (temp [0] != '\0')
00491                         lines.add (hithere);
00492 //                      lines.push_back (hithere);
00493         }
00494 
00495         fclose (fp);
00496 
00497         fp = NULL;
00498 
00499         return true;
00500 }
00501 
00502 void vuCamera::clear_lines ()
00503 
00504 {
00505         char *temp;
00506 
00507         for (unsigned int i = 0; i < lines.getLength (); i++)
00508 
00509         {
00510                 temp = lines [i];
00511                 delete [] temp;
00512         }
00513 
00514         lines.removeRange (0, lines.getLength () - 1);
00515 /*      while (lines.size () > 0)
00516 
00517         {
00518                 char* temp = lines [lines.size () - 1];
00519                 lines.pop_back ();
00520 
00521                 delete [] temp;
00522         }*/
00523 }
00524 
00525 bool vuCamera::verify_id (char* id)
00526 
00527 {
00528         return (strncmp (get_id (), id, strlen (get_id ())) == 0);
00529 }
00530 
00531 // d refers to the data format (ie, if something changes, then  new format should be used so that you
00532 // don't try to copy the old format into the new...
00533 char id_string_cgs_xq1 [] = "vuBasicCameraD1.00___";
00534 
00535 char* vuCamera::get_id ()
00536 
00537 {
00538         return id_string_cgs_xq1;
00539 }
00540 
00541 ostream& operator<<(ostream& out, vuCamera &cam)
00542 
00543 {
00544         char Shot [1024];
00545 
00546         cam.TakeSnapShot (Shot);
00547 
00548         out << Shot;
00549 
00550         cam.m_IsChanged = true;
00551 
00552         return out;
00553 }
00554 
00555 istream& operator>>(istream& in, vuCamera &cam)
00556 
00557 {
00558         char Shot [1024];
00559 
00560         in >> Shot;
00561 
00562         cam.RestoreShot (Shot);
00563 
00564         return in;
00565 }
00566 
00567 bool vuCamera::IsNextAvailable ()
00568 
00569 {
00570         return ((int (lines.getLength ()) > 0) && (line_number < int (lines.getLength () - 1)) && (line_number > -2));
00571 }
00572 
00573 bool vuCamera::IsPreviousAvailable ()
00574 
00575 {
00576         return ((int (lines.getLength ()) > 0) && (line_number > 0) && (line_number < int (lines.getLength ()) + 2));
00577 }
00578 
00579 bool vuCamera::IsRecording ()
00580 
00581 {
00582         return m_IsRecording;
00583 }
00584 
00585 bool vuCamera::load_cameras (vuDVector <vuCamera> &vect, char *fname)
00586 
00587 {
00588         vuCamera cam;
00589 
00590         if (vect.getLength () > 0)
00591                 vect.removeRange (dword (0), vect.getLength () - 1);
00592 
00593         cam.clear_lines ();
00594 
00595         if (!cam.load (fname))
00596                 return false;
00597 
00598         while (cam.IsNextAvailable ())
00599 
00600         {
00601                 vect.add (cam);
00602 
00603                 cam.RestoreNextShot ();
00604         }
00605 
00606         vect.add (cam);
00607 
00608         return true;
00609 }
00610 
00611 bool record_with_time (char* record_to, vuCamera &cam)
00612 
00613 {
00614         bool ret_val = cam.record (record_to);
00615 
00616         if (ret_val)
00617 
00618         {
00619                 fputs (cam.getWithTime_id (), cam.fp);
00620                 fputc ('\n', cam.fp);
00621         }
00622 
00623         return ret_val;
00624 }
00625 
00626 bool stop_recording (vuCamera &cam)
00627 
00628 {
00629         cam.stop_recording ();
00630 
00631         return true;
00632 }
00633 
00634 bool TakeSnapShotWithTime (float time, vuCamera &cam)
00635 
00636 {
00637         if (!cam.m_IsRecording)
00638                 return false;
00639 
00640         char time_ascii [14];
00641 
00642         gcvt (time, 10, time_ascii);
00643 
00644         fputs (time_ascii, cam.fp);
00645 
00646         fputs (", ", cam.fp);
00647 
00648         cam.TakeSnapShot ();
00649 
00650         return true;
00651 }
00652 
00653 bool load_WithTime (char* load_from, vuCamera *cam, vuDVector <vuCamera*> &cameras, vuDVector <float> &times)
00654 
00655 {
00656         cam->clear_lines ();
00657 
00658         char* temp;
00659         char* hithere;
00660 
00661         temp = new char [1000];
00662 
00663         times.removeRange (0, times.getLength () - 1);
00664         cameras.removeRange (0, cameras.getLength () - 1);
00665 
00666         cam->fp = fopen (load_from, "r");
00667 
00668         cam->line_number = -1;
00669 
00670         if (cam->fp == NULL)
00671                 return false;
00672 
00673         fgets (temp, 100, cam->fp);
00674 
00675         if (!(cam->verify_id (temp)))
00676                 return false;
00677 
00678         fgets (temp, 100, cam->fp);
00679 
00680         if (!(cam->verify_time_id (temp)))
00681                 return false;
00682 
00683         char* not_NULL = temp;
00684 
00685         int position;
00686         float current_time;
00687 
00688         vuCamera *t_camera;
00689 
00690         while (not_NULL)
00691 
00692         {
00693                 not_NULL = fgets (temp, 1000, cam->fp);
00694 
00695                 position = clear_blanks (temp);
00696 
00697                 current_time = atof (&(temp [position]));
00698                 position += get_next_comma (&(temp [position])) + 1;
00699                 position += clear_blanks (&(temp [position]));
00700 
00701                 hithere = new char [strlen (&(temp [position])) + 5];
00702                 strcpy (hithere, &(temp [position]));
00703 
00704                 if (temp [0] != '\0')
00705                         cam->lines.add (hithere);
00706 
00707                 t_camera = cam->create_new ();
00708                 t_camera->RestoreShot (hithere);
00709                 times.add (current_time);
00710 
00711                 cameras.add (t_camera);
00712         }
00713 
00714         fclose (cam->fp);
00715 
00716         cam->fp = NULL;
00717 
00718         return true;
00719 }
00720 
00721 char id_string_cgs_xq1_2 [] = "vuCamera_WithTime_id_1.00__";
00722 
00723 char* vuCamera::getWithTime_id ()
00724 
00725 {
00726         return id_string_cgs_xq1_2;
00727 }
00728 
00729 bool vuCamera::verify_time_id (char* cmp)
00730 
00731 {
00732         return (strncmp (getWithTime_id (), cmp, strlen (getWithTime_id ())) == 0);
00733 }
00734 
00735 vuCamera* vuCamera::create_new ()
00736 
00737 {
00738         vuCamera* ptr = new vuCamera [1];
00739 
00740         return ptr;
00741 }
00742 /*
00743 void vuCamera::delete_me ()
00744 
00745 {
00746         delete [] this;
00747 }*/
00748 
00749 vuCamera* vuCamera::operator* (float t)
00750 
00751 {
00752         vuCamera *temp_cam_vc_cgs__ = create_new ();
00753 
00754         temp_cam_vc_cgs__->setPosition (m_Position * t);
00755         temp_cam_vc_cgs__->setUpVector (m_UpVector * t);
00756         temp_cam_vc_cgs__->setLookAtVector (m_LookAtVector * t);
00757 //      temp_cam.setRightVector (m_RightVector * t);
00758 
00759         m_IsChanged = true;
00760 
00761         return temp_cam_vc_cgs__;
00762 }
00763 
00764 vuCamera* vuCamera::operator*= (float t)
00765 
00766 {
00767         cout << "t:" << t << endl;
00768 
00769         setPosition (m_Position *= t);
00770         setUpVector (m_UpVector *= t);
00771         setLookAtVector (m_LookAtVector *= t);
00772 //      temp_cam.setRightVector (m_RightVector *= t);
00773 
00774         m_IsChanged = true;
00775 
00776         return this;
00777 }
00778 
00779 vuCamera* operator* (float t, vuCamera &cam)
00780 
00781 {
00782         vuCamera *temp_cam_vc_cgs__ = cam.create_new ();
00783 
00784         temp_cam_vc_cgs__->setPosition (cam.m_Position * t);
00785         temp_cam_vc_cgs__->setUpVector (cam.m_UpVector * t);
00786         temp_cam_vc_cgs__->setLookAtVector (cam.m_LookAtVector * t);
00787 //      temp_cam.setRightVector (cam.m_RightVector * t);
00788 
00789         cam.m_IsChanged = true;
00790 
00791         return temp_cam_vc_cgs__;
00792 }
00793 
00794 vuCamera* vuCamera::operator+ (vuCamera &rhs)
00795 
00796 {
00797         vuCamera *temp_cam_vc_cgs__ = create_new ();
00798 
00799         temp_cam_vc_cgs__->setPosition (m_Position + rhs.getPosition ());
00800         temp_cam_vc_cgs__->setUpVector (m_UpVector + rhs.getUpVector ());
00801         temp_cam_vc_cgs__->setLookAtVector (m_LookAtVector + rhs.getLookAtVector ());
00802 //      temp_cam.setRightVector (m_RightVector * t);
00803 
00804         return temp_cam_vc_cgs__;
00805 }
00806 
00807 vuCamera* vuCamera::operator+= (vuCamera &rhs)
00808 
00809 {
00810         setPosition (m_Position += rhs.getPosition ());
00811         setUpVector (m_UpVector += rhs.getUpVector ());
00812         setLookAtVector (m_LookAtVector += rhs.getLookAtVector ());
00813 //      temp_cam.setRightVector (m_RightVector * t);
00814 
00815         m_IsChanged = true;
00816 
00817         return this;
00818 }
00819 
00820 vuCamera* vuCamera::operator+ (vuCamera *rhs)
00821 
00822 {
00823         vuCamera *temp_cam_vc_cgs__ = create_new ();
00824 
00825         temp_cam_vc_cgs__->setPosition (m_Position + rhs->getPosition ());
00826         temp_cam_vc_cgs__->setUpVector (m_UpVector + rhs->getUpVector ());
00827         temp_cam_vc_cgs__->setLookAtVector (m_LookAtVector + rhs->getLookAtVector ());
00828 //      temp_cam.setRightVector (m_RightVector * t);
00829 
00830         return temp_cam_vc_cgs__;
00831 }
00832 
00833 vuCamera* vuCamera::operator+= (vuCamera *rhs)
00834 
00835 {
00836         setPosition (m_Position += rhs->getPosition ());
00837         setUpVector (m_UpVector += rhs->getUpVector ());
00838         setLookAtVector (m_LookAtVector += rhs->getLookAtVector ());
00839 //      temp_cam.setRightVector (m_RightVector * t);
00840 
00841         m_IsChanged = true;
00842 
00843         return this;
00844 }
00845 
00846 vuCamera* vuCamera::operator= (vuCamera *rhs)
00847 
00848 {
00849         m_Position = rhs->getPosition ();
00850         m_UpVector = rhs->getUpVector ();
00851         m_LookAtVector = rhs->getLookAtVector ();
00852         m_RightVector = rhs->getRightVector ();
00853 
00854         m_IsChanged = true;
00855 
00856         return this;
00857 }
00858 
00859 vuCamera* vuCamera::set_equal_to_interp (vuCamera* cam1, vuCamera* cam2, float t1, float t2)
00860 
00861 {
00862         m_Position = cam1->getPosition () * t1;
00863         m_UpVector = cam1->getUpVector () * t1;
00864         m_LookAtVector = cam1->getLookAtVector () * t1;
00865         m_RightVector = cam1->getRightVector () * t1;
00866 
00867         m_Position += cam2->getPosition () * t2;
00868         m_UpVector += cam2->getUpVector () * t2;
00869         m_LookAtVector += cam2->getLookAtVector () * t2;
00870         m_RightVector += cam2->getRightVector () * t2;
00871 
00872         return this;
00873 }
00874 
00875 vuCamera* interpolate (vuCamera *cam1, vuCamera *cam2, float t, float t0, float tf)
00876 
00877         // Note that this will also extrapolate the data
00878         // because it might be of some use...
00879 
00880 {
00881         float t1, t2;
00882 
00883         cout << "interpolate" << t << ',' << t0 << ',' << tf << endl;
00884 
00885         t2 = t - t0;
00886         t1 = tf - t;
00887         t1 /= (tf - t0);
00888         t2 /= (tf - t0);
00889 
00890         vuCamera* ncam1 = cam1->create_new ();
00891 
00892         ncam1->set_equal_to_interp (cam1, cam2, t1, t2);
00893 
00894 //      *cam1 *= t1;
00895 //      *cam2 *= t2;
00896 //      *cam1 += cam2;
00897 
00898         return ncam1;
00899 //      *m_camera = cam2;
00900 
00901 }
00902 
00903 bool vuCamera::IsChanged ()
00904 
00905 {
00906         bool temp = m_IsChanged;
00907         m_IsChanged = false;
00908 
00909         return temp;
00910 }
00911 
00912 /*vuVector& vuVector::operator<<(const char* rhs)
00913 
00914 {
00915         RestoreShot (rhs);
00916 }*/
00917 
00918 /*
00919 int clear_blanks (char* line)
00920 `
00921 {
00922         int position = 0;
00923 
00924         while ((line [position] != ',') && (line [position] != '\0'))
00925                 position++;
00926 
00927         return position;
00928 }
00929 
00930 int get_next_comma (char* line)
00931 
00932 {
00933         int position = 0;
00934 
00935         while ((line [position] != ',') && (line [position] != '\0'))
00936                 position++;
00937 
00938         return position;
00939 }
00940 
00941 
00942 */
00943 
00944 
00945 
00946 

Generated on Wed Dec 15 21:20:33 2004 for vuVolume by  doxygen 1.3.9.1