camera.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "tango-gl/camera.h"
18 #include "tango-gl/util.h"
19 
20 namespace tango_gl {
21 
24  aspect_ratio_ = 4.0f / 3.0f;
25  width_ = 800.0f;
26  height_ = 600.0f;
27  near_clip_plane_ = 0.5f;
28  far_clip_plane_ = 50.0f;
29  ortho_ = false;
30  orthoScale_ = 2.0f;
31  orthoCropFactor_ = -1.0f;
32 }
33 
36 }
37 
39  if(ortho_)
40  {
42  }
44 }
45 
46 void Camera::SetWindowSize(float width, float height) {
47  width_ = width;
48  height_ = height;
49  aspect_ratio_ = width/height;
50 }
51 
52 void Camera::SetFieldOfView(float fov) {
54 }
55 
56 void Camera::SetNearFarClipPlanes(const float near, const float far)
57 {
58  near_clip_plane_ = near;
59  far_clip_plane_ = far;
60 }
61 
63 }
64 
66  float fx, float fy,
67  float cx, float cy,
68  float near, float far) {
69  const float xscale = near / fx;
70  const float yscale = near / fy;
71 
72  const float xoffset = (cx - (width / 2.0)) * xscale;
73  // Color camera's coordinates has y pointing downwards so we negate this term.
74  const float yoffset = -(cy - (height / 2.0)) * yscale;
75 
76  return glm::frustum(xscale * -width / 2.0f - xoffset,
77  xscale * width / 2.0f - xoffset,
78  yscale * -height / 2.0f - yoffset,
79  yscale * height / 2.0f - yoffset,
80  near, far);
81 }
82 
83 } // namespace tango_gl
tango_gl::Camera::aspect_ratio_
float aspect_ratio_
Definition: camera.h:60
tango_gl::Camera::GetViewMatrix
glm::mat4 GetViewMatrix()
Definition: camera.cpp:34
cy
const double cy
tango_gl::Camera::height_
float height_
Definition: camera.h:62
tango_gl::Camera::orthoScale_
float orthoScale_
Definition: camera.h:65
tango_gl::Camera::SetWindowSize
void SetWindowSize(const float width, const float height)
Definition: camera.cpp:46
fx
const double fx
util.h
tango_gl::Camera::width_
float width_
Definition: camera.h:61
tango_gl::Camera::~Camera
~Camera()
Definition: camera.cpp:62
glm::detail::tmat4x4
Definition: type_mat.hpp:47
tango_gl::Camera::Camera
Camera()
Definition: camera.cpp:22
glm::perspective
GLM_FUNC_DECL detail::tmat4x4< T, defaultp > perspective(T const &fovy, T const &aspect, T const &near, T const &far)
tango_gl::Camera::GetProjectionMatrix
glm::mat4 GetProjectionMatrix()
Definition: camera.cpp:38
tango_gl::Camera::SetFieldOfView
void SetFieldOfView(const float fov)
Definition: camera.cpp:52
tango_gl::Camera::field_of_view_
float field_of_view_
Definition: camera.h:59
glm::ortho
GLM_FUNC_DECL detail::tmat4x4< T, defaultp > ortho(T const &left, T const &right, T const &bottom, T const &top, T const &zNear, T const &zFar)
f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
camera.h
glm::frustum
GLM_FUNC_DECL detail::tmat4x4< T, defaultp > frustum(T const &left, T const &right, T const &bottom, T const &top, T const &near, T const &far)
tango_gl::Camera::ortho_
bool ortho_
Definition: camera.h:64
tango_gl::Camera::orthoCropFactor_
float orthoCropFactor_
Definition: camera.h:66
tango_gl::Camera::far_clip_plane_
float far_clip_plane_
Definition: camera.h:63
tango_gl
Definition: axis.cpp:20
DEGREE_2_RADIANS
#define DEGREE_2_RADIANS
Definition: tango-gl/include/tango-gl/util.h:70
cx
const double cx
tango_gl::Camera::ProjectionMatrixForCameraIntrinsics
static glm::mat4 ProjectionMatrixForCameraIntrinsics(float width, float height, float fx, float fy, float cx, float cy, float near, float far)
Definition: camera.cpp:65
tango_gl::Camera::SetNearFarClipPlanes
void SetNearFarClipPlanes(const float near, const float far)
Definition: camera.cpp:56
tango_gl::Transform::GetTransformationMatrix
glm::mat4 GetTransformationMatrix() const
Definition: transform.cpp:67
glm::inverse
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)
fy
const double fy
tango_gl::Camera::near_clip_plane_
float near_clip_plane_
Definition: camera.h:63


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:06