Open3D (C++ API)  0.15.1
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) 2018-2021 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 <utils/Entity.h>
30
32
34namespace filament {
35class Camera;
36class Engine;
37} // namespace filament
39
40namespace open3d {
41namespace visualization {
42namespace rendering {
43
44class FilamentCamera : public Camera {
45public:
46 explicit FilamentCamera(filament::Engine& engine);
48
49 void SetProjection(double fov,
50 double aspect,
51 double near,
52 double far,
53 FovType fov_type) override;
54
55 void SetProjection(Projection projection,
56 double left,
57 double right,
58 double bottom,
59 double top,
60 double near,
61 double far) override;
62
63 void SetProjection(const Eigen::Matrix3d& intrinsics,
64 double near,
65 double far,
66 double width,
67 double height) override;
68
69 void LookAt(const Eigen::Vector3f& center,
70 const Eigen::Vector3f& eye,
71 const Eigen::Vector3f& up) override;
72
73 void SetModelMatrix(const Transform& view) override;
74 void SetModelMatrix(const Eigen::Vector3f& forward,
75 const Eigen::Vector3f& left,
76 const Eigen::Vector3f& up) override;
77
78 double GetNear() const override;
79 double GetFar() const override;
81 double GetFieldOfView() const override;
83 FovType GetFieldOfViewType() const override;
84
85 Eigen::Vector3f GetPosition() const override;
86 Eigen::Vector3f GetForwardVector() const override;
87 Eigen::Vector3f GetLeftVector() const override;
88 Eigen::Vector3f GetUpVector() const override;
89 Transform GetModelMatrix() const override;
90 Transform GetViewMatrix() const override;
93 const ProjectionInfo& GetProjection() const override;
94
95 Eigen::Vector3f Unproject(float x,
96 float y,
97 float z,
98 float view_width,
99 float view_height) const override;
100
101 Eigen::Vector2f GetNDC(const Eigen::Vector3f& pt) const override;
102 double GetViewZ(float z_buffer) const override;
103
104 void CopyFrom(const Camera* camera) override;
105
106 filament::Camera* GetNativeCamera() const { return camera_; }
107
108private:
109 filament::Camera* camera_ = nullptr;
110 utils::Entity camera_entity_;
111 filament::Engine& engine_;
112 Camera::ProjectionInfo projection_;
113};
114
115} // namespace rendering
116} // namespace visualization
117} // namespace open3d
Eigen::Transform< float, 3, Eigen::Projective > ProjectionMatrix
Definition: Camera.h:45
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:44
~FilamentCamera()
Definition: FilamentCamera.cpp:90
double GetFar() const override
Definition: FilamentCamera.cpp:218
ProjectionMatrix GetProjectionMatrix() const override
Definition: FilamentCamera.cpp:290
double GetFieldOfView() const override
only valid if fov was passed to SetProjection()
Definition: FilamentCamera.cpp:220
Transform GetCullingProjectionMatrix() const override
Definition: FilamentCamera.cpp:300
Transform GetViewMatrix() const override
Definition: FilamentCamera.cpp:285
Eigen::Vector3f Unproject(float x, float y, float z, float view_width, float view_height) const override
Definition: FilamentCamera.cpp:349
filament::Camera * GetNativeCamera() const
Definition: FilamentCamera.h:106
double GetViewZ(float z_buffer) const override
Definition: FilamentCamera.cpp:318
Eigen::Vector3f GetUpVector() const override
Definition: FilamentCamera.cpp:275
void SetProjection(double fov, double aspect, double near, double far, FovType fov_type) override
Definition: FilamentCamera.cpp:123
Eigen::Vector3f GetForwardVector() const override
Definition: FilamentCamera.cpp:265
void SetModelMatrix(const Transform &view) override
Definition: FilamentCamera.cpp:344
FilamentCamera(filament::Engine &engine)
Definition: FilamentCamera.cpp:83
Eigen::Vector2f GetNDC(const Eigen::Vector3f &pt) const override
Definition: FilamentCamera.cpp:306
Eigen::Vector3f GetPosition() const override
Definition: FilamentCamera.cpp:260
void CopyFrom(const Camera *camera) override
Definition: FilamentCamera.cpp:96
Eigen::Vector3f GetLeftVector() const override
Definition: FilamentCamera.cpp:270
const ProjectionInfo & GetProjection() const override
Definition: FilamentCamera.cpp:327
Transform GetModelMatrix() const override
Definition: FilamentCamera.cpp:280
double GetNear() const override
Definition: FilamentCamera.cpp:216
FovType GetFieldOfViewType() const override
only valid if fov was passed to SetProjection()
Definition: FilamentCamera.cpp:236
void LookAt(const Eigen::Vector3f &center, const Eigen::Vector3f &eye, const Eigen::Vector3f &up) override
Definition: FilamentCamera.cpp:246
int width
Definition: FilePCD.cpp:71
int height
Definition: FilePCD.cpp:72
Definition: FilamentEngine.h:31
Definition: PinholeCameraIntrinsic.cpp:35