Main MRPT website > C++ reference for MRPT 1.5.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: "Sample_SimpleOpenGL.c"
11 
12 #include "opengl-precomp.h" // Precompiled header
13 
15 
16 #if MRPT_HAS_ASSIMP
17 # if defined(MRPT_ASSIMP_VERSION_MAJOR) && MRPT_ASSIMP_VERSION_MAJOR<3
18 # include <assimp.h>
19 # include <aiScene.h>
20 # include <aiPostProcess.h>
21 # else
22 # include <assimp/cimport.h>
23 # include <assimp/DefaultLogger.hpp>
24 # include <assimp/LogStream.hpp>
25 # include <assimp/scene.h>
26 # include <assimp/postprocess.h>
27 # endif
28 #endif
29 
30 #include "opengl_internals.h"
31 #include <mrpt/system/filesystem.h>
32 
33 using namespace mrpt;
34 using namespace mrpt::opengl;
35 using namespace mrpt::utils;
36 using namespace mrpt::math;
37 using namespace std;
38 
40 
41 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
42  void recursive_render (const aiScene *sc, const aiNode* nd,const std::vector<unsigned int> &textureIds,const std::map<std::string,CAssimpModel::TInfoPerTexture> &textureIdMap);
43  void apply_material(const aiMaterial *mtl,const std::vector<unsigned int> &textureIds, const std::map<std::string,CAssimpModel::TInfoPerTexture> &textureIdMap);
44  void set_float4(float f[4], float a, float b, float c, float d);
45  void color4_to_float4(const aiColor4D *c, float f[4]);
46  void get_bounding_box (const aiScene *sc,aiVector3D* min, aiVector3D* max);
47  void get_bounding_box_for_node (const aiScene *sc,const aiNode* nd, aiVector3D* min, aiVector3D* max, aiMatrix4x4* trafo);
48  void load_textures(const aiScene *scene, std::vector<unsigned int> &textureIds, std::map<std::string,CAssimpModel::TInfoPerTexture> &textureIdMap,const std::string &modelPath);
49 #endif //MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
50 
51 /*---------------------------------------------------------------
52  render
53  ---------------------------------------------------------------*/
55 {
56 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
58 
59  if (!m_assimp_scene->scene) return; // No scene
60 
61  aiScene *scene = (aiScene *) m_assimp_scene->scene;
62 
65  //glFrontFace(GL_CW);
66 
69 
70  if (!m_textures_loaded)
71  {
72  load_textures(scene,m_textureIds,m_textureIdMap,m_modelPath);
73  m_textures_loaded = true;
74  }
75 
76  recursive_render(scene, scene->mRootNode,m_textureIds,m_textureIdMap);
77 
80 
81  MRPT_END
82 #endif
83 }
84 
85 /*---------------------------------------------------------------
86  Implements the writing to a CStream capability of
87  CSerializable objects
88  ---------------------------------------------------------------*/
90 {
91  if (version)
92  *version = 0;
93  else
94  {
95  writeToStreamRender(out);
96 
97  const bool empty = m_assimp_scene->scene!=NULL;
98  out << empty;
99 
100  if (!empty)
101  {
102 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
103  //aiScene *scene = (aiScene *) m_assimp_scene->scene;
104  THROW_EXCEPTION("MRPT can't serialize Assimp objects yet!")
105 #else
106  THROW_EXCEPTION("MRPT compiled without OpenGL and/or Assimp")
107 #endif
108  }
109 
110 }
111 }
112 
113 /*---------------------------------------------------------------
114  Implements the reading from a CStream capability of
115  CSerializable objects
116  ---------------------------------------------------------------*/
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  } break;
129  default:
131 
132  };
134 }
135 
137  m_bbox_min(0,0,0),
138  m_bbox_max(0,0,0),
139  m_textures_loaded(false)
140 {
141  m_assimp_scene.reset( new TImplAssimp() );
142 }
143 
145 {
146  clear();
147 }
148 
149 /*---------------------------------------------------------------
150  clear
151  ---------------------------------------------------------------*/
153 {
155  m_assimp_scene.reset( new TImplAssimp() );
156  m_modelPath.clear();
157  m_textures_loaded = false;
158 
159 #if MRPT_HAS_OPENGL_GLUT
160  if (!m_textureIds.empty())
161  {
163  m_textureIds.clear();
164  }
165  m_textureIdMap.clear();
166 #endif
167 }
168 
169 void CAssimpModel::loadScene( const std::string &filepath )
170 {
171 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
172  clear();
174 
175  // we are taking one of the postprocessing presets to avoid
176  // spelling out 20+ single postprocessing flags here.
177  m_assimp_scene->scene = (void*) aiImportFile(filepath.c_str(), aiProcessPreset_TargetRealtime_MaxQuality );
178  m_modelPath = filepath;
179 
180 
181  if (m_assimp_scene->scene)
182  {
183  aiVector3D scene_min, scene_max;
184  aiScene *scene = (aiScene *) m_assimp_scene->scene;
185  get_bounding_box(scene,&scene_min,&scene_max);
186  m_bbox_min.x = scene_min.x; m_bbox_min.y = scene_min.y; m_bbox_min.z = scene_min.z;
187  m_bbox_max.x = scene_max.x; m_bbox_max.y = scene_max.y; m_bbox_max.z = scene_max.z;
188  }
189 
190 #else
191  THROW_EXCEPTION("MRPT compiled without OpenGL and/or Assimp")
192 #endif
193 }
194 
195 void CAssimpModel::evaluateAnimation( double time_anim )
196 {
197 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
198  //if (m_assimp_scene->file)
199  //{
200  // CRenderizableDisplayList::notifyChange();
201  // lib3ds_file_eval( (Lib3dsFile*) m_assimp_scene->file, time_anim );
202  //}
203 #endif
204 }
205 
207 {
208  bb_min = m_bbox_min;
209  bb_max = m_bbox_max;
210 
211  // Convert to coordinates of my parent:
212  m_pose.composePoint(bb_min, bb_min);
213  m_pose.composePoint(bb_max, bb_max);
214 }
215 
216 
218 {
219 }
220 
222 {
223 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
224  if (scene)
225  {
226  // cleanup - calling 'aiReleaseImport' is important, as the library
227  // keeps internal resources until the scene is freed again. Not
228  // doing so can cause severe resource leaking.
229  aiReleaseImport( (aiScene*) scene);
230  scene=NULL;
231  }
232 #endif
233 }
234 
235 bool CAssimpModel::traceRay(const mrpt::poses::CPose3D &o,double &dist) const {
236  //TODO
237  return false;
238 }
239 
240 
241 
242 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
243 
244 // ----------------------------------------------------------------------------
245 void get_bounding_box_for_node (const aiScene* scene, const aiNode* nd, aiVector3D* min, aiVector3D* max, aiMatrix4x4* trafo)
246 {
247  aiMatrix4x4 prev;
248  unsigned int n = 0, t;
249 
250  prev = *trafo;
251  aiMultiplyMatrix4(trafo,&nd->mTransformation);
252 
253  for (; n < nd->mNumMeshes; ++n) {
254  const aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
255  for (t = 0; t < mesh->mNumVertices; ++t) {
256 
257  aiVector3D tmp = mesh->mVertices[t];
258  aiTransformVecByMatrix4(&tmp,trafo);
259 
260  min->x = std::min(min->x,tmp.x);
261  min->y = std::min(min->y,tmp.y);
262  min->z = std::min(min->z,tmp.z);
263 
264  max->x = std::max(max->x,tmp.x);
265  max->y = std::max(max->y,tmp.y);
266  max->z = std::max(max->z,tmp.z);
267  }
268  }
269 
270  for (n = 0; n < nd->mNumChildren; ++n) {
271  get_bounding_box_for_node(scene,nd->mChildren[n],min,max,trafo);
272  }
273  *trafo = prev;
274 }
275 
276 // ----------------------------------------------------------------------------
277 void get_bounding_box (const aiScene* scene, aiVector3D* min, aiVector3D* max)
278 {
279  aiMatrix4x4 trafo;
280  aiIdentityMatrix4(&trafo);
281 
282  min->x = min->y = min->z = 1e10f;
283  max->x = max->y = max->z = -1e10f;
284  get_bounding_box_for_node(scene,scene->mRootNode,min,max,&trafo);
285 }
286 
287 // ----------------------------------------------------------------------------
288 void color4_to_float4(const aiColor4D *c, float f[4])
289 {
290  f[0] = c->r;
291  f[1] = c->g;
292  f[2] = c->b;
293  f[3] = c->a;
294 }
295 
296 // ----------------------------------------------------------------------------
297 void set_float4(float f[4], float a, float b, float c, float d)
298 {
299  f[0] = a;
300  f[1] = b;
301  f[2] = c;
302  f[3] = d;
303 }
304 
305 // ----------------------------------------------------------------------------
306 void apply_material(const aiMaterial *mtl,const std::vector<unsigned int> &textureIds, 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 
322  int texIndex = 0;
323  aiString texPath; //contains filename of texture
324 
325  if(AI_SUCCESS == mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath))
326  {
327  //bind texture
329  if (it==textureIdMap.end())
330  {
331  std::cerr << "[CAssimpModel] Error: using un-loaded texture '"<< texPath.data <<"'\n";
332  }
333  else
334  {
335  unsigned int texId = textureIds[it->second.id_idx];
337  }
338  }
339 
340  set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
341  if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
342  color4_to_float4(&diffuse, c);
344 
345  set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
346  if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
347  color4_to_float4(&specular, c);
349 
350  set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
351  if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
352  color4_to_float4(&ambient, c);
354 
355  set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
356  if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
357  color4_to_float4(&emission, c);
359 
360  max = 1;
361  ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
362  if(ret1 == AI_SUCCESS) {
363  max = 1;
364  ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
365  if(ret2 == AI_SUCCESS)
366  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
367  else
369  }
370  else {
372  set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
374  }
375 
376  max = 1;
377  if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max))
378  fill_mode = wireframe ? GL_LINE : GL_FILL;
379  else
380  fill_mode = GL_FILL;
381  glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
382 
383  max = 1;
384  if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided)
386  else
388 }
389 
390 // Can't send color down as a pointer to aiColor4D because AI colors are ABGR.
391 void Color4f(const aiColor4D *color)
392 {
393  glColor4f(color->r, color->g, color->b, color->a);
394 }
395 
396 // ----------------------------------------------------------------------------
397 void recursive_render (const aiScene *sc, const aiNode* nd,const std::vector<unsigned int> &textureIds, const std::map<std::string,CAssimpModel::TInfoPerTexture> &textureIdMap)
398 {
399  unsigned int i;
400  unsigned int n=0, t;
401  aiMatrix4x4 m = nd->mTransformation;
402 
403  // update transform
404  m.Transpose();
405  glPushMatrix();
406  glMultMatrixf((float*)&m);
407 
408  // draw all meshes assigned to this node
409  for (; n < nd->mNumMeshes; ++n)
410  {
411  const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
412 
413  apply_material(sc->mMaterials[mesh->mMaterialIndex],textureIds,textureIdMap);
414 
415 
416  if(mesh->mNormals == NULL)
418  else
420 
421  if(mesh->mColors[0] != NULL)
423  else
425 
426  for (t = 0; t < mesh->mNumFaces; ++t)
427  {
428  const struct aiFace* face = &mesh->mFaces[t];
429  GLenum face_mode;
430 
431  switch(face->mNumIndices)
432  {
433  case 1: face_mode = GL_POINTS; break;
434  case 2: face_mode = GL_LINES; break;
435  case 3: face_mode = GL_TRIANGLES; break;
436  default: face_mode = GL_POLYGON; break;
437  }
438 
439  glBegin(face_mode);
440 
441  for(i = 0; i < face->mNumIndices; i++) // go through all vertices in face
442  {
443  int vertexIndex = face->mIndices[i]; // get group index for current index
444  if(mesh->mColors[0] != NULL)
445  Color4f(&mesh->mColors[0][vertexIndex]);
446 
447  if(mesh->HasTextureCoords(0)) //HasTextureCoords(texture_coordinates_set)
448  {
449  glTexCoord2f(mesh->mTextureCoords[0][vertexIndex].x, 1 - mesh->mTextureCoords[0][vertexIndex].y); //mTextureCoords[channel][vertex]
450  }
451 
452  if (mesh->mNormals) {
453  glNormal3fv(&mesh->mNormals[vertexIndex].x);
454  }
455  glVertex3fv(&mesh->mVertices[vertexIndex].x);
456  }
457  glEnd();
458  }
459  }
460 
461  // draw all children
462  for (n = 0; n < nd->mNumChildren; ++n)
463  recursive_render(sc, nd->mChildren[n],textureIds,textureIdMap);
464 
465  glPopMatrix();
466 }
467 
468 // http://stackoverflow.com/questions/3418231/replace-part-of-a-string-with-another-string
469 void replaceAll(std::string& str, const std::string& from, const std::string& to) {
470  if(from.empty())
471  return;
472  size_t start_pos = 0;
473  while((start_pos = str.find(from, start_pos)) != std::string::npos) {
474  str.replace(start_pos, from.length(), to);
475  start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
476  }
477 }
478 
479 void load_textures(
480  const aiScene *scene,
481  std::vector<unsigned int> &textureIds,
482  std::map<std::string,CAssimpModel::TInfoPerTexture> &textureIdMap,
483  const std::string &modelPath)
484 {
485  if (scene->HasTextures()) THROW_EXCEPTION("Support for meshes with embedded textures is not implemented")
486 
487  textureIdMap.clear();
488 
489  /* getTexture Filenames and no. of Textures */
490  for (unsigned int m=0; m<scene->mNumMaterials; m++)
491  {
492  int texIndex = 0;
493  for (;;)
494  {
495  aiString path; // filename
496  aiReturn texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path);
497  if (texFound == AI_SUCCESS)
498  {
499  CAssimpModel::TInfoPerTexture &ipt = textureIdMap[path.data];
500  ipt.id_idx = std::string::npos; //fill map with textures, pointers still NULL yet
501  texIndex++;
502  }
503  else break;
504  }
505  }
506 
507  int numTextures = textureIdMap.size();
508 
509  /* create and fill array with GL texture ids */
510  textureIds.resize(numTextures);
511  if (numTextures) {
512  glGenTextures(numTextures, &textureIds[0]); /* Texture name generation */
513  }
514 
515  /* get iterator */
517 
519  for (int i=0; i<numTextures; i++)
520  {
521 
522  //save IL image ID
523  std::string filename = itr->first; // get filename
524  CAssimpModel::TInfoPerTexture &ipt = itr->second;
525  ipt.id_idx = i; // save texture id for filename in map
526  ++itr; // next texture
527 
528  const std::string fileloc = mrpt::system::filePathSeparatorsToNative( basepath + filename );
529 
532  mrpt::utils::CImage *img_rgb = ipt.img_rgb.pointer();
533  mrpt::utils::CImage *img_a = ipt.img_alpha.pointer();
534 
535  // Load images:
536  // TGA is handled specially since it's not supported by OpenCV:
537  bool load_ok;
538  if ( mrpt::system::lowerCase(mrpt::system::extractFileExtension(fileloc))==string("tga"))
539  {
540  load_ok = CImage::loadTGA(fileloc,*img_rgb,*img_a);
541  }
542  else
543  {
544  load_ok = img_rgb->loadFromFile(fileloc);
545  }
546 
547  if (load_ok)
548  {
549  //success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); /* Convert every colour component into unsigned byte. If your image contains alpha channel you can replace IL_RGB with IL_RGBA */
550  glBindTexture(GL_TEXTURE_2D, textureIds[i]); /* Binding of texture name */
551  //redefine standard texture values
553  interpolation for magnification filter */
555  interpolation for minifying filter */
556  //glTexImage2D(
557  // GL_TEXTURE_2D,
558  // 0,
559  // 8 /*ilGetInteger(IL_IMAGE_BPP)*/,
560  // /* ilGetInteger(IL_IMAGE_WIDTH)*/,
561  // /*ilGetInteger(IL_IMAGE_HEIGHT)*/,
562  // 0,
563  // /*ilGetInteger(IL_IMAGE_FORMAT)*/,
564  // GL_UNSIGNED_BYTE,
565  // ilGetData()); /* Texture specification */
566 
567  const int width = img_rgb->getWidth();
568  const int height = img_rgb->getHeight();
569 
570  // Prepare image data types:
571  const GLenum img_type = GL_UNSIGNED_BYTE;
572  const int nBytesPerPixel = img_rgb->isColor() ? 3 : 1;
573  const bool is_RGB_order = (!::strcmp(img_rgb->getChannelsOrder(),"RGB")); // Reverse RGB <-> BGR order?
574  const GLenum img_format = nBytesPerPixel==3 ? (is_RGB_order ? GL_RGB : GL_BGR): GL_LUMINANCE;
575 
576  // Send image data to OpenGL:
578  glPixelStorei(GL_UNPACK_ROW_LENGTH,img_rgb->getRowStride()/nBytesPerPixel );
579  glTexImage2D(GL_TEXTURE_2D, 0 /*level*/, 3 /* RGB components */, width, height,0 /*border*/, img_format, img_type, img_rgb->get_unsafe(0,0) );
581  }
582  else
583  {
584  /* Error occured */
585  const std::string sError = mrpt::format("[CAssimpModel] Couldn't load texture image: '%s'", fileloc.c_str());
586  cout << sError << endl;
587 #ifdef _MSC_VER
588  OutputDebugStringA(&sError[0]);
589 #endif
590  }
591  }
592 }
593 
594 
595 #endif // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP
GLAPI void GLAPIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
#define GL_BGR
Definition: glew.h:1144
EIGEN_STRONG_INLINE bool empty() const
#define GL_SPECULAR
Definition: glew.h:576
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
GLdouble GLdouble t
Definition: glext.h:3610
#define min(a, b)
GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
#define GL_FRONT_AND_BACK
Definition: glew.h:317
size_t id_idx
indices in m_textureIds. string::npos for non-initialized ones.
Definition: CAssimpModel.h:68
#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:4618
const char * getChannelsOrder() const
Returns a string of the form "BGR","RGB" or "GRAY" indicating the channels ordering.
Definition: CImage.cpp:1180
Scalar * iterator
Definition: eigen_plugins.h:23
#define GL_TRIANGLES
Definition: glew.h:272
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const MRPT_OVERRIDE
Simulation of ray-trace, given a pose.
#define GL_CULL_FACE
Definition: glew.h:378
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:298
#define GL_FILL
Definition: glew.h:626
#define GL_NORMALIZE
Definition: glew.h:412
#define GL_LINEAR
Definition: glew.h:656
const Scalar * const_iterator
Definition: eigen_plugins.h:24
double z
X,Y,Z coordinates.
#define GL_COLOR_MATERIAL
Definition: glew.h:388
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void loadScene(const std::string &file_name)
Loads a scene from a file in any supported file.
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:277
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
mrpt::math::TPoint3D m_bbox_min
Definition: CAssimpModel.h:87
#define GL_POLYGON
Definition: glew.h:277
#define GL_LIGHTING
Definition: glew.h:381
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. This class automatically holds the cached 3x3 rotation m...
Definition: CRenderizable.h:55
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
GLenum GLsizei width
Definition: glext.h:3513
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
GLuint color
Definition: glext.h:7093
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, 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:439
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
mrpt::math::TPoint3D m_bbox_max
Bounding box.
Definition: CAssimpModel.h:87
std::string BASE_IMPEXP lowerCase(const std::string &str)
Returns an lower-case version of a string.
#define MRPT_END
void clear()
Empty the object.
std::string BASE_IMPEXP filePathSeparatorsToNative(const std::string &filePath)
Windows: replace all &#39;/&#39;->&#39;\&#39; , in Linux/MacOS: replace all &#39;\&#39;->&#39;/&#39;.
Definition: filesystem.cpp:543
#define GL_DIFFUSE
Definition: glew.h:575
const GLubyte * c
Definition: glext.h:5590
#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:602
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
GLubyte GLubyte b
Definition: glext.h:5575
size_t getRowStride() const
Returns the row stride of the image: this is the number of bytes between two consecutive rows...
Definition: CImage.cpp:869
#define GL_RGB
Definition: glew.h:619
std::string BASE_IMPEXP extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
Definition: filesystem.cpp:96
int version
Definition: mrpt_jpeglib.h:898
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_POINTS
Definition: glew.h:268
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
Definition: glext.h:3919
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:93
GLAPI void GLAPIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
unsigned int GLenum
Definition: glew.h:202
#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:477
#define GL_TEXTURE_MIN_FILTER
Definition: glew.h:662
static CImagePtr Create()
#define GL_UNPACK_ALIGNMENT
Definition: glew.h:480
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
#define GL_LINE
Definition: glew.h:625
#define GL_TEXTURE_MAG_FILTER
Definition: glew.h:661
GLAPI void GLAPIENTRY glPolygonMode(GLenum face, GLenum mode)
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
GLuint in
Definition: glext.h:6301
The namespace for 3D scene representation and rendering.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
GLAPI void GLAPIENTRY glEnd(void)
#define GL_LIGHT_MODEL_TWO_SIDE
Definition: glew.h:383
#define GL_SHININESS
Definition: glew.h:603
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
Definition: CImage.cpp:898
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, which checks the coordinates.
Definition: CImage.cpp:491
#define GL_LINES
Definition: glew.h:269
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GLAPI void GLAPIENTRY glPushMatrix(void)
Lightweight 3D point.
GLenum GLsizei GLsizei height
Definition: glext.h:3523
GLAPI void GLAPIENTRY glDisable(GLenum cap)
A container for automatic deletion of lib3ds&#39;s scene when the last reference of the smart_ptr&#39;s is de...
Definition: CAssimpModel.h:79
void render_dl() const MRPT_OVERRIDE
Render child objects.
GLubyte GLubyte GLubyte a
Definition: glext.h:5575
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
size_t getWidth() const MRPT_OVERRIDE
Returns the width of the image in pixels.
Definition: CImage.cpp:855
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:42
#define GL_TEXTURE_2D
Definition: glew.h:6074
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:91
std::string BASE_IMPEXP 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:621
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:289
#define GL_AMBIENT
Definition: glew.h:574
GLenum GLuint GLint GLenum face
Definition: glext.h:7014
std::shared_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:85
size_t getHeight() const MRPT_OVERRIDE
Returns the height of the image in pixels.
Definition: CImage.cpp:884



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020