Open3D (C++ API)  0.18.0+252c867
NormalShader.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 <Eigen/Core>
11 #include <vector>
12 
14 
15 namespace open3d {
16 namespace visualization {
17 
18 namespace glsl {
19 
20 class NormalShader : public ShaderWrapper {
21 public:
22  ~NormalShader() override { Release(); }
23 
24 protected:
25  NormalShader(const std::string &name) : ShaderWrapper(name) { Compile(); }
26 
27 protected:
28  bool Compile() final;
29  void Release() final;
30  bool BindGeometry(const geometry::Geometry &geometry,
31  const RenderOption &option,
32  const ViewControl &view) final;
33  bool RenderGeometry(const geometry::Geometry &geometry,
34  const RenderOption &option,
35  const ViewControl &view) final;
36  void UnbindGeometry() final;
37 
38 protected:
39  virtual bool PrepareRendering(const geometry::Geometry &geometry,
40  const RenderOption &option,
41  const ViewControl &view) = 0;
42  virtual bool PrepareBinding(const geometry::Geometry &geometry,
43  const RenderOption &option,
44  const ViewControl &view,
45  std::vector<Eigen::Vector3f> &points,
46  std::vector<Eigen::Vector3f> &normals) = 0;
47 
48 protected:
53  GLuint MVP_;
54  GLuint V_;
55  GLuint M_;
56 };
57 
59 public:
60  NormalShaderForPointCloud() : NormalShader("NormalShaderForPointCloud") {}
61 
62 protected:
63  bool PrepareRendering(const geometry::Geometry &geometry,
64  const RenderOption &option,
65  const ViewControl &view) final;
66  bool PrepareBinding(const geometry::Geometry &geometry,
67  const RenderOption &option,
68  const ViewControl &view,
69  std::vector<Eigen::Vector3f> &points,
70  std::vector<Eigen::Vector3f> &normals) final;
71 };
72 
74 public:
76  : NormalShader("NormalShaderForTriangleMesh") {}
77 
78 protected:
79  bool PrepareRendering(const geometry::Geometry &geometry,
80  const RenderOption &option,
81  const ViewControl &view) final;
82  bool PrepareBinding(const geometry::Geometry &geometry,
83  const RenderOption &option,
84  const ViewControl &view,
85  std::vector<Eigen::Vector3f> &points,
86  std::vector<Eigen::Vector3f> &normals) final;
87 };
88 
89 } // namespace glsl
90 
91 } // namespace visualization
92 } // namespace open3d
The base geometry class.
Definition: Geometry.h:18
Defines rendering options for visualizer.
Definition: RenderOption.h:20
View controller for visualizer.
Definition: ViewControl.h:23
NormalShaderForPointCloud()
Definition: NormalShader.h:60
NormalShaderForTriangleMesh()
Definition: NormalShader.h:75
Definition: NormalShader.h:20
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: NormalShader.cpp:37
GLuint vertex_normal_
Definition: NormalShader.h:51
GLuint M_
Definition: NormalShader.h:55
GLuint MVP_
Definition: NormalShader.h:53
GLuint V_
Definition: NormalShader.h:54
~NormalShader() override
Definition: NormalShader.h:22
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
void UnbindGeometry() final
Definition: NormalShader.cpp:92
GLuint vertex_position_buffer_
Definition: NormalShader.h:50
GLuint vertex_normal_buffer_
Definition: NormalShader.h:52
NormalShader(const std::string &name)
Definition: NormalShader.h:25
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< Eigen::Vector3f > &normals)=0
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: NormalShader.cpp:69
void Release() final
Definition: NormalShader.cpp:32
bool Compile() final
Definition: NormalShader.cpp:19
GLuint vertex_position_
Definition: NormalShader.h:49
Definition: ShaderWrapper.h:21
std::string name
Definition: FilePCD.cpp:39
int points
Definition: FilePCD.cpp:54
Definition: NonRigidOptimizer.cpp:22
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Device.h:107