Open3D (C++ API)
GLHelper.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 <string>
30 
31 #include <Eigen/Core>
32 #include <GLFW/glfw3.h>
33 
34 namespace open3d {
35 namespace visualization {
36 namespace GLHelper {
37 
38 typedef Eigen::Matrix<GLfloat, 3, 1, Eigen::ColMajor> GLVector3f;
39 typedef Eigen::Matrix<GLfloat, 4, 1, Eigen::ColMajor> GLVector4f;
40 typedef Eigen::Matrix<GLfloat, 4, 4, Eigen::ColMajor> GLMatrix4f;
41 
42 GLMatrix4f LookAt(const Eigen::Vector3d &eye,
43  const Eigen::Vector3d &lookat,
44  const Eigen::Vector3d &up);
45 
46 GLMatrix4f Perspective(double field_of_view_,
47  double aspect,
48  double z_near,
49  double z_far);
50 
51 GLMatrix4f Ortho(double left,
52  double right,
53  double bottom,
54  double top,
55  double z_near,
56  double z_far);
57 
58 Eigen::Vector3d Project(const Eigen::Vector3d &point,
59  const GLMatrix4f &mvp_matrix,
60  const int width,
61  const int height);
62 
63 Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point,
64  const GLMatrix4f &mvp_matrix,
65  const int width,
66  const int height);
67 
68 int ColorCodeToPickIndex(const Eigen::Vector4i &color);
69 
70 } // namespace GLHelper
71 } // namespace visualization
72 } // namespace open3d
Eigen::Matrix< GLfloat, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:38
Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:102
int ColorCodeToPickIndex(const Eigen::Vector4i &color)
Definition: GLHelper.cpp:118
GLMatrix4f Perspective(double field_of_view_, double aspect, double z_near, double z_far)
Definition: GLHelper.cpp:55
Eigen::Matrix< GLfloat, 4, 1, Eigen::ColMajor > GLVector4f
Definition: GLHelper.h:39
Eigen::Matrix< GLfloat, 4, 4, Eigen::ColMajor > GLMatrix4f
Definition: GLHelper.h:40
Eigen::Vector3d Project(const Eigen::Vector3d &point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:87
GLMatrix4f LookAt(const Eigen::Vector3d &eye, const Eigen::Vector3d &lookat, const Eigen::Vector3d &up)
Definition: GLHelper.cpp:36
Definition: PinholeCameraIntrinsic.cpp:33
int height
Definition: FilePCD.cpp:68
int width
Definition: FilePCD.cpp:67
GLMatrix4f Ortho(double left, double right, double bottom, double top, double z_near, double z_far)
Definition: GLHelper.cpp:70