Open3D (C++ API)  0.11.0
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 namespace rendering {
34 
35 class Camera {
36 public:
37  enum class FovType { Vertical, Horizontal };
38  enum class Projection { Perspective, Ortho };
39  using Transform = Eigen::Transform<float, 3, Eigen::Affine>;
40 
41  virtual ~Camera() = default;
42 
43  virtual void SetProjection(double fov,
44  double aspect,
45  double near,
46  double far,
47  FovType fov_type) = 0;
48 
71  virtual void SetProjection(Projection projection,
72  double left,
73  double right,
74  double bottom,
75  double top,
76  double near,
77  double far) = 0;
78 
79  virtual double GetNear() const = 0;
80  virtual double GetFar() const = 0;
82  virtual double GetFieldOfView() const = 0;
84  virtual FovType GetFieldOfViewType() const = 0;
85 
86  virtual void SetModelMatrix(const Transform& view) = 0;
87  virtual void SetModelMatrix(const Eigen::Vector3f& forward,
88  const Eigen::Vector3f& left,
89  const Eigen::Vector3f& up) = 0;
90 
91  virtual void LookAt(const Eigen::Vector3f& center,
92  const Eigen::Vector3f& eye,
93  const Eigen::Vector3f& up) = 0;
94 
95  virtual Eigen::Vector3f GetPosition() const = 0;
96  virtual Eigen::Vector3f GetForwardVector() const = 0;
97  virtual Eigen::Vector3f GetLeftVector() const = 0;
98  virtual Eigen::Vector3f GetUpVector() const = 0;
99  virtual Transform GetModelMatrix() const = 0;
100  virtual Transform GetViewMatrix() const = 0;
101  virtual Transform GetProjectionMatrix() const = 0;
102 };
103 
104 } // namespace rendering
105 } // namespace visualization
106 } // namespace open3d
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
virtual void LookAt(const Eigen::Vector3f &center, const Eigen::Vector3f &eye, const Eigen::Vector3f &up)=0
virtual Transform GetModelMatrix() const =0
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:39
virtual void SetModelMatrix(const Transform &view)=0
Definition: PinholeCameraIntrinsic.cpp:35
virtual Eigen::Vector3f GetForwardVector() const =0
virtual Eigen::Vector3f GetPosition() const =0
virtual Transform GetProjectionMatrix() const =0
virtual double GetFar() const =0
virtual double GetNear() const =0
virtual Transform GetViewMatrix() const =0
virtual void SetProjection(double fov, double aspect, double near, double far, FovType fov_type)=0