Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

camera.hpp

00001 //============================================================================
00002 // camera.hpp : OPENGL-style camera class definition
00003 //  Defines and stores a "camera" composed of 3 coord axes, an origin for
00004 //  these axes (center-of-projection or eye location), a near and far plane
00005 //  as distances from the origin projected along the viewing direction, 
00006 //  the viewplane window extents (projection window defined in cam coords 
00007 //  on the viewplane - near plane). ViewPlane is defined as the near plane.
00008 //  Viewing direction is always defined along the -Z axis with eye at origin.
00009 //----------------------------------------------------------------------------
00010 // $Id: camera.hpp,v 1.6 2000/05/08 07:03:02 sharif Exp $
00011 //============================================================================
00012 
00013 #ifndef CAMERA
00014 #define CAMERA
00015 
00016 #include <stdio.h>
00017 #include <vec3f.hpp>
00018 #include <mat16fv.hpp>
00019 
00020 class Camera
00021 {
00022  public:
00023 
00024   Vec3f X, Y, Z;            // NORMALIZED CAMERA COORDINATE-AXIS VECTORS
00025   Vec3f Orig;               // LOCATION OF ORIGIN OF CAMERA SYSTEM IN WORLD COORDS
00026   float wL,wR,wB,wT;        // WINDOW EXTENTS DEFINED AS A RECT ON NearPlane
00027   float Near,Far;           // DISTANCES TO NEAR AND FAR PLANES (IN VIEWING DIR)
00028 
00029   Camera();
00030   Camera(const Camera &Cam);
00031   void Copy(const Camera &Cam);
00032 
00033   void LookAt(const Vec3f& Eye, const Vec3f& ViewRefPt, const Vec3f& ViewUp);
00034   void Perspective(float Yfov, float Aspect, float Ndist, float Fdist);
00035   void Frustum(float l, float r, float b, float t, float Ndist, float Fdist);
00036 
00037   void TightlyFitToSphere(
00038     const Vec3f& Eye, const Vec3f& ViewUp, const Vec3f& Cntr, float Rad);
00039 
00040   void GetLookAtParams(Vec3f *Eye, Vec3f *ViewRefPt, Vec3f *ViewUp) const;
00041   void GetPerspectiveParams(float *Yfov, float *Aspect, 
00042                             float *Ndist, float *Fdist) const;
00043   void GetFrustumParams(float *l, float *r, float *b, float *t, 
00044                         float *Ndist, float *Fdist) const;
00045   const Vec3f& wCOP() const; // WORLD COORDINATE CENTER-OF-PROJECTION (EYE)
00046   Vec3f ViewDir() const;     // VIEWING DIRECTION
00047   Vec3f ViewDirOffAxis() const;
00048 
00049   float* GetXform_Screen2Obj(float* M, int WW, int WH) const;
00050   float* GetXform_Obj2Screen(float* M, int WW, int WH) const;
00051 
00052   float* GetModelviewMatrix(float* M) const;
00053   float* GetProjectionMatrix(float* M) const;
00054   float* GetViewportMatrix(float* M, int WW, int WH) const;
00055 
00056   void SetModelviewMatrix(const float* M);
00057 
00058   float* GetInvModelviewMatrix(float* M) const;
00059   float* GetInvProjectionMatrix(float* M) const;
00060   float* GetInvViewportMatrix(float* M, int WW, int WH) const;
00061 
00062   Vec3f WorldToCam(const Vec3f &wP) const;
00063   Vec3f CamToWorld(const Vec3f &cP) const;
00064 
00065   void LoadIdentityXform();
00066   void Xform(const float M[16]);
00067 
00068   void GetPixelRay(float sx, float sy, int ww, int wh, 
00069                    Vec3f *Start, Vec3f *Dir) const;
00070 
00071   void WriteToFile(FILE *fp) const;
00072   int ReadFromFile(FILE *fp);  // RETURNS "1" IF SUCCESSFUL, "0" IF EOF
00073 
00074   void CalcVerts(Vec3f *V) const;    // CALCS EIGHT CORNERS OF VIEW-FRUSTUM
00075   void Print() const;
00076   void Display() const;
00077   void DisplayInGreen() const;
00078 };
00079 
00080 #endif

Generated at Fri Oct 12 15:12:20 2001 for GLVU by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001