Open3D (C++ API)
PickingShader.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 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 <vector>
30 #include <Eigen/Core>
32 
33 namespace open3d {
34 namespace visualization {
35 
36 namespace glsl {
37 
38 class PickingShader : public ShaderWrapper {
39 public:
40  ~PickingShader() override { Release(); }
41 
42 protected:
43  PickingShader(const std::string &name) : ShaderWrapper(name) { Compile(); }
44 
45 protected:
46  bool Compile() final;
47  void Release() final;
48  bool BindGeometry(const geometry::Geometry &geometry,
49  const RenderOption &option,
50  const ViewControl &view) final;
51  bool RenderGeometry(const geometry::Geometry &geometry,
52  const RenderOption &option,
53  const ViewControl &view) final;
54  void UnbindGeometry() final;
55 
56 protected:
57  virtual bool PrepareRendering(const geometry::Geometry &geometry,
58  const RenderOption &option,
59  const ViewControl &view) = 0;
60  virtual bool PrepareBinding(const geometry::Geometry &geometry,
61  const RenderOption &option,
62  const ViewControl &view,
63  std::vector<Eigen::Vector3f> &points,
64  std::vector<float> &indices) = 0;
65 
66 protected:
69  GLuint vertex_index_;
71  GLuint MVP_;
72 };
73 
75 public:
77  : PickingShader("PickingShaderForPointCloud") {}
78 
79 protected:
80  bool PrepareRendering(const geometry::Geometry &geometry,
81  const RenderOption &option,
82  const ViewControl &view) final;
83  bool PrepareBinding(const geometry::Geometry &geometry,
84  const RenderOption &option,
85  const ViewControl &view,
86  std::vector<Eigen::Vector3f> &points,
87  std::vector<float> &indices) final;
88 };
89 
90 } // namespace glsl
91 
92 } // namespace visualization
93 } // namespace open3d
Definition: Geometry.h:32
Definition: PickingShader.h:38
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: PickingShader.cpp:89
void Release() final
Definition: PickingShader.cpp:51
Definition: ViewControl.h:38
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: PickingShader.cpp:56
PickingShader(const std::string &name)
Definition: PickingShader.h:43
Definition: RenderOption.h:36
GLuint vertex_position_
Definition: PickingShader.h:67
~PickingShader() override
Definition: PickingShader.h:40
GLuint vertex_index_buffer_
Definition: PickingShader.h:70
PickingShaderForPointCloud()
Definition: PickingShader.h:76
bool Compile() final
Definition: PickingShader.cpp:39
int points
Definition: FilePCD.cpp:69
Definition: PinholeCameraIntrinsic.cpp:33
GLuint vertex_position_buffer_
Definition: PickingShader.h:68
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
std::string name
Definition: FilePCD.cpp:54
Definition: ShaderWrapper.h:40
GLuint vertex_index_
Definition: PickingShader.h:69
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< float > &indices)=0
GLuint MVP_
Definition: PickingShader.h:71
void UnbindGeometry() final
Definition: PickingShader.cpp:110