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

Detailed Description

A triangle (float coordinates) with RGBA colors (u8) and UV (texture coordinates) for each vertex.

Note that not all the fields must be filled in, it depends on the consumer of the structure.

The structure is memory packed to 1-byte, to ensure it can be used in GPU memory vertex arrays without unexpected paddings.

See also
opengl::COpenGLScene, CSetOfTexturedTriangles

Definition at line 35 of file TTriangle.h.

#include <mrpt/opengl/TTriangle.h>

Classes

struct  Vertex
 

Public Member Functions

 TTriangle ()=default
 
 TTriangle (const mrpt::math::TPolygon3D &p)
 
 TTriangle (const mrpt::math::TPoint3Df &p1, const mrpt::math::TPoint3Df &p2, const mrpt::math::TPoint3Df &p3)
 Constructor from 3 points (default normals are computed) More...
 
 TTriangle (const mrpt::math::TPoint3Df &p1, const mrpt::math::TPoint3Df &p2, const mrpt::math::TPoint3Df &p3, const mrpt::math::TVector3Df &n1, const mrpt::math::TVector3Df &n2, const mrpt::math::TVector3Df &n3)
 Constructor from 3 points and its 3 normals. More...
 
const float & x (size_t i) const
 
const float & y (size_t i) const
 
const float & z (size_t i) const
 
const uint8_t & r (size_t i) const
 
const uint8_t & g (size_t i) const
 
const uint8_t & b (size_t i) const
 
const uint8_t & a (size_t i) const
 
const float & u (size_t i) const
 
const float & v (size_t i) const
 
float & x (size_t i)
 
float & y (size_t i)
 
float & z (size_t i)
 
uint8_t & r (size_t i)
 
uint8_t & g (size_t i)
 
uint8_t & b (size_t i)
 
uint8_t & a (size_t i)
 
float & u (size_t i)
 
float & v (size_t i)
 
mrpt::math::TPoint3Dfvertex (size_t i)
 
const mrpt::math::TPoint3Dfvertex (size_t i) const
 
void setColor (const mrpt::img::TColor &c)
 Sets the color of all vertices. More...
 
void setColor (const mrpt::img::TColorf &c)
 
void computeNormals ()
 Compute the three normals from the cross-product of "v01 x v02". More...
 
void readFrom (mrpt::serialization::CArchive &i)
 
void writeTo (mrpt::serialization::CArchive &o) const
 

Public Attributes

std::array< Vertex, 3 > vertices
 

Constructor & Destructor Documentation

◆ TTriangle() [1/4]

mrpt::opengl::TTriangle::TTriangle ( )
default

◆ TTriangle() [2/4]

mrpt::opengl::TTriangle::TTriangle ( const mrpt::math::TPolygon3D p)
inlineexplicit

Definition at line 53 of file TTriangle.h.

References ASSERT_EQUAL_, computeNormals(), and vertices.

Here is the call graph for this function:

◆ TTriangle() [3/4]

mrpt::opengl::TTriangle::TTriangle ( const mrpt::math::TPoint3Df p1,
const mrpt::math::TPoint3Df p2,
const mrpt::math::TPoint3Df p3 
)
inlineexplicit

Constructor from 3 points (default normals are computed)

Definition at line 65 of file TTriangle.h.

References computeNormals(), and vertices.

Here is the call graph for this function:

◆ TTriangle() [4/4]

mrpt::opengl::TTriangle::TTriangle ( const mrpt::math::TPoint3Df p1,
const mrpt::math::TPoint3Df p2,
const mrpt::math::TPoint3Df p3,
const mrpt::math::TVector3Df n1,
const mrpt::math::TVector3Df n2,
const mrpt::math::TVector3Df n3 
)
inlineexplicit

Constructor from 3 points and its 3 normals.

Definition at line 75 of file TTriangle.h.

References vertices.

Member Function Documentation

◆ a() [1/2]

const uint8_t& mrpt::opengl::TTriangle::a ( size_t  i) const
inline

Definition at line 96 of file TTriangle.h.

References vertices.

