Open3D (C++ API)  0.12.0
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  Transform GetProjectionMatrix() const override;
90  const ProjectionInfo& GetProjection() const override;
91 
92  Eigen::Vector2f GetNDC(const Eigen::Vector3f& pt) const override;
93 
94  void CopyFrom(const Camera* camera) override;
95 
96  filament::Camera* GetNativeCamera() const { return camera_; }
97 
98 private:
99  filament::Camera* camera_ = nullptr;
100  filament::Engine& engine_;
101  Camera::ProjectionInfo projection_;
102 };
103 
104 } // namespace rendering
105 } // namespace visualization
106 } // namespace open3d
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:96
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:39
Definition: PinholeCameraIntrinsic.cpp:35
int height
Definition: FilePCD.cpp:72
Definition: FilamentEngine.h:31
int width
Definition: FilePCD.cpp:71