Open3D (C++ API)  0.18.0
FilamentCamera.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <utils/Entity.h>
11 
13 
15 namespace filament {
16 class Camera;
17 class Engine;
18 } // namespace filament
20 
21 namespace open3d {
22 namespace visualization {
23 namespace rendering {
24 
25 class FilamentCamera : public Camera {
26 public:
27  explicit FilamentCamera(filament::Engine& engine);
29 
30  void SetProjection(double fov,
31  double aspect,
32  double near,
33  double far,
34  FovType fov_type) override;
35 
36  void SetProjection(Projection projection,
37  double left,
38  double right,
39  double bottom,
40  double top,
41  double near,
42  double far) override;
43 
44  void SetProjection(const Eigen::Matrix3d& intrinsics,
45  double near,
46  double far,
47  double width,
48  double height) override;
49 
50  void LookAt(const Eigen::Vector3f& center,
51  const Eigen::Vector3f& eye,
52  const Eigen::Vector3f& up) override;
53 
54  void SetModelMatrix(const Transform& view) override;
55  void SetModelMatrix(const Eigen::Vector3f& forward,
56  const Eigen::Vector3f& left,
57  const Eigen::Vector3f& up) override;
58 
59  double GetNear() const override;
60  double GetFar() const override;
62  double GetFieldOfView() const override;
64  FovType GetFieldOfViewType() const override;
65 
66  Eigen::Vector3f GetPosition() const override;
67  Eigen::Vector3f GetForwardVector() const override;
68  Eigen::Vector3f GetLeftVector() const override;
69  Eigen::Vector3f GetUpVector() const override;
70  Transform GetModelMatrix() const override;
71  Transform GetViewMatrix() const override;
72  ProjectionMatrix GetProjectionMatrix() const override;
73  Transform GetCullingProjectionMatrix() const override;
74  const ProjectionInfo& GetProjection() const override;
75 
76  Eigen::Vector3f Unproject(float x,
77  float y,
78  float z,
79  float view_width,
80  float view_height) const override;
81 
82  Eigen::Vector2f GetNDC(const Eigen::Vector3f& pt) const override;
83  double GetViewZ(float z_buffer) const override;
84 
85  void CopyFrom(const Camera* camera) override;
86 
87  filament::Camera* GetNativeCamera() const { return camera_; }
88 
89 private:
90  filament::Camera* camera_ = nullptr;
91  utils::Entity camera_entity_;
92  filament::Engine& engine_;
93  Camera::ProjectionInfo projection_;
94 };
95 
96 } // namespace rendering
97 } // namespace visualization
98 } // namespace open3d
Eigen::Transform< float, 3, Eigen::Projective > ProjectionMatrix
Definition: Camera.h:26
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:25
~FilamentCamera()
Definition: FilamentCamera.cpp:71
double GetFar() const override
Definition: FilamentCamera.cpp:199
ProjectionMatrix GetProjectionMatrix() const override
Definition: FilamentCamera.cpp:271
double GetFieldOfView() const override
only valid if fov was passed to SetProjection()
Definition: FilamentCamera.cpp:201
Transform GetCullingProjectionMatrix() const override
Definition: FilamentCamera.cpp:281
Transform GetViewMatrix() const override
Definition: FilamentCamera.cpp:266
filament::Camera * GetNativeCamera() const
Definition: FilamentCamera.h:87
Eigen::Vector3f Unproject(float x, float y, float z, float view_width, float view_height) const override
Definition: FilamentCamera.cpp:330
double GetViewZ(float z_buffer) const override
Definition: FilamentCamera.cpp:299
Eigen::Vector3f GetUpVector() const override
Definition: FilamentCamera.cpp:256
void SetProjection(double fov, double aspect, double near, double far, FovType fov_type) override
Definition: FilamentCamera.cpp:104
Eigen::Vector3f GetForwardVector() const override
Definition: FilamentCamera.cpp:246
void SetModelMatrix(const Transform &view) override
Definition: FilamentCamera.cpp:325
FilamentCamera(filament::Engine &engine)
Definition: FilamentCamera.cpp:64
Eigen::Vector2f GetNDC(const Eigen::Vector3f &pt) const override
Definition: FilamentCamera.cpp:287
Eigen::Vector3f GetPosition() const override
Definition: FilamentCamera.cpp:241
void CopyFrom(const Camera *camera) override
Definition: FilamentCamera.cpp:77
Eigen::Vector3f GetLeftVector() const override
Definition: FilamentCamera.cpp:251
const ProjectionInfo & GetProjection() const override
Definition: FilamentCamera.cpp:308
Transform GetModelMatrix() const override
Definition: FilamentCamera.cpp:261
double GetNear() const override
Definition: FilamentCamera.cpp:197
FovType GetFieldOfViewType() const override
only valid if fov was passed to SetProjection()
Definition: FilamentCamera.cpp:217
void LookAt(const Eigen::Vector3f &center, const Eigen::Vector3f &eye, const Eigen::Vector3f &up) override
Definition: FilamentCamera.cpp:227
int width
Definition: FilePCD.cpp:52
int height
Definition: FilePCD.cpp:53
Definition: FilamentEngine.h:12
Definition: PinholeCameraIntrinsic.cpp:16