CORGI
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
camera_interface.h
Go to the documentation of this file.
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef FPL_CAMERA_INTERFACE_H
16 #define FPL_CAMERA_INTERFACE_H
17 
18 #include "mathfu/glsl_mappings.h"
19 
20 namespace corgi {
21 
22 /// @file
23 /// @addtogroup corgi_component_library
24 /// @{
25 ///
26 /// @class CameraInterface
27 ///
28 /// @brief An interface for 3D cameras, allowing them to have position, facing
29 /// field of view, etc. Libraries can use this to pass around generic cameras
30 /// that the game itself can implement the logic for.
32  public:
33  /// @brief The destructor for the CameraInterface.
34  virtual ~CameraInterface() {}
35 
36  /// @brief Get the view/projection matrix.
37  ///
38  /// @return Returns the view/projection matrix as a mathfu::mat4.
39  virtual mathfu::mat4 GetTransformMatrix() const = 0;
40 
41  /// @brief Get the view matrix.
42  ///
43  /// @return Returns the view matrix as a mathfu::mat4.
44  virtual mathfu::mat4 GetViewMatrix() const = 0;
45 
46  /// @brief Get the view/projection matrix at a given index.
47  ///
48  /// @param[in] index The index of the desired matrix.
49  ///
50  /// @return Returns the view/projection matrix as a mathfu::mat4.
51  virtual mathfu::mat4 GetTransformMatrix(int32_t index) const = 0;
52 
53  /// @brief Get the view matrix at a given index.
54  ///
55  /// @param[in] index The index of the desired matrix.
56  ///
57  /// @return Returns the view matrix as a mathfu::mat4.
58  virtual mathfu::mat4 GetViewMatrix(int32_t index) const = 0;
59 
60  /// @brief Get the camera's world position,.
61  ///
62  /// @return Returns the camera's position as a mathfu::vec3.
63  virtual mathfu::vec3 position() const = 0;
64 
65  /// @brief Get the camera's world position at a given index.
66  ///
67  /// @param[in] index The index of the camera whose position should be
68  /// returned.
69  ///
70  /// @return Returns the camera's position as a mathfu::vec3.
71  virtual mathfu::vec3 position(int32_t index) const = 0;
72 
73  /// @brief Set the camera's world position.
74  ///
75  /// @param[in] position A const mathfu::vec3 reference to the world position
76  /// to set.
77  virtual void set_position(const mathfu::vec3& position) = 0;
78 
79  /// @brief Set the camera's world position.
80  ///
81  /// @param[in] index The index of the camera whose position should be set.
82  /// @param[in] position A const mathfu::vec3 reference to the world position
83  /// to set.
84  virtual void set_position(int32_t index, const mathfu::vec3& position) = 0;
85 
86  /// @brief Get the camera's forward direction.
87  ///
88  /// @return Returns the camera's forward direction as a const mathfu::vec3
89  /// reference.
90  virtual const mathfu::vec3& facing() const = 0;
91 
92  /// @brief Set the camera's forward direction.
93  ///
94  /// @param[in] facing A const mathfu::vec3 reference to the direction the
95  /// camera should face.
96  virtual void set_facing(const mathfu::vec3& facing) = 0;
97 
98  /// @brief Get the camera's up direction.
99  ///
100  /// @return Returns the camera's up direction as a const mathfu::vec3
101  /// reference.
102  virtual const mathfu::vec3& up() const = 0;
103 
104  /// @brief Set the camera's up direction.
105  ///
106  /// @param[in] up A const mathfu::vec3 reference to the up direction to
107  /// set for the camera.
108  virtual void set_up(const mathfu::vec3& up) = 0;
109 
110  /// @brief Set the viewport angle.
111  ///
112  /// @param[in] viewport_angle A float representing the viewport angle, in
113  /// radians.
114  virtual void set_viewport_angle(float viewport_angle) = 0;
115 
116  /// @brief Get the viewport angle.
117  ///
118  /// @return Returns the viewport angle, in radians.
119  virtual float viewport_angle() const = 0;
120 
121  /// @brief Set the camera's viewport resolution.
122  ///
123  /// @param[in] viewport_resolution A mathfu::vec2 representing the viewport
124  /// resolution.
125  virtual void set_viewport_resolution(mathfu::vec2 viewport_resolution) = 0;
126 
127  /// @brief Get the viewport resolution.
128  ///
129  /// @return Returns the viewport resolution as a mathfu::vec2.
130  virtual mathfu::vec2 viewport_resolution() const = 0;
131 
132  /// @brief Set the distance to the near clipping plane.
133  ///
134  /// @param[in] viewport_near_plane A float distance to the near clipping
135  /// plane.
136  virtual void set_viewport_near_plane(float viewport_near_plane) = 0;
137 
138  /// @brief Get the distance to the near clipping plane.
139  ///
140  /// @return Returns the float distance to the near clipping plane.
141  virtual float viewport_near_plane() const = 0;
142 
143  /// @brief Set the distance to the far clipping plane.
144  ///
145  /// @param[in] viewport_far_plane A float distance to the far clipping
146  /// plane.
147  virtual void set_viewport_far_plane(float viewport_far_plane) = 0;
148 
149  /// @brief Get the distance to the far clipping plane.
150  ///
151  /// @return Returns the float distance to the far clipping plane.
152  virtual float viewport_far_plane() const = 0;
153 
154  /// @brief Sets the camera's viewport.
155  ///
156  /// @param[in] viewport A const mathfu::vec4i reference to the viewport that
157  /// should be set.
158  virtual void set_viewport(const mathfu::vec4i& viewport) = 0;
159 
160  /// @brief Sets the camera's viewport at a given index.
161  ///
162  /// @param[in] index The index of the viewport to set.
163  /// @param[in] viewport A const mathfu::vec4i reference to the viewport that
164  /// should be set.
165  virtual void set_viewport(int32_t index, const mathfu::vec4i& viewport) = 0;
166 
167  /// @brief Get the camera's viewport at a given index.
168  ///
169  /// @param[in] index The index of the desired viewport.
170  ///
171  /// @return Returns the camera viewport as a const mathfu::vec4i reference.
172  virtual const mathfu::vec4i& viewport(int32_t index) const = 0;
173 
174  /// @brief Check if the camera is stereoscopic.
175  ///
176  /// @return Returns `true` if this camera is stereoscopic. Otherwise it
177  /// returns `false`.
178  virtual bool IsStereo() const = 0;
179 
180  /// @brief Set a camera as stereoscopic.
181  ///
182  /// @param[in] b A bool determining if the camera is stereoscopic or not.
183  virtual void set_stereo(bool b) = 0;
184 };
185 /// @}
186 
187 } // corgi
188 
189 #endif // FPL_CAMERA_INTERFACE_H
virtual void set_viewport_angle(float viewport_angle)=0
Set the viewport angle.
virtual ~CameraInterface()
The destructor for the CameraInterface.
Definition: camera_interface.h:34
virtual float viewport_far_plane() const =0
Get the distance to the far clipping plane.
virtual float viewport_angle() const =0
Get the viewport angle.
virtual void set_viewport_far_plane(float viewport_far_plane)=0
Set the distance to the far clipping plane.
virtual void set_facing(const mathfu::vec3 &facing)=0
Set the camera's forward direction.
virtual void set_viewport_resolution(mathfu::vec2 viewport_resolution)=0
Set the camera's viewport resolution.
virtual void set_viewport_near_plane(float viewport_near_plane)=0
Set the distance to the near clipping plane.
virtual const mathfu::vec4i & viewport(int32_t index) const =0
Get the camera's viewport at a given index.
virtual void set_viewport(const mathfu::vec4i &viewport)=0
Sets the camera's viewport.
virtual void set_up(const mathfu::vec3 &up)=0
Set the camera's up direction.
virtual mathfu::vec3 position() const =0
Get the camera's world position,.
virtual void set_stereo(bool b)=0
Set a camera as stereoscopic.
virtual mathfu::mat4 GetTransformMatrix() const =0
Get the view/projection matrix.
virtual const mathfu::vec3 & up() const =0
Get the camera's up direction.
virtual mathfu::mat4 GetViewMatrix() const =0
Get the view matrix.
An interface for 3D cameras, allowing them to have position, facing field of view, etc. Libraries can use this to pass around generic cameras that the game itself can implement the logic for.
Definition: camera_interface.h:31
virtual void set_position(const mathfu::vec3 &position)=0
Set the camera's world position.
virtual bool IsStereo() const =0
Check if the camera is stereoscopic.
virtual mathfu::vec2 viewport_resolution() const =0
Get the viewport resolution.
virtual const mathfu::vec3 & facing() const =0
Get the camera's forward direction.
virtual float viewport_near_plane() const =0
Get the distance to the near clipping plane.