00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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;
00025 Vec3f Orig;
00026 float wL,wR,wB,wT;
00027 float Near,Far;
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;
00046 Vec3f ViewDir() const;
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);
00073
00074 void CalcVerts(Vec3f *V) const;
00075 void Print() const;
00076 void Display() const;
00077 void DisplayInGreen() const;
00078 };
00079
00080 #endif