Main MRPT website > C++ reference for MRPT 1.9.9
CAssimpModel.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-2017, 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 // This file contains portions of code from Assimp's example:
11 // "Sample_SimpleOpenGL.c"
12 
13 #include "opengl-precomp.h" // Precompiled header
14 
16 
17 #if MRPT_HAS_ASSIMP
18 #if defined(MRPT_ASSIMP_VERSION_MAJOR) && MRPT_ASSIMP_VERSION_MAJOR < 3
19 #include <assimp.h>
20 #include <aiScene.h>
21 #include <aiPostProcess.h>
22 #else
23 #include <assimp/cimport.h>
24 #include <assimp/DefaultLogger.hpp>
25 #include <assimp/LogStream.hpp>
26 #include <assimp/scene.h>
27 #include <assimp/postprocess.h>
28 #endif
29 #endif
30 
31 #include "opengl_internals.h"
32 #include <mrpt/system/filesystem.h>
33 
34 using namespace mrpt;
35 using namespace mrpt::opengl;
36 using namespace mrpt::utils;
37 using namespace mrpt::math;
38 using namespace std;
39 
41 
42 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
43 void recursive_render(
44  const aiScene* sc, const aiNode* nd,
45  const std::vector<unsigned int>& textureIds,
46  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap);
47 void apply_material(
48  const aiMaterial* mtl, const std::vector<unsigned int>& textureIds,
49  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap);
50 void set_float4(float f[4], float a, float b, float c, float d);
51 void color4_to_float4(const aiColor4D* c, float f[4]);
52 void get_bounding_box(const aiScene* sc, aiVector3D* min, aiVector3D* max);
53 void get_bounding_box_for_node(
54  const aiScene* sc, const aiNode* nd, aiVector3D* min, aiVector3D* max,
55  aiMatrix4x4* trafo);
56 void load_textures(
57  const aiScene* scene, std::vector<unsigned int>& textureIds,
58  std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap,
59  const std::string& modelPath);
60 #endif // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
61 
62 /*---------------------------------------------------------------
63  render
64  ---------------------------------------------------------------*/
66 {
67 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
69 
70  if (!m_assimp_scene->scene) return; // No scene
71 
72  aiScene* scene = (aiScene*)m_assimp_scene->scene;
73 
76  // glFrontFace(GL_CW);
77 
80 
81  if (!m_textures_loaded)
82  {
83  load_textures(scene, m_textureIds, m_textureIdMap, m_modelPath);
84  m_textures_loaded = true;
85  }
86 
87  recursive_render(scene, scene->mRootNode, m_textureIds, m_textureIdMap);
88 
91 
92  MRPT_END
93 #endif
94 }
95 
96 /*---------------------------------------------------------------
97  Implements the writing to a CStream capability of
98  CSerializable objects
99  ---------------------------------------------------------------*/
100 void CAssimpModel::writeToStream(mrpt::utils::CStream& out, int* version) const
101 {
102  if (version)
103  *version = 0;
104  else
105  {
106  writeToStreamRender(out);
107 
108  const bool empty = m_assimp_scene->scene != nullptr;
109  out << empty;
110 
111  if (!empty)
112  {
113 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
114  // aiScene *scene = (aiScene *) m_assimp_scene->scene;
115  THROW_EXCEPTION("MRPT can't serialize Assimp objects yet!")
116 #else
117  THROW_EXCEPTION("MRPT compiled without OpenGL and/or Assimp")
118 #endif
119  }
120  }
121 }
122 
123 /*---------------------------------------------------------------
124  Implements the reading from a CStream capability of
125  CSerializable objects
126  ---------------------------------------------------------------*/
128 {
129  THROW_EXCEPTION("MRPT can't serialize Assimp objects yet!")
130 
131  switch (version)
132  {
133  case 0:
134  {
135  readFromStreamRender(in);
136 
137  clear();
138  }
139  break;
140  default:
142  };
144 }
145 
147  : m_bbox_min(0, 0, 0), m_bbox_max(0, 0, 0), m_textures_loaded(false)
148 {
149  m_assimp_scene = mrpt::make_aligned_shared<TImplAssimp>();
150 }
151 
153 /*---------------------------------------------------------------
154  clear
155  ---------------------------------------------------------------*/
157 {
159  m_assimp_scene = mrpt::make_aligned_shared<TImplAssimp>();
160  m_modelPath.clear();
161  m_textures_loaded = false;
162 
163 #if MRPT_HAS_OPENGL_GLUT
164  if (!m_textureIds.empty())
165  {
167  m_textureIds.clear();
168  }
169  m_textureIdMap.clear();
170 #endif
171 }
172 
174 {
175 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
176  clear();
178 
179  // we are taking one of the postprocessing presets to avoid
180  // spelling out 20+ single postprocessing flags here.
181  m_assimp_scene->scene = (void*)aiImportFile(
182  filepath.c_str(), aiProcessPreset_TargetRealtime_MaxQuality);
183  m_modelPath = filepath;
184 
185  if (m_assimp_scene->scene)
186  {
187  aiVector3D scene_min, scene_max;
188  aiScene* scene = (aiScene*)m_assimp_scene->scene;
189  get_bounding_box(scene, &scene_min, &scene_max);
190  m_bbox_min.x = scene_min.x;
191  m_bbox_min.y = scene_min.y;
192  m_bbox_min.z = scene_min.z;
193  m_bbox_max.x = scene_max.x;
194  m_bbox_max.y = scene_max.y;
195  m_bbox_max.z = scene_max.z;
196  }
197 
198 #else
199  THROW_EXCEPTION("MRPT compiled without OpenGL and/or Assimp")
200 #endif
201 }
202 
203 void CAssimpModel::evaluateAnimation(double time_anim)
204 {
205 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
206 // if (m_assimp_scene->file)
207 //{
208 // CRenderizableDisplayList::notifyChange();
209 // lib3ds_file_eval( (Lib3dsFile*) m_assimp_scene->file, time_anim );
210 //}
211 #endif
212 }
213 
215  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
216 {
217  bb_min = m_bbox_min;
218  bb_max = m_bbox_max;
219 
220  // Convert to coordinates of my parent:
221  m_pose.composePoint(bb_min, bb_min);
222  m_pose.composePoint(bb_max, bb_max);
223 }
224 
227 {
228 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
229  if (scene)
230  {
231  // cleanup - calling 'aiReleaseImport' is important, as the library
232  // keeps internal resources until the scene is freed again. Not
233  // doing so can cause severe resource leaking.
234  aiReleaseImport((aiScene*)scene);
235  scene = nullptr;
236  }
237 #endif
238 }
239 
240 bool CAssimpModel::traceRay(const mrpt::poses::CPose3D& o, double& dist) const
241 {
242  // TODO
243  return false;
244 }
245 
246 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
247 
248 // ----------------------------------------------------------------------------
249 void get_bounding_box_for_node(
250  const aiScene* scene, const aiNode* nd, aiVector3D* min, aiVector3D* max,
251  aiMatrix4x4* trafo)
252 {
253  aiMatrix4x4 prev;
254  unsigned int n = 0, t;
255 
256  prev = *trafo;
257  aiMultiplyMatrix4(trafo, &nd->mTransformation);
258 
259  for (; n < nd->mNumMeshes; ++n)
260  {
261  const aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
262  for (t = 0; t < mesh->mNumVertices; ++t)
263  {
264  aiVector3D tmp = mesh->mVertices[t];
265  aiTransformVecByMatrix4(&tmp, trafo);
266 
267  min->x = std::min(min->x, tmp.x);
268  min->y = std::min(min->y, tmp.y);
269  min->z = std::min(min->z, tmp.z);
270 
271  max->x = std::max(max->x, tmp.x);
272  max->y = std::max(max->y, tmp.y);
273  max->z = std::max(max->z, tmp.z);
274  }
275  }
276 
277  for (n = 0; n < nd->mNumChildren; ++n)
278  {
279  get_bounding_box_for_node(scene, nd->mChildren[n], min, max, trafo);
280  }
281  *trafo = prev;
282 }
283 
284 // ----------------------------------------------------------------------------
285 void get_bounding_box(const aiScene* scene, aiVector3D* min, aiVector3D* max)
286 {
287  aiMatrix4x4 trafo;
288  aiIdentityMatrix4(&trafo);
289 
290  min->x = min->y = min->z = 1e10f;
291  max->x = max->y = max->z = -1e10f;
292  get_bounding_box_for_node(scene, scene->mRootNode, min, max, &trafo);
293 }
294 
295 // ----------------------------------------------------------------------------
296 void color4_to_float4(const aiColor4D* c, float f[4])
297 {
298  f[0] = c->r;
299  f[1] = c->g;
300  f[2] = c->b;
301  f[3] = c->a;
302 }
303 
304 // ----------------------------------------------------------------------------
305 void set_float4(float f[4], float a, float b, float c, float d)
306 {
307  f[0] = a;
308  f[1] = b;
309  f[2] = c;
310  f[3] = d;
311 }
312 
313 // ----------------------------------------------------------------------------
314 void apply_material(
315  const aiMaterial* mtl, const std::vector<unsigned int>& textureIds,
316  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap)
317 {
318  float c[4];
319 
320  GLenum fill_mode;
321  int ret1, ret2;
322  aiColor4D diffuse;
323  aiColor4D specular;
324  aiColor4D ambient;
325  aiColor4D emission;
326  float shininess, strength;
327  int two_sided;
328  int wireframe;
329  unsigned int max;
330 
331  int texIndex = 0;
332  aiString texPath; // contains filename of texture
333 
334  if (AI_SUCCESS ==
335  mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath))
336  {
337  // bind texture
339  it = textureIdMap.find(texPath.data);
340  if (it == textureIdMap.end())
341  {
342  std::cerr << "[CAssimpModel] Error: using un-loaded texture '"
343  << texPath.data << "'\n";
344  }
345  else
346  {
347  unsigned int texId = textureIds[it->second.id_idx];
349  }
350  }
351 
352  set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
353  if (AI_SUCCESS ==
354  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
355  color4_to_float4(&diffuse, c);
357 
358  set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
359  if (AI_SUCCESS ==
360  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
361  color4_to_float4(&specular, c);
363 
364  set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
365  if (AI_SUCCESS ==
366  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
367  color4_to_float4(&ambient, c);
369 
370  set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
371  if (AI_SUCCESS ==
372  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
373  color4_to_float4(&emission, c);
375 
376  max = 1;
377  ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
378  if (ret1 == AI_SUCCESS)
379  {
380  max = 1;
381  ret2 = aiGetMaterialFloatArray(
382  mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
383  if (ret2 == AI_SUCCESS)
384  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
385  else
387  }
388  else
389  {
391  set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
393  }
394 
395  max = 1;
396  if (AI_SUCCESS == aiGetMaterialIntegerArray(
397  mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max))
398  fill_mode = wireframe ? GL_LINE : GL_FILL;
399  else
400  fill_mode = GL_FILL;
401  glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
402 
403  max = 1;
404  if ((AI_SUCCESS == aiGetMaterialIntegerArray(
405  mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) &&
406  two_sided)
408  else
410 }
411 
412 // Can't send color down as a pointer to aiColor4D because AI colors are ABGR.
413 void Color4f(const aiColor4D* color)
414 {
415  glColor4f(color->r, color->g, color->b, color->a);
416 }
417 
418 // ----------------------------------------------------------------------------
419 void recursive_render(
420  const aiScene* sc, const aiNode* nd,
421  const std::vector<unsigned int>& textureIds,
422  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap)
423 {
424  unsigned int i;
425  unsigned int n = 0, t;
426  aiMatrix4x4 m = nd->mTransformation;
427 
428  // update transform
429  m.Transpose();
430  glPushMatrix();
431  glMultMatrixf((float*)&m);
432 
433  // draw all meshes assigned to this node
434  for (; n < nd->mNumMeshes; ++n)
435  {
436  const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
437 
438  apply_material(
439  sc->mMaterials[mesh->mMaterialIndex], textureIds, textureIdMap);
440 
441  if (mesh->mNormals == nullptr)
443  else
445 
446  if (mesh->mColors[0] != nullptr)
448  else
450 
451  for (t = 0; t < mesh->mNumFaces; ++t)
452  {
453  const struct aiFace* face = &mesh->mFaces[t];
454  GLenum face_mode;
455 
456  switch (face->mNumIndices)
457  {
458  case 1:
459  face_mode = GL_POINTS;
460  break;
461  case 2:
462  face_mode = GL_LINES;
463  break;
464  case 3:
465  face_mode = GL_TRIANGLES;
466  break;
467  default:
468  face_mode = GL_POLYGON;
469  break;
470  }
471 
472  glBegin(face_mode);
473 
474  for (i = 0; i < face->mNumIndices;
475  i++) // go through all vertices in face
476  {
477  int vertexIndex =
478  face->mIndices[i]; // get group index for current index
479  if (mesh->mColors[0] != nullptr)
480  Color4f(&mesh->mColors[0][vertexIndex]);
481 
482  if (mesh->HasTextureCoords(
483  0)) // HasTextureCoords(texture_coordinates_set)
484  {
485  glTexCoord2f(
486  mesh->mTextureCoords[0][vertexIndex].x,
487  1 -
488  mesh->mTextureCoords[0][vertexIndex]
489  .y); // mTextureCoords[channel][vertex]
490  }
491 
492  if (mesh->mNormals)
493  {
494  glNormal3fv(&mesh->mNormals[vertexIndex].x);
495  }
496  glVertex3fv(&mesh->mVertices[vertexIndex].x);
497  }
498  glEnd();
499  }
500  }
501 
502  // draw all children
503  for (n = 0; n < nd->mNumChildren; ++n)
504  recursive_render(sc, nd->mChildren[n], textureIds, textureIdMap);
505 
506  glPopMatrix();
507 }
508 
509 // http://stackoverflow.com/questions/3418231/replace-part-of-a-string-with-another-string
510 void replaceAll(
511  std::string& str, const std::string& from, const std::string& to)
512 {
513  if (from.empty()) return;
514  size_t start_pos = 0;
515  while ((start_pos = str.find(from, start_pos)) != std::string::npos)
516  {
517  str.replace(start_pos, from.length(), to);
518  start_pos += to.length(); // In case 'to' contains 'from', like
519  // replacing 'x' with 'yx'
520  }
521 }
522 
523 void load_textures(
524  const aiScene* scene, std::vector<unsigned int>& textureIds,
525  std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap,
526  const std::string& modelPath)
527 {
528  if (scene->HasTextures())
530  "Support for meshes with embedded textures is not implemented")
531 
532  textureIdMap.clear();
533 
534  /* getTexture Filenames and no. of Textures */
535  for (unsigned int m = 0; m < scene->mNumMaterials; m++)
536  {
537  int texIndex = 0;
538  for (;;)
539  {
540  aiString path; // filename
541  aiReturn texFound = scene->mMaterials[m]->GetTexture(
542  aiTextureType_DIFFUSE, texIndex, &path);
543  if (texFound == AI_SUCCESS)
544  {
545  CAssimpModel::TInfoPerTexture& ipt = textureIdMap[path.data];
546  ipt.id_idx = std::string::npos; // fill map with textures,
547  // pointers still nullptr yet
548  texIndex++;
549  }
550  else
551  break;
552  }
553  }
554 
555  int numTextures = textureIdMap.size();
556 
557  /* create and fill array with GL texture ids */
558  textureIds.resize(numTextures);
559  if (numTextures)
560  {
562  numTextures, &textureIds[0]); /* Texture name generation */
563  }
564 
565  /* get iterator */
567  textureIdMap.begin();
568 
571  for (int i = 0; i < numTextures; i++)
572  {
573  // save IL image ID
574  std::string filename = itr->first; // get filename
575  CAssimpModel::TInfoPerTexture& ipt = itr->second;
576  ipt.id_idx = i; // save texture id for filename in map
577  ++itr; // next texture
578 
579  const std::string fileloc =
580  mrpt::system::filePathSeparatorsToNative(basepath + filename);
581 
582  ipt.img_rgb = mrpt::make_aligned_shared<mrpt::utils::CImage>();
583  ipt.img_alpha = mrpt::make_aligned_shared<mrpt::utils::CImage>();
584  mrpt::utils::CImage* img_rgb = ipt.img_rgb.get();
585  mrpt::utils::CImage* img_a = ipt.img_alpha.get();
586 
587  // Load images:
588  // TGA is handled specially since it's not supported by OpenCV:
589  bool load_ok;
591  mrpt::system::extractFileExtension(fileloc)) == string("tga"))
592  {
593  load_ok = CImage::loadTGA(fileloc, *img_rgb, *img_a);
594  }
595  else
596  {
597  load_ok = img_rgb->loadFromFile(fileloc);
598  }
599 
600  if (load_ok)
601  {
602  // success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); /* Convert
603  // every colour component into unsigned byte. If your image contains
604  // alpha channel you can replace IL_RGB with IL_RGBA */
606  GL_TEXTURE_2D, textureIds[i]); /* Binding of texture name */
607  // redefine standard texture values
610  GL_LINEAR); /* We will use linear
611 interpolation for magnification filter */
614  GL_LINEAR); /* We will use linear
615 interpolation for minifying filter */
616  // glTexImage2D(
617  // GL_TEXTURE_2D,
618  // 0,
619  // 8 /*ilGetInteger(IL_IMAGE_BPP)*/,
620  // /* ilGetInteger(IL_IMAGE_WIDTH)*/,
621  // /*ilGetInteger(IL_IMAGE_HEIGHT)*/,
622  // 0,
623  // /*ilGetInteger(IL_IMAGE_FORMAT)*/,
624  // GL_UNSIGNED_BYTE,
625  // ilGetData()); /* Texture specification */
626 
627  const int width = img_rgb->getWidth();
628  const int height = img_rgb->getHeight();
629 
630  // Prepare image data types:
631  const GLenum img_type = GL_UNSIGNED_BYTE;
632  const int nBytesPerPixel = img_rgb->isColor() ? 3 : 1;
633  const bool is_RGB_order =
634  (!::strcmp(
635  img_rgb->getChannelsOrder(),
636  "RGB")); // Reverse RGB <-> BGR order?
637  const GLenum img_format = nBytesPerPixel == 3
638  ? (is_RGB_order ? GL_RGB : GL_BGR)
639  : GL_LUMINANCE;
640 
641  // Send image data to OpenGL:
644  GL_UNPACK_ROW_LENGTH, img_rgb->getRowStride() / nBytesPerPixel);
645  glTexImage2D(
646  GL_TEXTURE_2D, 0 /*level*/, 3 /* RGB components */, width,
647  height, 0 /*border*/, img_format, img_type,
648  img_rgb->get_unsafe(0, 0));
649  glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Reset
650  }
651  else
652  {
653  /* Error occured */
654  const std::string sError = mrpt::format(
655  "[CAssimpModel] Couldn't load texture image: '%s'",
656  fileloc.c_str());
657  cout << sError << endl;
658 #ifdef _MSC_VER
659  OutputDebugStringA(&sError[0]);
660 #endif
661  }
662  }
663 }
664 
665 #endif // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
GLAPI void GLAPIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
#define GL_BGR
Definition: glew.h:1239
EIGEN_STRONG_INLINE bool empty() const
#define GL_SPECULAR
Definition: glew.h:580
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
GLdouble GLdouble t
Definition: glext.h:3689
#define min(a, b)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define GL_FRONT_AND_BACK
Definition: glew.h:321
size_t id_idx
indices in m_textureIds.
Definition: CAssimpModel.h:76
#define THROW_EXCEPTION(msg)
GLAPI void GLAPIENTRY glPopMatrix(void)
void evaluateAnimation(double time_anim)
Evaluates the scene at a given animation time.
GLenum GLsizei n
Definition: glext.h:5074
Scalar * iterator
Definition: eigen_plugins.h:26
#define GL_TRIANGLES
Definition: glew.h:276
#define GL_CULL_FACE
Definition: glew.h:382
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
STL namespace.
#define GL_UNSIGNED_BYTE
Definition: glew.h:302
#define GL_FILL
Definition: glew.h:630
#define GL_NORMALIZE
Definition: glew.h:416
#define GL_LINEAR
Definition: glew.h:660
const Scalar * const_iterator
Definition: eigen_plugins.h:27
#define GL_COLOR_MATERIAL
Definition: glew.h:392
void loadScene(const std::string &file_name)
Loads a scene from a file in any supported file.
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
mrpt::math::TPoint3D m_bbox_min
Bounding box.
Definition: CAssimpModel.h:99
#define GL_POLYGON
Definition: glew.h:281
#define GL_LIGHTING
Definition: glew.h:385
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:189
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
GLenum GLsizei width
Definition: glext.h:3531
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
GLuint color
Definition: glext.h:8300
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:105
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
mrpt::math::TPoint3D m_bbox_max
Definition: CAssimpModel.h:99
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...
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
#define MRPT_END
void clear()
Empty the object.
std::string filePathSeparatorsToNative(const std::string &filePath)
Windows: replace all &#39;/&#39;->&#39;\&#39; , in Linux/MacOS: replace all &#39;\&#39;->&#39;/&#39;.
Definition: filesystem.cpp:608
#define GL_DIFFUSE
Definition: glew.h:579
const GLubyte * c
Definition: glext.h:6313
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
GLAPI void GLAPIENTRY glNormal3fv(const GLfloat *v)
#define GL_EMISSION
Definition: glew.h:606
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
GLubyte GLubyte b
Definition: glext.h:6279
#define GL_RGB
Definition: glew.h:623
double x
X,Y,Z coordinates.
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
Definition: filesystem.cpp:97
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_POINTS
Definition: glew.h:272
GLsizei const GLchar ** string
Definition: glext.h:4101
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
GLAPI void GLAPIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
unsigned int GLenum
Definition: glew.h:206
#define MRPT_START
GLAPI void GLAPIENTRY glLightModeli(GLenum pname, GLint param)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define GL_UNPACK_ROW_LENGTH
Definition: glew.h:481
#define GL_TEXTURE_MIN_FILTER
Definition: glew.h:666
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
#define GL_UNPACK_ALIGNMENT
Definition: glew.h:484
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
#define GL_LINE
Definition: glew.h:629
#define GL_TEXTURE_MAG_FILTER
Definition: glew.h:665
GLAPI void GLAPIENTRY glPolygonMode(GLenum face, GLenum mode)
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
Definition: CPose3D.cpp:453
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
GLuint in
Definition: glext.h:7274
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
GLAPI void GLAPIENTRY glEnd(void)
#define GL_LIGHT_MODEL_TWO_SIDE
Definition: glew.h:387
#define GL_SHININESS
Definition: glew.h:607
#define GL_LINES
Definition: glew.h:273
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
void render_dl() const override
Render child objects.
GLAPI void GLAPIENTRY glPushMatrix(void)
Lightweight 3D point.
GLenum GLsizei GLsizei height
Definition: glext.h:3554
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
GLAPI void GLAPIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:43
#define GL_TEXTURE_2D
Definition: glew.h:7238
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:103
std::string extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
Definition: filesystem.cpp:77
#define GL_LUMINANCE
Definition: glew.h:625
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define GL_TRUE
Definition: glew.h:293
#define GL_AMBIENT
Definition: glew.h:578
GLenum GLuint GLint GLenum face
Definition: glext.h:8194
std::shared_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:96



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019