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.2f;
28  far_clip_plane_ = 1000.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
float height_
Definition: camera.h:62
void SetNearFarClipPlanes(const float near, const float far)
Definition: camera.cpp:56
f
float field_of_view_
Definition: camera.h:59
glm::mat4 GetTransformationMatrix() const
Definition: transform.cpp:67
void SetWindowSize(const float width, const float height)
Definition: camera.cpp:46
GLM_FUNC_DECL detail::tmat4x4< T, defaultp > perspective(T const &fovy, T const &aspect, T const &near, T const &far)
static glm::mat4 ProjectionMatrixForCameraIntrinsics(float width, float height, float fx, float fy, float cx, float cy, float near, float far)
Definition: camera.cpp:65
void SetFieldOfView(const float fov)
Definition: camera.cpp:52
float orthoCropFactor_
Definition: camera.h:66
float near_clip_plane_
Definition: camera.h:63
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)
#define DEGREE_2_RADIANS
float aspect_ratio_
Definition: camera.h:60
float far_clip_plane_
Definition: camera.h:63
glm::mat4 GetProjectionMatrix()
Definition: camera.cpp:38
float width_
Definition: camera.h:61
glm::mat4 GetViewMatrix()
Definition: camera.cpp:34
float orthoScale_
Definition: camera.h:65
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)
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:30