Referenced by mrpt::maps::CRandomFieldGridMap2D::getAs3DObject(), mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::stock_objects::RobotPioneer(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ a() [2/2]

uint8_t& mrpt::opengl::TTriangle::a ( size_t  i)
inline

Definition at line 105 of file TTriangle.h.

References vertices.

◆ b() [1/2]

const uint8_t& mrpt::opengl::TTriangle::b ( size_t  i) const
inline

Definition at line 95 of file TTriangle.h.

References vertices.

Referenced by mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::stock_objects::RobotPioneer(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ b() [2/2]

uint8_t& mrpt::opengl::TTriangle::b ( size_t  i)
inline

Definition at line 104 of file TTriangle.h.

References vertices.

◆ computeNormals()

void TTriangle::computeNormals ( )

Compute the three normals from the cross-product of "v01 x v02".

Note that using this default normals will not lead to interpolated lighting in the fragment shaders, since all vertex are equal; a derived class should use custom, more accurate normals to enable soft lighting.

Definition at line 21 of file TTriangle.cpp.

References v(), vertices, x(), y(), and z().

Referenced by mrpt::opengl::CAngularObservationMesh::addTriangle(), mrpt::opengl::CColorBar::onUpdateBuffers_all(), mrpt::opengl::stock_objects::RobotPioneer(), and TTriangle().

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

◆ g() [1/2]

const uint8_t& mrpt::opengl::TTriangle::g ( size_t  i) const
inline

Definition at line 94 of file TTriangle.h.

References vertices.

Referenced by mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::stock_objects::RobotPioneer(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ g() [2/2]

uint8_t& mrpt::opengl::TTriangle::g ( size_t  i)
inline

Definition at line 103 of file TTriangle.h.

References vertices.

◆ r() [1/2]

const uint8_t& mrpt::opengl::TTriangle::r ( size_t  i) const
inline

Definition at line 93 of file TTriangle.h.

References vertices.

Referenced by mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::stock_objects::RobotPioneer(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ r() [2/2]

uint8_t& mrpt::opengl::TTriangle::r ( size_t  i)
inline

Definition at line 102 of file TTriangle.h.

References vertices.

◆ readFrom()

void TTriangle::readFrom ( mrpt::serialization::CArchive i)

Definition at line 43 of file TTriangle.cpp.

References vertices.

◆ setColor() [1/2]

void mrpt::opengl::TTriangle::setColor ( const mrpt::img::TColor c)
inline

Sets the color of all vertices.

Definition at line 116 of file TTriangle.h.

References mrpt::img::TColor::A, mrpt::img::TColor::B, mrpt::img::TColor::G, mrpt::img::TColor::R, and vertices.

Referenced by mrpt::opengl::CAngularObservationMesh::addTriangle(), mrpt::opengl::stock_objects::RobotPioneer(), and setColor().

Here is the caller graph for this function:

◆ setColor() [2/2]

void mrpt::opengl::TTriangle::setColor ( const mrpt::img::TColorf c)
inline

Definition at line 126 of file TTriangle.h.

References mrpt::img::TColorf::A, mrpt::img::TColorf::B, mrpt::f2u8(), mrpt::img::TColorf::G, mrpt::img::TColorf::R, and setColor().

Here is the call graph for this function:

◆ u() [1/2]

const float& mrpt::opengl::TTriangle::u ( size_t  i) const
inline

Definition at line 97 of file TTriangle.h.

References vertices.

◆ u() [2/2]

float& mrpt::opengl::TTriangle::u ( size_t  i)
inline

Definition at line 106 of file TTriangle.h.

References vertices.

◆ v() [1/2]

const float& mrpt::opengl::TTriangle::v ( size_t  i) const
inline

Definition at line 98 of file TTriangle.h.

References vertices.

Referenced by computeNormals().

Here is the caller graph for this function:

◆ v() [2/2]

float& mrpt::opengl::TTriangle::v ( size_t  i)
inline

Definition at line 107 of file TTriangle.h.

References vertices.

◆ vertex() [1/2]

mrpt::math::TPoint3Df& mrpt::opengl::TTriangle::vertex ( size_t  i)
inline

Definition at line 109 of file TTriangle.h.

References vertices.

Referenced by createPolygonFromTriangle(), and mrpt::opengl::stock_objects::RobotPioneer().

Here is the caller graph for this function:

◆ vertex() [2/2]

const mrpt::math::TPoint3Df& mrpt::opengl::TTriangle::vertex ( size_t  i) const
inline

Definition at line 110 of file TTriangle.h.

References vertices.

◆ writeTo()

void TTriangle::writeTo ( mrpt::serialization::CArchive o) const

Definition at line 35 of file TTriangle.cpp.

References vertices.

◆ x() [1/2]

const float& mrpt::opengl::TTriangle::x ( size_t  i) const
inline

Definition at line 90 of file TTriangle.h.

References vertices.

Referenced by computeNormals(), mrpt::maps::CRandomFieldGridMap2D::getAs3DObject(), mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::CSetOfTriangles::updatePolygons(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ x() [2/2]

float& mrpt::opengl::TTriangle::x ( size_t  i)
inline

Definition at line 99 of file TTriangle.h.

References vertices.

◆ y() [1/2]

const float& mrpt::opengl::TTriangle::y ( size_t  i) const
inline

Definition at line 91 of file TTriangle.h.

References vertices.

Referenced by computeNormals(), mrpt::maps::CRandomFieldGridMap2D::getAs3DObject(), mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::CSetOfTriangles::updatePolygons(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ y() [2/2]

float& mrpt::opengl::TTriangle::y ( size_t  i)
inline

Definition at line 100 of file TTriangle.h.

References vertices.

◆ z() [1/2]

const float& mrpt::opengl::TTriangle::z ( size_t  i) const
inline

Definition at line 92 of file TTriangle.h.

References vertices.

Referenced by computeNormals(), mrpt::maps::CRandomFieldGridMap2D::getAs3DObject(), mrpt::opengl::CMesh::onUpdateBuffers_Wireframe(), mrpt::opengl::CSetOfTriangles::updatePolygons(), and mrpt::opengl::CMesh::updateTriangles().

Here is the caller graph for this function:

◆ z() [2/2]

float& mrpt::opengl::TTriangle::z ( size_t  i)
inline

Definition at line 101 of file TTriangle.h.

References vertices.

Member Data Documentation

◆ vertices

std::array<Vertex, 3> mrpt::opengl::TTriangle::vertices



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