MRPT  1.9.9
COpenGLStandardObject.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 
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 using namespace mrpt::math;
20 using namespace mrpt::poses;
21 
24 
25 #define COMPILE_TIME_ASSERT(N, expr) char dummy_constraint##N[expr]
26 
27 #if MRPT_HAS_OPENGL_GLUT
28 COMPILE_TIME_ASSERT(GLENUM, sizeof(GLenum) == sizeof(_GLENUM));
29 #endif
30 
31 /*---------------------------------------------------------------
32  render
33  ---------------------------------------------------------------*/
34 void renderFunc(TPoint3D p)
35 {
36 #if MRPT_HAS_OPENGL_GLUT
37  glVertex3f(p.x, p.y, p.z);
38 #else
40 #endif
41 }
42 
44 {
45 #if MRPT_HAS_OPENGL_GLUT
46  for_each(enabled.begin(), enabled.end(), glEnable);
47  glShadeModel(GL_SMOOTH);
48  // This line won't take any effect if GL_BLEND is not enabled, so it's safe
49  // to always execute it.
50  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
51  glColor4ub(m_color.R, m_color.G, m_color.B, m_color.A);
52  if (normal[0] || normal[1] || normal[2])
53  glNormal3f(normal[0], normal[1], normal[2]);
54  if (chunkSize == 0)
55  {
56  glBegin(type);
57  for_each(vertices.begin(), vertices.end(), renderFunc);
58  glEnd();
59  }
60  else
61  {
62  auto it = vertices.begin();
63  do
64  {
65  glBegin(type);
66  for_each(it, it + chunkSize, renderFunc);
67  it += chunkSize;
68  glEnd();
69  } while (it != vertices.end());
70  }
71  for_each(enabled.begin(), enabled.end(), glDisable);
72 #endif
73 }
74 
75 uint8_t COpenGLStandardObject::serializeGetVersion() const { return 1; }
78 {
79  writeToStreamRender(out);
80  out << type << vertices << chunkSize << enabled;
81 }
82 
84  mrpt::serialization::CArchive& in, uint8_t version)
85 {
86  switch (version)
87  {
88  case 1:
89  {
90  readFromStreamRender(in);
91  in >> type >> vertices >> chunkSize >> enabled;
92  }
93  break;
94  default:
96  };
98 }
99 
101  const mrpt::poses::CPose3D& o, double& dist) const
102 {
104  MRPT_UNUSED_PARAM(dist);
105  // This object isn't intended to hold geometric properties. No trace ray
106  // should be performed on it.
107  return false;
108 }
109 
112 {
113  bb_min.x = 0;
114  bb_min.y = 0;
115  bb_min.z = 0;
116 
117  bb_max.x = 0;
118  bb_max.y = 0;
119  bb_max.z = 0;
120 
121  // Convert to coordinates of my parent:
122  m_pose.composePoint(bb_min, bb_min);
123  m_pose.composePoint(bb_max, bb_max);
124 }
125 
127 {
128  auto it = enabled.begin();
129  while (it != enabled.end())
130  {
131  if (*it == flag)
132  it = enabled.erase(it);
133  else
134  ++it;
135  }
137 }
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
#define COMPILE_TIME_ASSERT(N, expr)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
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...
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
This base provides a set of functions for maths stuff.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
IMPLEMENTS_SERIALIZABLE(COpenGLStandardObject, CRenderizableDisplayList, mrpt::opengl) void renderFunc(TPoint3D p)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void disable(_GLENUM flag)
Disable some openGL flag.
T x
X,Y,Z coordinates.
Definition: TPoint3D.h:23
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:54
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::vision::TStereoCalibResults out
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
const auto bb_min
Objects of this class represent a generic openGL object without specific geometric properties...
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray Tracing.
void render_dl() const override
Render.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7fcfece08 Sat Feb 22 22:47:46 2020 +0100 at sáb feb 22 23:00:10 CET 2020