1 //-----------------------------------------------------------------------------
2 // Camera
3 //-----------------------------------------------------------------------------
4 
5 #ifndef __CAMERA_H__
6 #define __CAMERA_H__
7 
8 #include "frustum.h"
9 
10 /**
11  * Camera class.
12  * The camera inheritate from the frustum class.
13  * The camera rotation vector has default orientation equal to (90, -90, 0).
14  * All rotations value given to camera should take care of this to have
15  * valid orientations.
16  */
17 class Camera : public Frustum
18 {
19   public:
20     Camera(void);
21     ~Camera(void);
22 
23     void Init(float fov, float w, float h);
24     void SetFov(float fov);
25     float GetFov(void);
26 
27     void UpdateRotation(void);    /**< Updates the rotation matrix */
28     void UpdatePosition(void);    /**< Updates the camera position */
29     void UpdateViewport(void);    /**< Updates the camera viewport */
30     void UpdateProjection(void);  /**< Updates the projection matrix */
31     void UpdateFrustum(void);   /**< Updates the camera frustum */
32 
33     /**
34      * Imports the parameters of another camera.
35      */
36     void ImportParams(Camera *cam);
37 
38     float pos[3];         /**< position */
39     float rot[3];         /**< rotation (in order: pitch, yaw, roll) */
40 
41     float fov;            /**< fov in radians */
42     float cos_fov;          /**< cos(fov) */
43     float proj_ratio;       /**< projection ratio */
44 
45     float viewport_size;      /**< normalized viewport size */
46     float viewport_width;     /**< maximum width of viewport */
47     float viewport_height;      /**< maximum height of viewport */
48     float viewport_left;      /**< left position of viewport */
49     float viewport_top;       /**< top position of viewport */
50 
51     float viewsize;         /**< Viewport size */
52 
53     float rotation[9];        /**< precalculated 3x3 rotation matrix for applying movements */
54 
55     vec3_t forward;         /**< eyedir, and normal of the viewing z=0 plane */
56     vec3_t right;         /**< right vector */
57     vec3_t up;            /**< up vector */
58     float eyedist;          /**< signed distance to the z=0 plane */
59 
60     bool inWater;         /**< camera is in water */
61     float waterwidthdeform;     /**< Water width deformation */
62     float waterheightdeform;    /**< Water height deformation */
63     float waterdeformtimefactor;  /**< Water deformation scale */
64 
65     bool lockfrustum;       /**< locks the camera frustum */
66 };
67 
68 #endif  /* __CAMERA_H__ */
69