zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Camera.cpp
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 #include <zeni.h>
19 
20 #include <cmath>
21 
22 #include <Zeni/Define.h>
23 
24 namespace Zeni {
25 
26  Camera::Camera(const Point3f &position_, const Quaternion &orientation_, const float &near_clip_, const float &far_clip_, const float &fov_rad_, const float &tunnel_vision_factor_)
27  : position(position_),
28  orientation(orientation_),
29  near_clip(near_clip_),
30  far_clip(far_clip_),
31  fov_rad(fov_rad_),
32  tunnel_vision_factor(tunnel_vision_factor_)
33  {
34  }
35 
36  void Camera::adjust_yaw(const float &theta) {
38  }
39 
40  void Camera::adjust_pitch(const float &phi) {
42  }
43 
44  void Camera::adjust_roll(const float &rho) {
46  }
47 
48  void Camera::move_forward_xy(const float &distance) {
50  }
51 
52  void Camera::move_left_xy(const float &distance) {
54  }
55 
56  void Camera::turn_left_xy(const float &theta) {
58  }
59 
60  void Camera::look_at(const Point3f &world_coord, const Vector3f &horizon_plane_normal) {
61  const Vector3f forward = (world_coord - position).normalized();
62  const Vector3f left = (horizon_plane_normal % forward).normalized();
63  const Vector3f up = (forward % left).normalized();
64 
65  orientation = Quaternion::Forward_Up(forward, up,
68  }
69 
70  void Camera::look_at(const Point3f &world_coord, const Collision::Plane &horizon_plane) {
71  look_at(world_coord, horizon_plane.get_normal());
72  }
73 
74 }
75 
76 #include <Zeni/Undefine.h>
Camera(const Point3f &position=ZENI_DEFAULT_CAMERA_POSITION, const Quaternion &orientation=ZENI_DEFAULT_CAMERA_ORIENTATION, const float &near_clip=ZENI_DEFAULT_CAMERA_NEAR_CLIP, const float &far_clip=ZENI_DEFAULT_CAMERA_FAR_CLIP, const float &fov_rad_=ZENI_DEFAULT_CAMERA_FOV, const float &tunnel_vision_factor=ZENI_DEFAULT_CAMERA_TUNNEL_VISION)
The Camera constructor is an alternative to using the numerous setter functions.
Definition: Camera.cpp:26
Vector3f get_forward() const
Get the vector indicating the direction in which the camera is pointing.
Definition: Camera.hxx:33
GLint left
Definition: glew.h:7291
Quaternion orientation
Definition: Camera.h:91
GLint GLenum GLboolean normalized
Definition: glew.h:1891
void adjust_yaw(const float &theta)
Adjust the orientation of the camera: left == positive;.
Definition: Camera.cpp:36
static Quaternion Axis_Angle(const Vector3f &v, const float &theta)
Create a Quaternion from an Axis/Angle pair.
Definition: Quaternion.cpp:56
const Vector3f & get_normal() const
Definition: Collision.h:226
Vector3f get_ij() const
Get just the i and j parts.
Definition: Vector3f.hxx:158
A 3D Point represented with floats.
Definition: Coordinate.h:133
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
GLsizei GLsizei GLfloat distance
Definition: glew.h:12423
A Featureful Quaternion Class.
Definition: Quaternion.h:44
static Quaternion Forward_Up(const Vector3f &destination_forward, const Vector3f &destination_up, const Vector3f &default_forward=ZENI_DEFAULT_FORWARD_VECTOR, const Vector3f &default_up=ZENI_DEFAULT_UP_VECTOR)
Create a Quaternion from a Forward/Up Vector3f pair.
Definition: Quaternion.cpp:66
void move_left_xy(const float &distance)
Move the camera in the left direction, projected onto the xy-plane.
Definition: Camera.cpp:52
void turn_left_xy(const float &theta)
Turn the camera left about the z-axis.
Definition: Camera.cpp:56
Point3f position
Definition: Camera.h:90
Collision Plane.
Definition: Collision.h:207
Vector3f get_left() const
Get the vector indicating what is &quot;left&quot; from the perspective of the camera.
Definition: Camera.hxx:41
void adjust_pitch(const float &phi)
Adjust the orientation of the camera: up == positive;.
Definition: Camera.cpp:40
void look_at(const Point3f &world_coord, const Vector3f &horizon_plane_normal=ZENI_DEFAULT_UP_VECTOR)
Set the Camera to look at a specific Point3f while maintaining a horizontal horizon for a Plane with ...
Definition: Camera.cpp:60
Vector3f get_up() const
Get the vector indicating what is &quot;up&quot; from the perspective of the camera.
Definition: Camera.hxx:37
Vector3f normalized() const
Get the normalized vector.
Definition: Vector3f.cpp:58
void adjust_roll(const float &rho)
Adjust the orientation of the camera: spin right == positive;.
Definition: Camera.cpp:44
#define ZENI_DEFAULT_UP_VECTOR
Definition: Define.h:33
void move_forward_xy(const float &distance)
Move the camera in the forward direction, projected onto the xy-plane.
Definition: Camera.cpp:48
#define ZENI_DEFAULT_FORWARD_VECTOR
Definition: Define.h:32