MRPT  1.9.9
COpenGLStandardObject.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://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);
48  // This line won't take any effect if GL_BLEND is not enabled, so it's safe
49  // to always execute it.
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  std::vector<TPoint3D>::const_iterator 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 
78 {
79  writeToStreamRender(out);
80  out << type << vertices << chunkSize << enabled;
81 }
82 
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 
111  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
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  std::vector<_GLENUM>::iterator it = enabled.begin();
129  while (it != enabled.end())
130  {
131  if (*it == flag)
132  it = enabled.erase(it);
133  else
134  ++it;
135  }
137 }
#define COMPILE_TIME_ASSERT(N, expr)
IMPLEMENTS_SERIALIZABLE(COpenGLStandardObject, CRenderizableDisplayList, mrpt::opengl) void renderFunc(TPoint3D p)
Objects of this class represent a generic openGL object without specific geometric properties.
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...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void disable(_GLENUM flag)
Disable some openGL flag.
virtual void render_dl() const override
Render.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray Tracing.
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:87
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
Scalar * iterator
Definition: eigen_plugins.h:26
const Scalar * const_iterator
Definition: eigen_plugins.h:27
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define GL_SRC_ALPHA
Definition: glew.h:286
#define GL_SMOOTH
Definition: glew.h:635
unsigned int GLenum
Definition: glew.h:206
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3528
GLuint in
Definition: glext.h:7274
GLfloat GLfloat p
Definition: glext.h:6305
This base provides a set of functions for maths stuff.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:16
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
unsigned char uint8_t
Definition: rptypes.h:41
Lightweight 3D point.
double x
X,Y,Z coordinates.



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST