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
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:131
unsigned char * get_unsafe(unsigned int col, unsigned int row, unsigned int channel=0) const
Access to pixels without checking boundaries - Use normally the () operator better,...
Definition: CImage.cpp:491
bool loadFromFile(const std::string &fileName, int isColor=-1)
Load image from a file, whose format is determined from the extension (internally uses OpenCV).
Definition: CImage.cpp:271
size_t getRowStride() const
Returns the row stride of the image: this is the number of bytes between two consecutive rows.
Definition: CImage.cpp:878
size_t getHeight() const override
Returns the height of the image in pixels.
Definition: CImage.cpp:892
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
Definition: CImage.cpp:906
size_t getWidth() const override
Returns the width of the image in pixels.
Definition: CImage.cpp:864
const char * getChannelsOrder() const
Returns a string of the form "BGR","RGB" or "GRAY" indicating the channels ordering.
Definition: CImage.cpp:1180
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:41
mrpt::math::TPoint3D m_bbox_min
Bounding box.
Definition: CAssimpModel.h:96
std::shared_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:93
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
mrpt::math::TPoint3D m_bbox_max
Definition: CAssimpModel.h:96
void clear()
Empty the object.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void loadScene(const std::string &file_name)
Loads a scene from a file in any supported file.
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:100
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::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:102
void evaluateAnimation(double time_anim)
Evaluates the scene at a given animation time.
void render_dl() const override
Render child objects.
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)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:55
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:87
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
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
EIGEN_STRONG_INLINE bool empty() const
Scalar * iterator
Definition: eigen_plugins.h:26
const Scalar * const_iterator
Definition: eigen_plugins.h:27
#define MRPT_START
Definition: exceptions.h:262
#define MRPT_END
Definition: exceptions.h:266
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
#define GL_DIFFUSE
Definition: glew.h:579
#define GL_TRUE
Definition: glew.h:293
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
#define GL_SHININESS
Definition: glew.h:607
#define GL_TEXTURE_MIN_FILTER
Definition: glew.h:666
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
#define GL_FRONT_AND_BACK
Definition: glew.h:321
#define GL_BGR
Definition: glew.h:1239
#define GL_SPECULAR
Definition: glew.h:580
GLAPI void GLAPIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
#define GL_LINEAR
Definition: glew.h:660
#define GL_LINES
Definition: glew.h:273
#define GL_NORMALIZE
Definition: glew.h:416
GLAPI void GLAPIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
#define GL_AMBIENT
Definition: glew.h:578
GLAPI void GLAPIENTRY glPolygonMode(GLenum face, GLenum mode)
#define GL_LUMINANCE
Definition: glew.h:625
#define GL_TRIANGLES
Definition: glew.h:276
GLAPI void GLAPIENTRY glPushMatrix(void)
#define GL_RGB
Definition: glew.h:623
GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m)
unsigned int GLenum
Definition: glew.h:206
#define GL_UNSIGNED_BYTE
Definition: glew.h:302
#define GL_POINTS
Definition: glew.h:272
#define GL_CULL_FACE
Definition: glew.h:382
#define GL_UNPACK_ALIGNMENT
Definition: glew.h:484
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
#define GL_FILL
Definition: glew.h:630
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
#define GL_COLOR_MATERIAL
Definition: glew.h:392
GLAPI void GLAPIENTRY glPopMatrix(void)
GLAPI void GLAPIENTRY glLightModeli(GLenum pname, GLint param)
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_LINE
Definition: glew.h:629
GLAPI void GLAPIENTRY glEnd(void)
#define GL_POLYGON
Definition: glew.h:281
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
#define GL_EMISSION
Definition: glew.h:606
#define GL_TEXTURE_MAG_FILTER
Definition: glew.h:665
GLAPI void GLAPIENTRY glDisable(GLenum cap)
#define GL_LIGHT_MODEL_TWO_SIDE
Definition: glew.h:387
#define GL_TEXTURE_2D
Definition: glew.h:7238
GLAPI void GLAPIENTRY glNormal3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
#define GL_LIGHTING
Definition: glew.h:385
#define GL_UNPACK_ROW_LENGTH
Definition: glew.h:481
GLdouble GLdouble t
Definition: glext.h:3689
GLenum GLsizei n
Definition: glext.h:5074
const GLubyte * c
Definition: glext.h:6313
GLuint color
Definition: glext.h:8300
GLenum GLuint GLint GLenum face
Definition: glext.h:8194
GLubyte GLubyte b
Definition: glext.h:6279
GLenum GLsizei width
Definition: glext.h:3531
GLuint in
Definition: glext.h:7274
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLenum GLsizei GLsizei height
Definition: glext.h:3554
GLsizei const GLchar ** string
Definition: glext.h:4101
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
Definition: filesystem.cpp:97
std::string filePathSeparatorsToNative(const std::string &filePath)
Windows: replace all '/'->'\' , in Linux/MacOS: replace all '\'->'/'.
Definition: filesystem.cpp:609
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
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:186
This base provides a set of functions for maths stuff.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:16
mrpt::img::CImage CImage
Definition: utils/CImage.h:5
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define min(a, b)
unsigned char uint8_t
Definition: rptypes.h:41
Lightweight 3D point.
double x
X,Y,Z coordinates.
size_t id_idx
indices in m_textureIds.
Definition: CAssimpModel.h:73



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