zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Camera.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
36 #ifndef ZENI_CAMERA_H
37 #define ZENI_CAMERA_H
38 
39 #include <Zeni/Collision.h>
40 #include <Zeni/Coordinate.h>
41 #include <Zeni/Vector3f.h>
42 #include <Zeni/Matrix4f.h>
43 #include <Zeni/Quaternion.h>
44 
45 #include <Zeni/Define.h>
46 
47 namespace Zeni {
48 
49  class ZENI_DLL Camera {
50  public:
53  const Quaternion &orientation = ZENI_DEFAULT_CAMERA_ORIENTATION,
54  const float &near_clip = ZENI_DEFAULT_CAMERA_NEAR_CLIP,
55  const float &far_clip = ZENI_DEFAULT_CAMERA_FAR_CLIP,
56  const float &fov_rad_ = ZENI_DEFAULT_CAMERA_FOV,
57  const float &tunnel_vision_factor = ZENI_DEFAULT_CAMERA_TUNNEL_VISION);
58 
59  // Accessors
60  inline Vector3f get_forward() const;
61  inline Vector3f get_up() const;
62  inline Vector3f get_left() const;
63  inline float get_fov_deg() const;
64  inline float get_tunnel_vision_factor() const;
65 
66  // Modifiers
67  inline void set_fov_deg(const float &degrees);
68 
69  // Convenience Functions
70 
71  inline Point3f get_tunneled_position() const;
72  inline float get_tunneled_near_clip() const;
73  inline float get_tunneled_far_clip() const;
74  inline float get_tunneled_fov_deg() const;
75  inline float get_tunneled_fov_rad() const;
76  inline Matrix4f get_view_matrix() const;
77  inline Matrix4f get_projection_matrix(const std::pair<Point2i, Point2i> &viewport) const;
78 
79  void adjust_yaw(const float &theta);
80  void adjust_pitch(const float &phi);
81  void adjust_roll(const float &rho);
82 
83  void move_forward_xy(const float &distance);
84  void move_left_xy(const float &distance);
85  void turn_left_xy(const float &theta);
86 
87  void look_at(const Point3f &world_coord, const Vector3f &horizon_plane_normal = ZENI_DEFAULT_UP_VECTOR);
88  void look_at(const Point3f &world_coord, const Collision::Plane &horizon_plane);
89 
91  Quaternion orientation; // relative to forward(1.0f, 0.0f, 0.0f), up(0.0f, 0.0f, 1.0f)
92 
93  float near_clip; // should never be less than 1.0f, and higher values will be better still
94  float far_clip; // should always be higher than near_clip
95  float fov_rad; // should be in range (0.0f, pi)
96 
97  float tunnel_vision_factor; // 1.0f is default, higher values will decrease the field-of-view, while keeping the near clip view the same
98  };
99 
100 }
101 
102 #include <Zeni/Undefine.h>
103 
104 #endif
#define ZENI_DEFAULT_CAMERA_POSITION
Definition: Define.h:26
Camera / Point of View.
Definition: Camera.h:49
Quaternion orientation
Definition: Camera.h:91
#define ZENI_DEFAULT_CAMERA_ORIENTATION
Definition: Define.h:27
float near_clip
Definition: Camera.h:93
float fov_rad
Definition: Camera.h:95
A 3D Point represented with floats.
Definition: Coordinate.h:133
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
#define ZENI_DEFAULT_CAMERA_TUNNEL_VISION
Definition: Define.h:31
float far_clip
Definition: Camera.h:94
GLsizei GLsizei GLfloat distance
Definition: glew.h:12423
A Featureful Quaternion Class.
Definition: Quaternion.h:44
Point3f position
Definition: Camera.h:90
#define ZENI_DEFAULT_CAMERA_NEAR_CLIP
Definition: Define.h:28
Collision Plane.
Definition: Collision.h:207
float tunnel_vision_factor
Definition: Camera.h:97
A Featureful 4-Space Matrix Class.
Definition: Matrix4f.h:47
#define ZENI_DEFAULT_CAMERA_FAR_CLIP
Definition: Define.h:29
#define ZENI_DEFAULT_UP_VECTOR
Definition: Define.h:33
#define ZENI_DEFAULT_CAMERA_FOV
Definition: Define.h:30