Open3D (C++ API)  0.13.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FilamentCamera.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 
30 
32 namespace filament {
33 class Camera;
34 class Engine;
35 } // namespace filament
37 
38 namespace open3d {
39 namespace visualization {
40 namespace rendering {
41 
42 class FilamentCamera : public Camera {
43 public:
44  explicit FilamentCamera(filament::Engine& engine);
45  ~FilamentCamera();
46 
47  void SetProjection(double fov,
48  double aspect,
49  double near,
50  double far,
51  FovType fov_type) override;
52 
53  void SetProjection(Projection projection,
54  double left,
55  double right,
56  double bottom,
57  double top,
58  double near,
59  double far) override;
60 
61  void SetProjection(const Eigen::Matrix3d& intrinsics,
62  double near,
63  double far,
64  double width,
65  double height) override;
66 
67  void LookAt(const Eigen::Vector3f& center,
68  const Eigen::Vector3f& eye,
69  const Eigen::Vector3f& up) override;
70 
71  void SetModelMatrix(const Transform& view) override;
72  void SetModelMatrix(const Eigen::Vector3f& forward,
73  const Eigen::Vector3f& left,
74  const Eigen::Vector3f& up) override;
75 
76  double GetNear() const override;
77  double GetFar() const override;
79  double GetFieldOfView() const override;
81  FovType GetFieldOfViewType() const override;
82 
83  Eigen::Vector3f GetPosition() const override;
84  Eigen::Vector3f GetForwardVector() const override;
85  Eigen::Vector3f GetLeftVector() const override;
86  Eigen::Vector3f GetUpVector() const override;
87  Transform GetModelMatrix() const override;
88  Transform GetViewMatrix() const override;
89  ProjectionMatrix GetProjectionMatrix() const override;
90  Transform GetCullingProjectionMatrix() const override;
91  const ProjectionInfo& GetProjection() const override;
92 
93  Eigen::Vector3f Unproject(float x,
94  float y,
95  float z,
96  float view_width,
97  float view_height) const override;
98 
99  Eigen::Vector2f GetNDC(const Eigen::Vector3f& pt) const override;
100 
101  void CopyFrom(const Camera* camera) override;
102 
103  filament::Camera* GetNativeCamera() const { return camera_; }
104 
105 private:
106  filament::Camera* camera_ = nullptr;
107  filament::Engine& engine_;
108  Camera::ProjectionInfo projection_;
109 };
110 
111 } // namespace rendering
112 } // namespace visualization
113 } // namespace open3d
Eigen::Transform< float, 3, Eigen::Projective > ProjectionMatrix
Definition: Camera.h:45
GLMatrix4f LookAt(const Eigen::Vector3d &eye, const Eigen::Vector3d &lookat, const Eigen::Vector3d &up)
Definition: GLHelper.cpp:36
filament::Camera * GetNativeCamera() const
Definition: FilamentCamera.h:103
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:44
Definition: PinholeCameraIntrinsic.cpp:35
int height
Definition: FilePCD.cpp:72
void Unproject(const core::Tensor &depth, utility::optional< std::reference_wrapper< const core::Tensor >> image_colors, core::Tensor &points, utility::optional< std::reference_wrapper< core::Tensor >> colors, const core::Tensor &intrinsics, const core::Tensor &extrinsics, float depth_scale, float depth_max, int64_t stride)
Definition: PointCloud.cpp:42
Definition: FilamentEngine.h:31
int width
Definition: FilePCD.cpp:71