MRPT  2.0.0
List of all members | Public Member Functions | Public Attributes
mrpt::opengl::TRenderMatrices Struct Reference

Detailed Description

Rendering state related to the projection and model-view matrices.

Used to store matrices that will be sent to shaders.

The homogeneous coordinates of a rendered point comes from:

p = p_matrix * mv_matrix * [x y z 1.0]'

Definition at line 25 of file TRenderMatrices.h.

#include <mrpt/opengl/TRenderMatrices.h>

Public Member Functions

 TRenderMatrices ()=default
 
void computeProjectionMatrix (float zmin, float zmax)
 Uses is_projective , vw,vh, etc. More...
 
void computeOrthoProjectionMatrix (float left, float right, float bottom, float top, float znear, float zfar)
 Especial case for custom parameters of Orthographic projection. More...
 
void applyLookAt ()
 Updates the current p_matrix such that it "looks at" pointing, with up vector "up". More...
 
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 local coordinates (wrt to the current model matrix) of (x,y,z). More...
 
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. More...
 

Public Attributes

mrpt::math::TPoint3D eye = {0, 0, 0}
 The camera is here. More...
 
mrpt::math::TPoint3D pointing = {0, 0, 0}
 The camera points to here. More...
 
mrpt::math::TPoint3D up = {0, 0, 0}
 Up vector of the camera. More...
 
size_t viewport_width = 640
 In pixels. More...
 
size_t viewport_height = 480
 
double FOV = 30.0f
 Vertical FOV in degrees. More...
 
double azimuth = .0
 Camera elev & azimuth, in radians. More...
 
double elev = .0
 
double eyeDistance = 1.0f
 
bool is_projective = true
 true: projective, false: ortho More...
 
mrpt::math::CMatrixFloat44 p_matrix
 Projection matrix, computed by renderNormalScene() from all the parameters above. More...
 
mrpt::math::CMatrixFloat44 mv_matrix
 Model-view matrix. More...
 
mrpt::math::CMatrixFloat44 pmv_matrix
 Result of p_matrix * mv_matrix. More...
 

Constructor & Destructor Documentation

◆ TRenderMatrices()

mrpt::opengl::TRenderMatrices::TRenderMatrices ( )
default

Member Function Documentation

◆ applyLookAt()

void TRenderMatrices::applyLookAt ( )

Updates the current p_matrix such that it "looks at" pointing, with up vector "up".

Replacement for deprecated OpenGL gluLookAt().

Definition at line 84 of file TRenderMatrices.cpp.

References mrpt::math::CMatrixFixed< T, ROWS, COLS >::asEigen(), ASSERT_, mrpt::math::crossProduct3D(), mrpt::d2f(), eye, p_matrix, pointing, mrpt::math::UNINITIALIZED_MATRIX, and up.

Here is the call graph for this function:

◆ computeOrthoProjectionMatrix()

void TRenderMatrices::computeOrthoProjectionMatrix ( float  left,
float  right,
float  bottom,
float  top,
float  znear,
float  zfar 
)

Especial case for custom parameters of Orthographic projection.

Replacement for obsolete: glOrtho()

Definition at line 19 of file TRenderMatrices.cpp.

References ASSERT_ABOVE_, p_matrix, and mrpt::math::MatrixBase< Scalar, Derived >::setIdentity().

Referenced by computeProjectionMatrix(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeProjectionMatrix()

void TRenderMatrices::computeProjectionMatrix ( float  zmin,
float  zmax 
)

Uses is_projective , vw,vh, etc.

and computes p_matrix. Replacement for obsolete: gluPerspective() and glOrtho()

Definition at line 35 of file TRenderMatrices.cpp.

References ASSERT_ABOVE_, ASSERT_ABOVEEQ_, computeOrthoProjectionMatrix(), mrpt::DEG2RAD(), eyeDistance, FOV, is_projective, p_matrix, mrpt::math::MatrixVectorBase< Scalar, Derived >::setZero(), viewport_height, and viewport_width.

Referenced by TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ projectPoint()

void TRenderMatrices::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 local coordinates (wrt to the current model matrix) of (x,y,z).

The output proj_z_depth is the real distance from the eye to the point.

Definition at line 138 of file TRenderMatrices.cpp.

References mrpt::math::CMatrixFixed< T, ROWS, COLS >::asEigen(), and pmv_matrix.

Referenced by projectPointPixels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ projectPointPixels()

void TRenderMatrices::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.

Definition at line 150 of file TRenderMatrices.cpp.

References projectPoint(), viewport_height, and viewport_width.

Referenced by mrpt::opengl::COctreePointRenderer< CPointCloudColoured >::octree_recursive_render().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ azimuth

double mrpt::opengl::TRenderMatrices::azimuth = .0

Camera elev & azimuth, in radians.

Definition at line 43 of file TRenderMatrices.h.

Referenced by mrpt::opengl::COpenGLViewport::get3DRayForPixelCoord().

◆ elev

double mrpt::opengl::TRenderMatrices::elev = .0

◆ eye

mrpt::math::TPoint3D mrpt::opengl::TRenderMatrices::eye = {0, 0, 0}

The camera is here.

Definition at line 30 of file TRenderMatrices.h.

Referenced by applyLookAt(), and mrpt::opengl::COpenGLViewport::get3DRayForPixelCoord().

◆ eyeDistance

double mrpt::opengl::TRenderMatrices::eyeDistance = 1.0f

◆ FOV

double mrpt::opengl::TRenderMatrices::FOV = 30.0f

Vertical FOV in degrees.

Definition at line 41 of file TRenderMatrices.h.

Referenced by computeProjectionMatrix(), mrpt::opengl::COpenGLViewport::get3DRayForPixelCoord(), and TEST().

◆ is_projective

bool mrpt::opengl::TRenderMatrices::is_projective = true

◆ mv_matrix

mrpt::math::CMatrixFloat44 mrpt::opengl::TRenderMatrices::mv_matrix

◆ p_matrix

mrpt::math::CMatrixFloat44 mrpt::opengl::TRenderMatrices::p_matrix

Projection matrix, computed by renderNormalScene() from all the parameters above.

Used in shaders.

Definition at line 50 of file TRenderMatrices.h.

Referenced by applyLookAt(), computeOrthoProjectionMatrix(), computeProjectionMatrix(), mrpt::opengl::processRenderQueue(), mrpt::opengl::COpenGLViewport::renderTextMessages(), and TEST().

◆ pmv_matrix

mrpt::math::CMatrixFloat44 mrpt::opengl::TRenderMatrices::pmv_matrix

Result of p_matrix * mv_matrix.

Used in shaders. Updated by renderSetOfObjects()

Definition at line 58 of file TRenderMatrices.h.

Referenced by mrpt::opengl::processRenderQueue(), projectPoint(), and mrpt::opengl::CText::render().

◆ pointing

mrpt::math::TPoint3D mrpt::opengl::TRenderMatrices::pointing = {0, 0, 0}

The camera points to here.

Definition at line 33 of file TRenderMatrices.h.

Referenced by applyLookAt().

◆ up

mrpt::math::TPoint3D mrpt::opengl::TRenderMatrices::up = {0, 0, 0}

Up vector of the camera.

Definition at line 36 of file TRenderMatrices.h.

Referenced by applyLookAt().

◆ viewport_height

size_t mrpt::opengl::TRenderMatrices::viewport_height = 480

◆ viewport_width

size_t mrpt::opengl::TRenderMatrices::viewport_width = 640



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020