zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Camera.hxx
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 
18 #ifndef ZENI_CAMERA_HXX
19 #define ZENI_CAMERA_HXX
20 
21 // HXXed below
22 #include <Zeni/Coordinate.h>
23 #include <Zeni/Matrix4f.h>
24 #include <Zeni/Quaternion.h>
25 
26 #include <Zeni/Camera.h>
27 #include <cmath>
28 
29 #include <Zeni/Define.h>
30 
31 namespace Zeni {
32 
35  }
36 
39  }
40 
43  }
44  float Camera::get_fov_deg() const {
45  return fov_rad * 180.0f / Global::pi;
46  }
47 
48  void Camera::set_fov_deg(const float &degrees) {
49  fov_rad = degrees * Global::pi / 180.0f;
50  }
51 
53  return position + (1.0f - tunnel_vision_factor) * near_clip * get_forward();
54  }
55 
58  }
59 
62  }
63 
65  return get_tunneled_fov_rad() * 180.0f / Global::pi;
66  }
67 
69  return 2.0f * std::atan((near_clip * std::tan(0.5f * fov_rad)) / get_tunneled_near_clip());
70  }
71 
74  }
75 
76  Matrix4f Camera::get_projection_matrix(const std::pair<Point2i, Point2i> &viewport) const {
78  float(viewport.second.x - viewport.first.x) / (viewport.second.y - viewport.first.y),
80  }
81 
82 }
83 
84 #include <Zeni/Undefine.h>
85 
86 #include <Zeni/Coordinate.hxx>
87 #include <Zeni/Matrix4f.hxx>
88 #include <Zeni/Quaternion.hxx>
89 
90 #endif
float get_tunneled_fov_rad() const
Get the field of view (in the y-axis) in radians, shifted by tunnel vision.
Definition: Camera.hxx:68
Vector3f get_forward() const
Get the vector indicating the direction in which the camera is pointing.
Definition: Camera.hxx:33
GLclampf f
Definition: glew.h:3390
Quaternion orientation
Definition: Camera.h:91
float get_fov_deg() const
Get the field of view (in the y-axis) in degrees.
Definition: Camera.hxx:44
Point3f get_tunneled_position() const
Get the position shifted by tunnel vision.
Definition: Camera.hxx:52
float near_clip
Definition: Camera.h:93
float fov_rad
Definition: Camera.h:95
Matrix4f get_projection_matrix(const std::pair< Point2i, Point2i > &viewport) const
Equivalent to gluPerspective + tunnel_vision_factor.
Definition: Camera.hxx:76
A 3D Point represented with floats.
Definition: Coordinate.h:133
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
const float pi
pi == 3.1415926...
Definition: Vector3f.cpp:27
float far_clip
Definition: Camera.h:94
Point3f position
Definition: Camera.h:90
static Matrix4f View(const Point3f &position, const Vector3f &forward, const Vector3f &up)
Similar to gluLookAt.
Definition: Matrix4f.hxx:77
float get_tunneled_near_clip() const
Get the near clip shifted by tunnel vision.
Definition: Camera.hxx:56
float get_tunneled_fov_deg() const
Get the field of view (in the y-axis) in degrees, shifted by tunnel vision.
Definition: Camera.hxx:64
float get_tunneled_far_clip() const
Get the far clip shifted by tunnel vision.
Definition: Camera.hxx:60
float tunnel_vision_factor
Definition: Camera.h:97
void set_fov_deg(const float &degrees)
Set the field of view (in the y-axis) in degrees.
Definition: Camera.hxx:48
Vector3f get_left() const
Get the vector indicating what is &quot;left&quot; from the perspective of the camera.
Definition: Camera.hxx:41
double atan(double x)
Definition: s_atan.c:67
A Featureful 4-Space Matrix Class.
Definition: Matrix4f.h:47
static Matrix4f Perspective(const float &fov_rad_y, const float &aspect, const float &near, const float &far)
Similar to gluPerspective.
Definition: Matrix4f.hxx:104
Matrix4f get_view_matrix() const
Equivalent to gluLookAt + tunnel_vision_factor.
Definition: Camera.hxx:72
Vector3f get_up() const
Get the vector indicating what is &quot;up&quot; from the perspective of the camera.
Definition: Camera.hxx:37
#define ZENI_DEFAULT_LEFT_VECTOR
Definition: Define.h:34
#define ZENI_DEFAULT_UP_VECTOR
Definition: Define.h:33
#define ZENI_DEFAULT_FORWARD_VECTOR
Definition: Define.h:32