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-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 // 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>
34 
35 using namespace mrpt;
36 using namespace mrpt::opengl;
37 using namespace mrpt::math;
38 using namespace std;
39 using mrpt::img::CImage;
40 
42 
43 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
44 void recursive_render(
45  const aiScene* sc, const aiNode* nd,
46  const std::vector<unsigned int>& textureIds,
47  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap);
48 void apply_material(
49  const aiMaterial* mtl, const std::vector<unsigned int>& textureIds,
50  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap);
51 void set_float4(float f[4], float a, float b, float c, float d);
52 void color4_to_float4(const aiColor4D* c, float f[4]);
53 void get_bounding_box(const aiScene* sc, aiVector3D* min, aiVector3D* max);
54 void get_bounding_box_for_node(
55  const aiScene* sc, const aiNode* nd, aiVector3D* min, aiVector3D* max,
56  aiMatrix4x4* trafo);
57 void load_textures(
58  const aiScene* scene, std::vector<unsigned int>& textureIds,
59  std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap,
60  const std::string& modelPath);
61 #endif // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
62 
63 /*---------------------------------------------------------------
64  render
65  ---------------------------------------------------------------*/
67 {
68 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
70 
71  if (!m_assimp_scene->scene) return; // No scene
72 
73  aiScene* scene = (aiScene*)m_assimp_scene->scene;
74 
77  // glFrontFace(GL_CW);
78 
81 
82  if (!m_textures_loaded)
83  {
84  load_textures(scene, m_textureIds, m_textureIdMap, m_modelPath);
85  m_textures_loaded = true;
86  }
87 
88  recursive_render(scene, scene->mRootNode, m_textureIds, m_textureIdMap);
89 
92 
93  MRPT_END
94 #endif
95 }
96 
99 {
100  writeToStreamRender(out);
101 
102  const bool empty = m_assimp_scene->scene != nullptr;
103  out << empty;
104 
105  if (!empty)
106  {
107 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
108  // aiScene *scene = (aiScene *) m_assimp_scene->scene;
109  THROW_EXCEPTION("MRPT can't serialize Assimp objects yet!");
110 #else
111  THROW_EXCEPTION("MRPT compiled without OpenGL and/or Assimp");
112 #endif
113  }
114 }
115 
118 {
119  THROW_EXCEPTION("MRPT can't serialize Assimp objects yet!");
120 
121  switch (version)
122  {
123  case 0:
124  {
125  readFromStreamRender(in);
126 
127  clear();
128  }
129  break;
130  default:
132  };
134 }
135 
137  : m_bbox_min(0, 0, 0), m_bbox_max(0, 0, 0), m_textures_loaded(false)
138 {
139  m_assimp_scene = mrpt::make_aligned_shared<TImplAssimp>();
140 }
141 
143 /*---------------------------------------------------------------
144  clear
145  ---------------------------------------------------------------*/
147 {
149  m_assimp_scene = mrpt::make_aligned_shared<TImplAssimp>();
150  m_modelPath.clear();
151  m_textures_loaded = false;
152 
153 #if MRPT_HAS_OPENGL_GLUT
154  if (!m_textureIds.empty())
155  {
157  m_textureIds.clear();
158  }
159  m_textureIdMap.clear();
160 #endif
161 }
162 
164 {
165 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
166  clear();
168 
169  // we are taking one of the postprocessing presets to avoid
170  // spelling out 20+ single postprocessing flags here.
171  m_assimp_scene->scene = (void*)aiImportFile(
172  filepath.c_str(), aiProcessPreset_TargetRealtime_MaxQuality);
173  m_modelPath = filepath;
174 
175  if (m_assimp_scene->scene)
176  {
177  aiVector3D scene_min, scene_max;
178  aiScene* scene = (aiScene*)m_assimp_scene->scene;
179  get_bounding_box(scene, &scene_min, &scene_max);
180  m_bbox_min.x = scene_min.x;
181  m_bbox_min.y = scene_min.y;
182  m_bbox_min.z = scene_min.z;
183  m_bbox_max.x = scene_max.x;
184  m_bbox_max.y = scene_max.y;
185  m_bbox_max.z = scene_max.z;
186  }
187 
188 #else
189  THROW_EXCEPTION("MRPT compiled without OpenGL and/or Assimp");
190 #endif
191 }
192 
193 void CAssimpModel::evaluateAnimation(double time_anim)
194 {
195 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
196 // if (m_assimp_scene->file)
197 //{
198 // CRenderizableDisplayList::notifyChange();
199 // lib3ds_file_eval( (Lib3dsFile*) m_assimp_scene->file, time_anim );
200 //}
201 #endif
202 }
203 
205  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
206 {
207  bb_min = m_bbox_min;
208  bb_max = m_bbox_max;
209 
210  // Convert to coordinates of my parent:
211  m_pose.composePoint(bb_min, bb_min);
212  m_pose.composePoint(bb_max, bb_max);
213 }
214 
217 {
218 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
219  if (scene)
220  {
221  // cleanup - calling 'aiReleaseImport' is important, as the library
222  // keeps internal resources until the scene is freed again. Not
223  // doing so can cause severe resource leaking.
224  aiReleaseImport((aiScene*)scene);
225  scene = nullptr;
226  }
227 #endif
228 }
229 
230 bool CAssimpModel::traceRay(const mrpt::poses::CPose3D& o, double& dist) const
231 {
232  // TODO
233  return false;
234 }
235 
236 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
237 
238 // ----------------------------------------------------------------------------
239 void get_bounding_box_for_node(
240  const aiScene* scene, const aiNode* nd, aiVector3D* min, aiVector3D* max,
241  aiMatrix4x4* trafo)
242 {
243  aiMatrix4x4 prev;
244  unsigned int n = 0, t;
245 
246  prev = *trafo;
247  aiMultiplyMatrix4(trafo, &nd->mTransformation);
248 
249  for (; n < nd->mNumMeshes; ++n)
250  {
251  const aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
252  for (t = 0; t < mesh->mNumVertices; ++t)
253  {
254  aiVector3D tmp = mesh->mVertices[t];
255  aiTransformVecByMatrix4(&tmp, trafo);
256 
257  min->x = std::min(min->x, tmp.x);
258  min->y = std::min(min->y, tmp.y);
259  min->z = std::min(min->z, tmp.z);
260 
261  max->x = std::max(max->x, tmp.x);
262  max->y = std::max(max->y, tmp.y);
263  max->z = std::max(max->z, tmp.z);
264  }
265  }
266 
267  for (n = 0; n < nd->mNumChildren; ++n)
268  {
269  get_bounding_box_for_node(scene, nd->mChildren[n], min, max, trafo);
270  }
271  *trafo = prev;
272 }
273 
274 // ----------------------------------------------------------------------------
275 void get_bounding_box(const aiScene* scene, aiVector3D* min, aiVector3D* max)
276 {
277  aiMatrix4x4 trafo;
278  aiIdentityMatrix4(&trafo);
279 
280  min->x = min->y = min->z = 1e10f;
281  max->x = max->y = max->z = -1e10f;
282  get_bounding_box_for_node(scene, scene->mRootNode, min, max, &trafo);
283 }
284 
285 // ----------------------------------------------------------------------------
286 void color4_to_float4(const aiColor4D* c, float f[4])
287 {
288  f[0] = c->r;
289  f[1] = c->g;
290  f[2] = c->b;
291  f[3] = c->a;
292 }
293 
294 // ----------------------------------------------------------------------------
295 void set_float4(float f[4], float a, float b, float c, float d)
296 {
297  f[0] = a;
298  f[1] = b;
299  f[2] = c;
300  f[3] = d;
301 }
302 
303 // ----------------------------------------------------------------------------
304 void apply_material(
305  const aiMaterial* mtl, const std::vector<unsigned int>& textureIds,
306  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap)
307 {
308  float c[4];
309 
310  GLenum fill_mode;
311  int ret1, ret2;
312  aiColor4D diffuse;
313  aiColor4D specular;
314  aiColor4D ambient;
315  aiColor4D emission;
316  float shininess, strength;
317  int two_sided;
318  int wireframe;
319  unsigned int max;
320 
321  int texIndex = 0;
322  aiString texPath; // contains filename of texture
323 
324  if (AI_SUCCESS ==
325  mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath))
326  {
327  // bind texture
329  it = textureIdMap.find(texPath.data);
330  if (it == textureIdMap.end())
331  {
332  std::cerr << "[CAssimpModel] Error: using un-loaded texture '"
333  << texPath.data << "'\n";
334  }
335  else
336  {
337  unsigned int texId = textureIds[it->second.id_idx];
339  }
340  }
341 
342  set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
343  if (AI_SUCCESS ==
344  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
345  color4_to_float4(&diffuse, c);
347 
348  set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
349  if (AI_SUCCESS ==
350  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
351  color4_to_float4(&specular, c);
353 
354  set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
355  if (AI_SUCCESS ==
356  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
357  color4_to_float4(&ambient, c);
359 
360  set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
361  if (AI_SUCCESS ==
362  aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
363  color4_to_float4(&emission, c);
365 
366  max = 1;
367  ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
368  if (ret1 == AI_SUCCESS)
369  {
370  max = 1;
371  ret2 = aiGetMaterialFloatArray(
372  mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
373  if (ret2 == AI_SUCCESS)
374  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
375  else
377  }
378  else
379  {
381  set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
383  }
384 
385  max = 1;
386  if (AI_SUCCESS == aiGetMaterialIntegerArray(
387  mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max))
388  fill_mode = wireframe ? GL_LINE : GL_FILL;
389  else
390  fill_mode = GL_FILL;
391  glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
392 
393  max = 1;
394  if ((AI_SUCCESS == aiGetMaterialIntegerArray(
395  mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) &&
396  two_sided)
398  else
400 }
401 
402 // Can't send color down as a pointer to aiColor4D because AI colors are ABGR.
403 void Color4f(const aiColor4D* color)
404 {
405  glColor4f(color->r, color->g, color->b, color->a);
406 }
407 
408 // ----------------------------------------------------------------------------
409 void recursive_render(
410  const aiScene* sc, const aiNode* nd,
411  const std::vector<unsigned int>& textureIds,
412  const std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap)
413 {
414  unsigned int i;
415  unsigned int n = 0, t;
416  aiMatrix4x4 m = nd->mTransformation;
417 
418  // update transform
419  m.Transpose();
420  glPushMatrix();
421  glMultMatrixf((float*)&m);
422 
423  // draw all meshes assigned to this node
424  for (; n < nd->mNumMeshes; ++n)
425  {
426  const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
427 
428  apply_material(
429  sc->mMaterials[mesh->mMaterialIndex], textureIds, textureIdMap);
430 
431  if (mesh->mNormals == nullptr)
433  else
435 
436  if (mesh->mColors[0] != nullptr)
438  else
440 
441  for (t = 0; t < mesh->mNumFaces; ++t)
442  {
443  const struct aiFace* face = &mesh->mFaces[t];
444  GLenum face_mode;
445 
446  switch (face->mNumIndices)
447  {
448  case 1:
449  face_mode = GL_POINTS;
450  break;
451  case 2:
452  face_mode = GL_LINES;
453  break;
454  case 3:
455  face_mode = GL_TRIANGLES;
456  break;
457  default:
458  face_mode = GL_POLYGON;
459  break;
460  }
461 
462  glBegin(face_mode);
463 
464  for (i = 0; i < face->mNumIndices;
465  i++) // go through all vertices in face
466  {
467  int vertexIndex =
468  face->mIndices[i]; // get group index for current index
469  if (mesh->mColors[0] != nullptr)
470  Color4f(&mesh->mColors[0][vertexIndex]);
471 
472  if (mesh->HasTextureCoords(
473  0)) // HasTextureCoords(texture_coordinates_set)
474  {
475  glTexCoord2f(
476  mesh->mTextureCoords[0][vertexIndex].x,
477  1 -
478  mesh->mTextureCoords[0][vertexIndex]
479  .y); // mTextureCoords[channel][vertex]
480  }
481 
482  if (mesh->mNormals)
483  {
484  glNormal3fv(&mesh->mNormals[vertexIndex].x);
485  }
486  glVertex3fv(&mesh->mVertices[vertexIndex].x);
487  }
488  glEnd();
489  }
490  }
491 
492  // draw all children
493  for (n = 0; n < nd->mNumChildren; ++n)
494  recursive_render(sc, nd->mChildren[n], textureIds, textureIdMap);
495 
496  glPopMatrix();
497 }
498 
499 // http://stackoverflow.com/questions/3418231/replace-part-of-a-string-with-another-string
500 void replaceAll(
501  std::string& str, const std::string& from, const std::string& to)
502 {
503  if (from.empty()) return;
504  size_t start_pos = 0;
505  while ((start_pos = str.find(from, start_pos)) != std::string::npos)
506  {
507  str.replace(start_pos, from.length(), to);
508  start_pos += to.length(); // In case 'to' contains 'from', like
509  // replacing 'x' with 'yx'
510  }
511 }
512 
513 void load_textures(
514  const aiScene* scene, std::vector<unsigned int>& textureIds,
515  std::map<std::string, CAssimpModel::TInfoPerTexture>& textureIdMap,
516  const std::string& modelPath)
517 {
518  if (scene->HasTextures())
520  "Support for meshes with embedded textures is not implemented")
521 
522  textureIdMap.clear();
523 
524  /* getTexture Filenames and no. of Textures */
525  for (unsigned int m = 0; m < scene->mNumMaterials; m++)
526  {
527  int texIndex = 0;
528  for (;;)
529  {
530  aiString path; // filename
531  aiReturn texFound = scene->mMaterials[m]->GetTexture(
532  aiTextureType_DIFFUSE, texIndex, &path);
533  if (texFound == AI_SUCCESS)
534  {
535  CAssimpModel::TInfoPerTexture& ipt = textureIdMap[path.data];
536  ipt.id_idx = std::string::npos; // fill map with textures,
537  // pointers still nullptr yet
538  texIndex++;
539  }
540  else
541  break;
542  }
543  }
544 
545  int numTextures = textureIdMap.size();
546 
547  /* create and fill array with GL texture ids */
548  textureIds.resize(numTextures);
549  if (numTextures)
550  {
552  numTextures, &textureIds[0]); /* Texture name generation */
553  }
554 
555  /* get iterator */
557  textureIdMap.begin();
558 
561  for (int i = 0; i < numTextures; i++)
562  {
563  // save IL image ID
564  std::string filename = itr->first; // get filename
565  CAssimpModel::TInfoPerTexture& ipt = itr->second;
566  ipt.id_idx = i; // save texture id for filename in map
567  ++itr; // next texture
568 
569  const std::string fileloc =
570  mrpt::system::filePathSeparatorsToNative(basepath + filename);
571 
572  ipt.img_rgb = mrpt::make_aligned_shared<mrpt::img::CImage>();
573  ipt.img_alpha = mrpt::make_aligned_shared<mrpt::img::CImage>();
574  mrpt::img::CImage* img_rgb = ipt.img_rgb.get();
575  mrpt::img::CImage* img_a = ipt.img_alpha.get();
576 
577  // Load images:
578  // TGA is handled specially since it's not supported by OpenCV:
579  bool load_ok;
581  mrpt::system::extractFileExtension(fileloc)) == string("tga"))
582  {
583  load_ok = CImage::loadTGA(fileloc, *img_rgb, *img_a);
584  }
585  else
586  {
587  load_ok = img_rgb->loadFromFile(fileloc);
588  }
589 
590  if (load_ok)
591  {
592  // success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); /* Convert
593  // every colour component into unsigned byte. If your image contains
594  // alpha channel you can replace IL_RGB with IL_RGBA */
596  GL_TEXTURE_2D, textureIds[i]); /* Binding of texture name */
597  // redefine standard texture values
600  linear interpolation for magnification
601  filter */
604  linear interpolation for minifying filter
605  */
606  // glTexImage2D(
607  // GL_TEXTURE_2D,
608  // 0,
609  // 8 /*ilGetInteger(IL_IMAGE_BPP)*/,
610  // /* ilGetInteger(IL_IMAGE_WIDTH)*/,
611  // /*ilGetInteger(IL_IMAGE_HEIGHT)*/,
612  // 0,
613  // /*ilGetInteger(IL_IMAGE_FORMAT)*/,
614  // GL_UNSIGNED_BYTE,
615  // ilGetData()); /* Texture specification */
616 
617  const int width = img_rgb->getWidth();
618  const int height = img_rgb->getHeight();
619 
620  // Prepare image data types:
621  const GLenum img_type = GL_UNSIGNED_BYTE;
622  const int nBytesPerPixel = img_rgb->isColor() ? 3 : 1;
623  const bool is_RGB_order =
624  (!::strcmp(
625  img_rgb->getChannelsOrder(),
626  "RGB")); // Reverse RGB <-> BGR order?
627  const GLenum img_format = nBytesPerPixel == 3
628  ? (is_RGB_order ? GL_RGB : GL_BGR)
629  : GL_LUMINANCE;
630 
631  // Send image data to OpenGL:
634  GL_UNPACK_ROW_LENGTH, img_rgb->getRowStride() / nBytesPerPixel);
635  glTexImage2D(
636  GL_TEXTURE_2D, 0 /*level*/, 3 /* RGB components */, width,
637  height, 0 /*border*/, img_format, img_type,
638  img_rgb->get_unsafe(0, 0));
639  glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Reset
640  }
641  else
642  {
643  /* Error occured */
644  const std::string sError = mrpt::format(
645  "[CAssimpModel] Couldn't load texture image: '%s'",
646  fileloc.c_str());
647  cout << sError << endl;
648 #ifdef _MSC_VER
649  OutputDebugStringA(&sError[0]);
650 #endif
651  }
652  }
653 }
654 
655 #endif // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
GLAPI void GLAPIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
#define GL_BGR
Definition: glew.h:1239
Scalar * iterator
Definition: eigen_plugins.h:26
EIGEN_STRONG_INLINE bool empty() const
#define GL_SPECULAR
Definition: glew.h:580
#define MRPT_START
Definition: exceptions.h:262
GLdouble GLdouble t
Definition: glext.h:3689
#define min(a, b)
GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
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:75
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
#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
#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:98
#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
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
unsigned char uint8_t
Definition: rptypes.h:41
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:90
GLuint color
Definition: glext.h:8300
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:104
mrpt::img::CImage CImage
Definition: utils/CImage.h:7
This base provides a set of functions for maths stuff.
mrpt::math::TPoint3D m_bbox_max
Definition: CAssimpModel.h:98
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.
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:609
#define GL_DIFFUSE
Definition: glew.h:579
const GLubyte * c
Definition: glext.h:6313
GLAPI void GLAPIENTRY glNormal3fv(const GLfloat *v)
#define GL_EMISSION
Definition: glew.h:606
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
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
GLAPI void GLAPIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
unsigned int GLenum
Definition: glew.h:206
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
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
#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:379
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
#define MRPT_END
Definition: exceptions.h:266
GLuint in
Definition: glext.h:7274
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
GLAPI void GLAPIENTRY glEnd(void)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
#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)
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:188
GLAPI void GLAPIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
const Scalar * const_iterator
Definition: eigen_plugins.h:27
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:42
#define GL_TEXTURE_2D
Definition: glew.h:7238
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:102
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:95
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019