MRPT  2.0.4
TRenderMatrices.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/math/CMatrixFixed.h>
12 #include <mrpt/math/TPoint3D.h>
13 
14 namespace mrpt::opengl
15 {
16 /** Rendering state related to the projection and model-view matrices.
17  * Used to store matrices that will be sent to shaders.
18  *
19  * The homogeneous coordinates of a rendered point comes from:
20  *
21  * p = p_matrix * mv_matrix * [x y z 1.0]'
22  *
23  * \ingroup mrpt_opengl_grp
24  */
26 {
27  TRenderMatrices() = default;
28 
29  /** The camera is here. */
31 
32  /** The camera points to here */
34 
35  /** Up vector of the camera. */
36  mrpt::math::TPoint3D up = {0, 0, 0};
37 
38  /** In pixels. This may be smaller than the total render window. */
39  size_t viewport_width = 640, viewport_height = 480;
40  /** Vertical FOV in degrees. */
41  double FOV = 30.0f;
42  /** Camera elev & azimuth, in radians. */
43  double azimuth = .0, elev = .0;
44  double eyeDistance = 1.0f;
45  /** true: projective, false: ortho */
46  bool is_projective = true;
47 
48  /** Projection matrix, computed by renderNormalScene() from all the
49  * parameters above. Used in shaders. */
51 
52  /** Model-view matrix. */
54 
55  /** Result of p_matrix * mv_matrix. Used in shaders.
56  * Updated by renderSetOfObjects()
57  */
59 
60  /** Uses is_projective , vw,vh, etc. and computes p_matrix.
61  * Replacement for obsolete: gluPerspective() and glOrtho() */
62  void computeProjectionMatrix(float zmin, float zmax);
63 
64  /** Especial case for custom parameters of Orthographic projection.
65  * Replacement for obsolete: glOrtho()*/
67  float left, float right, float bottom, float top, float znear,
68  float zfar);
69 
70  /** Updates the current p_matrix such that it "looks at" pointing, with
71  * up vector "up". Replacement for deprecated OpenGL gluLookAt(). */
72  void applyLookAt();
73 
74  /** Computes the normalized coordinates (range=[0,1]) on the current
75  * rendering viewport of a
76  * point with local coordinates (wrt to the current model matrix) of
77  * (x,y,z).
78  * The output proj_z_depth is the real distance from the eye to the point.
79  */
80  void projectPoint(
81  float x, float y, float z, float& proj_u, float& proj_v,
82  float& proj_z_depth) const;
83 
84  /** Projects a point from global world coordinates into (u,v) pixel
85  * coordinates. */
86  void projectPointPixels(
87  float x, float y, float z, float& proj_u_px, float& proj_v_px,
88  float& proj_depth) const;
89 };
90 
91 } // namespace mrpt::opengl
mrpt::math::TPoint3D up
Up vector of the camera.
void computeProjectionMatrix(float zmin, float zmax)
Uses is_projective , vw,vh, etc.
mrpt::math::CMatrixFloat44 pmv_matrix
Result of p_matrix * mv_matrix.
void projectPointPixels(float x, float y, float z, float &proj_u_px, float &proj_v_px, float &proj_depth) const
Projects a point from global world coordinates into (u,v) pixel coordinates.
void applyLookAt()
Updates the current p_matrix such that it "looks at" pointing, with up vector "up".
mrpt::math::CMatrixFloat44 mv_matrix
Model-view matrix.
Rendering state related to the projection and model-view matrices.
void computeOrthoProjectionMatrix(float left, float right, float bottom, float top, float znear, float zfar)
Especial case for custom parameters of Orthographic projection.
double azimuth
Camera elev & azimuth, in radians.
size_t viewport_width
In pixels.
mrpt::math::TPoint3D eye
The camera is here.
void projectPoint(float x, float y, float z, float &proj_u, float &proj_v, float &proj_z_depth) const
Computes the normalized coordinates (range=[0,1]) on the current rendering viewport of a point with l...
mrpt::math::TPoint3D pointing
The camera points to here.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
double FOV
Vertical FOV in degrees.
mrpt::math::CMatrixFloat44 p_matrix
Projection matrix, computed by renderNormalScene() from all the parameters above. ...
bool is_projective
true: projective, false: ortho



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020