Open3D (C++ API)
Camera.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2019 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Geometry>
30 
31 namespace open3d {
32 namespace visualization {
33 
34 class Camera {
35 public:
36  enum class FovType { Vertical, Horizontal };
37  enum class Projection { Perspective, Ortho };
38  using Transform = Eigen::Transform<float, 3, Eigen::Affine>;
39 
40  virtual ~Camera() = default;
41 
42  virtual void SetProjection(double fov,
43  double aspect,
44  double near,
45  double far,
46  FovType fov_type) = 0;
47 
70  virtual void SetProjection(Projection projection,
71  double left,
72  double right,
73  double bottom,
74  double top,
75  double near,
76  double far) = 0;
77 
78  virtual double GetNear() const = 0;
79  virtual double GetFar() const = 0;
81  virtual double GetFieldOfView() const = 0;
83  virtual FovType GetFieldOfViewType() const = 0;
84 
85  virtual void SetModelMatrix(const Transform& view) = 0;
86  virtual void SetModelMatrix(const Eigen::Vector3f& forward,
87  const Eigen::Vector3f& left,
88  const Eigen::Vector3f& up) = 0;
89 
90  virtual void LookAt(const Eigen::Vector3f& center,
91  const Eigen::Vector3f& eye,
92  const Eigen::Vector3f& up) = 0;
93 
94  virtual Eigen::Vector3f GetPosition() const = 0;
95  virtual Eigen::Vector3f GetForwardVector() const = 0;
96  virtual Eigen::Vector3f GetLeftVector() const = 0;
97  virtual Eigen::Vector3f GetUpVector() const = 0;
98  virtual Transform GetModelMatrix() const = 0;
99  virtual Transform GetViewMatrix() const = 0;
100  virtual Transform GetProjectionMatrix() const = 0;
101 };
102 
103 } // namespace visualization
104 } // namespace open3d
virtual void SetModelMatrix(const Transform &view)=0
virtual Transform GetProjectionMatrix() const =0
virtual Eigen::Vector3f GetPosition() const =0
virtual void LookAt(const Eigen::Vector3f &center, const Eigen::Vector3f &eye, const Eigen::Vector3f &up)=0
virtual double GetFar() const =0
virtual Eigen::Vector3f GetUpVector() const =0
virtual double GetFieldOfView() const =0
only valid if fov was passed to SetProjection()
virtual FovType GetFieldOfViewType() const =0
only valid if fov was passed to SetProjection()
virtual Eigen::Vector3f GetLeftVector() const =0
Definition: Camera.h:34
Projection
Definition: Camera.h:37
Definition: Open3DViewer.h:29
virtual Transform GetModelMatrix() const =0
FovType
Definition: Camera.h:36
virtual void SetProjection(double fov, double aspect, double near, double far, FovType fov_type)=0
virtual double GetNear() const =0
virtual Transform GetViewMatrix() const =0
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:38
virtual Eigen::Vector3f GetForwardVector() const =0