MRPT  1.9.9
CGridPlaneXZ.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, 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 
10 #include "opengl-precomp.h" // Precompiled header
11 
14 
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 
20 using namespace std;
21 
23 
24 /** Constructor */
26  float xMin, float xMax, float zMin, float zMax, float y, float frequency,
27  float lineWidth, bool antiAliasing)
28  : m_xMin(xMin),
29  m_xMax(xMax),
30  m_zMin(zMin),
31  m_zMax(zMax),
32  m_plane_y(y),
33  m_frequency(frequency),
34  m_lineWidth(lineWidth),
35  m_antiAliasing(antiAliasing)
36 {
37 }
38 
39 /*---------------------------------------------------------------
40  render
41  ---------------------------------------------------------------*/
43 {
44 #if MRPT_HAS_OPENGL_GLUT
45  ASSERT_(m_frequency >= 0);
46 
47  // Enable antialiasing:
48  if (m_antiAliasing)
49  {
54  }
55  glLineWidth(m_lineWidth);
56 
57  glDisable(GL_LIGHTING); // Disable lights when drawing lines
59 
60  ASSERT_(m_frequency >= 0);
61 
62  for (float z = m_zMin; z <= m_zMax; z += m_frequency)
63  {
64  glVertex3f(m_xMin, m_plane_y, z);
65  glVertex3f(m_xMax, m_plane_y, z);
66  }
67 
68  for (float x = m_xMin; x <= m_xMax; x += m_frequency)
69  {
70  glVertex3f(x, m_plane_y, m_zMin);
71  glVertex3f(x, m_plane_y, m_zMax);
72  }
73 
74  glEnd();
76 
77  // End antialiasing:
78  if (m_antiAliasing)
79  {
80  glPopAttrib();
82  }
83 #endif
84 }
85 
88 {
89  writeToStreamRender(out);
90  out << m_xMin << m_xMax;
91  out << m_zMin << m_zMax << m_plane_y;
92  out << m_frequency;
93  out << m_lineWidth << m_antiAliasing; // v1
94 }
95 
98 {
99  switch (version)
100  {
101  case 0:
102  case 1:
103  {
104  readFromStreamRender(in);
105  in >> m_xMin >> m_xMax;
106  in >> m_zMin >> m_zMax >> m_plane_y;
107  in >> m_frequency;
108  if (version >= 1)
109  in >> m_lineWidth >> m_antiAliasing;
110  else
111  {
112  m_lineWidth = 1.0f;
113  m_antiAliasing = true;
114  }
115  }
116  break;
117  default:
119  };
121 }
122 
125 {
126  bb_min.x = m_xMin;
127  bb_min.y = 0;
128  bb_min.z = m_zMin;
129 
130  bb_max.x = m_xMax;
131  bb_max.y = 0;
132  bb_max.z = m_zMax;
133 
134  // Convert to coordinates of my parent:
135  m_pose.composePoint(bb_min, bb_min);
136  m_pose.composePoint(bb_max, bb_max);
137 }
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
GLdouble GLdouble z
Definition: glext.h:3879
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
STL namespace.
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:288
GLAPI void GLAPIENTRY glPopAttrib(void)
#define GL_LIGHTING
Definition: glew.h:386
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
A grid of lines over the XZ plane.
Definition: CGridPlaneXZ.h:29
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
unsigned char uint8_t
Definition: rptypes.h:44
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
#define GL_COLOR_BUFFER_BIT
Definition: glew.h:266
#define GL_LINE_SMOOTH
Definition: glew.h:368
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:433
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define GL_SRC_ALPHA
Definition: glew.h:287
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
Definition: gl_utils.cpp:155
void render_dl() const override
Render.
GLuint in
Definition: glext.h:7391
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
GLAPI void GLAPIENTRY glEnd(void)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
GLenum GLint GLint y
Definition: glext.h:3542
const auto bb_min
#define GL_LINES
Definition: glew.h:274
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
GLenum GLint x
Definition: glext.h:3542
Lightweight 3D point.
Definition: TPoint3D.h:90
GLAPI void GLAPIENTRY glDisable(GLenum cap)
#define GL_LINE_BIT
Definition: glew.h:254



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019