Main MRPT website > C++ reference for MRPT 1.9.9
C3DSScene.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 #include "opengl-precomp.h" // Precompiled header
11 
12 #include <mrpt/config.h>
13 
14 #if MRPT_HAS_LIB3DS
15 // Include the lib3ds library:
16 #include <lib3ds/file.h>
17 #include <lib3ds/background.h>
18 #include <lib3ds/camera.h>
19 #include <lib3ds/mesh.h>
20 #include <lib3ds/node.h>
21 #include <lib3ds/material.h>
22 #include <lib3ds/matrix.h>
23 #include <lib3ds/vector.h>
24 #include <lib3ds/light.h>
25 #endif
26 
27 #include <mrpt/opengl/C3DSScene.h>
29 
30 #include <mrpt/compress/zip.h>
31 #include <mrpt/system/filesystem.h>
33 
34 #include <mrpt/utils/CStringList.h>
35 #include <mrpt/utils/CStream.h>
38 
39 #include "opengl_internals.h"
40 
41 using namespace mrpt;
42 using namespace mrpt::opengl;
43 using namespace mrpt::utils;
44 using namespace mrpt::math;
45 using namespace std;
46 
48 
49 #if MRPT_HAS_LIB3DS
50 static void render_node(Lib3dsNode* node, Lib3dsFile* file);
51 static void light_update(Lib3dsLight* l, Lib3dsFile* file);
52 #endif
53 
54 /*---------------------------------------------------------------
55  render
56  ---------------------------------------------------------------*/
58 {
59 #if MRPT_HAS_LIB3DS
60 #if MRPT_HAS_OPENGL_GLUT
62 
63  if (!m_3dsfile->file) return; // No scene
64 
65  Lib3dsFile* file = (Lib3dsFile*)m_3dsfile->file;
66  if (!file) return;
67 
69 
72 
73  // Add an ambient light:
74  if (m_enable_extra_lighting)
75  {
76  int li = GL_LIGHT7;
77  const GLfloat a[] = {0.8f, 0.8f, 0.8f, 1.0f};
78  GLfloat c[] = {0.5f, 0.5f, 0.5f, 0.5f};
79 
80  glLightfv(li, GL_AMBIENT, a);
81  glLightfv(li, GL_DIFFUSE, c);
82  glLightfv(li, GL_SPECULAR, c);
83  glEnable(li);
84  }
85 
86  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, file->ambient);
87 
88  /* Lights. Set them from light nodes if possible. If not, use the
89  * light objects directly.
90  */
91  {
92  const GLfloat a[] = {0.1f, 0.1f, 0.1f, 1.0f};
93  GLfloat c[] = {1.0f, 1.0f, 1.0f, 1.0f};
94  GLfloat p[] = {0.0f, 0.0f, 0.0f, 1.0f};
95 
96  int li = GL_LIGHT0;
97  for (Lib3dsLight* l = file->lights; l; l = l->next)
98  {
99  glEnable(li);
100 
101  light_update(l, file);
102 
103  c[0] = l->color[0];
104  c[1] = l->color[1];
105  c[2] = l->color[2];
106  // c[3] = l->multiplier;
107  glLightfv(li, GL_AMBIENT, a);
108  glLightfv(li, GL_DIFFUSE, c);
109  glLightfv(li, GL_SPECULAR, c);
110 
111  // float att = (1.0/m_scale_x)-1;
112  // glLightfv(li, GL_LINEAR_ATTENUATION, &att );
113 
114  float att = 1.0 / m_scale_x;
116 
117  p[0] = l->position[0];
118  p[1] = l->position[1];
119  p[2] = l->position[2];
120  glLightfv(li, GL_POSITION, p);
121 
122  if (l->spot_light)
123  {
124  p[0] = (l->spot[0] - l->position[0]);
125  p[1] = (l->spot[1] - l->position[1]);
126  p[2] = (l->spot[2] - l->position[2]);
128  }
129  ++li;
130  }
131  }
132 
133  for (Lib3dsNode* p = file->nodes; p != 0; p = p->next) render_node(p, file);
134 
136  MRPT_END
137 #endif
138 #else
139  THROW_EXCEPTION("This class requires compiling MRPT against lib3ds");
140 #endif
141 }
142 
143 #if MRPT_HAS_LIB3DS
144 
145 // texture size: by now minimum standard
146 #define TEX_XSIZE 1024
147 #define TEX_YSIZE 1024
148 
149 struct _player_texture
150 {
151  int valid; // was the loading attempt successful ?
152 #ifdef USE_SDL
153  SDL_Surface* bitmap;
154 #else
155  void* bitmap;
156 #endif
157 
158 #if MRPT_HAS_OPENGL_GLUT
159  GLuint tex_id; // OpenGL texture ID
160 #else
161  unsigned int tex_id; // OpenGL texture ID
162 #endif
163 
164  float scale_x, scale_y; // scale the texcoords, as OpenGL thinks in
165  // TEX_XSIZE and TEX_YSIZE
166 };
167 
168 typedef struct _player_texture Player_texture;
169 Player_texture* pt;
170 int tex_mode = 0; // Texturing active ?
171 
172 const char* datapath = ".";
173 
174 /*
175 * Render node recursively, first children, then parent.
176 * Each node receives its own OpenGL display list.
177 */
178 static void render_node(Lib3dsNode* node, Lib3dsFile* file)
179 {
180 #if MRPT_HAS_OPENGL_GLUT
181  {
182  Lib3dsNode* p;
183  for (p = node->childs; p != 0; p = p->next)
184  {
185  render_node(p, file);
186  }
187  }
188  if (node->type == LIB3DS_OBJECT_NODE)
189  {
190  Lib3dsMesh* mesh;
191 
192  if (strcmp(node->name, "$$$DUMMY") == 0)
193  {
194  return;
195  }
196 
197  mesh = lib3ds_file_mesh_by_name(file, node->data.object.morph);
198  if (mesh == nullptr) mesh = lib3ds_file_mesh_by_name(file, node->name);
199 
200  if (!mesh->user.d)
201  {
202  ASSERT(mesh);
203  if (!mesh)
204  {
205  return;
206  }
207 
208  mesh->user.d = glGenLists(1);
209  glNewList(mesh->user.d, GL_COMPILE);
210 
211  {
212  unsigned p;
213  Lib3dsVector* normalL = (Lib3dsVector*)malloc(
214  3 * sizeof(Lib3dsVector) * mesh->faces);
215  Lib3dsMaterial* oldmat = (Lib3dsMaterial*)-1;
216  {
217  Lib3dsMatrix M;
218  lib3ds_matrix_copy(M, mesh->matrix);
219  lib3ds_matrix_inv(M);
220  glMultMatrixf(&M[0][0]);
221  }
222  lib3ds_mesh_calculate_normals(mesh, normalL);
223 
224  for (p = 0; p < mesh->faces; ++p)
225  {
226  Lib3dsFace* f = &mesh->faceL[p];
227  Lib3dsMaterial* mat = 0;
228 #ifdef USE_SDL
229  Player_texture* pt = nullptr;
230  int tex_mode = 0;
231 #endif
232  if (f->material[0])
233  {
234  mat = lib3ds_file_material_by_name(file, f->material);
235  }
236 
237  if (mat != oldmat)
238  {
239  if (mat)
240  {
241  if (mat->two_sided)
243  else
245 
247 
248  /* Texturing added by Gernot < gz@lysator.liu.se >
249  */
250 
251  /*
252  if (mat->texture1_map.name[0]) {
253  //
254  texture map?
255  Lib3dsTextureMap *tex =
256  &mat->texture1_map;
257  if (!tex->user.p) { // no
258  player texture yet?
259  char texname[1024];
260  pt = (Player_texture*)
261  malloc(sizeof(*pt));
262  tex->user.p = pt;
263  snprintf(texname, sizeof(texname),
264  "%s/%s", datapath, tex->name);
265  strcpy(texname, datapath);
266  strcat(texname, "/");
267  strcat(texname, tex->name);
268  #ifdef DEBUG
269  printf("Loading texture map, name
270  %s\n", texname);
271  #endif
272  #ifdef USE_SDL
273  #ifdef USE_SDL_IMG_load
274  pt->bitmap = IMG_load(texname);
275  #else
276  pt->bitmap = IMG_Load(texname);
277  #endif
278 
279  #else
280  pt->bitmap = nullptr;
281  fputs("3dsplayer: Warning: No
282  image loading support, skipping texture.\n",
283  stderr);
284  #endif // USE_SDL
285  if (pt->bitmap) { // could image
286  be loaded ?
287  // this OpenGL texupload code is
288  incomplete format-wise!
289  // to make it complete, examine
290  SDL_surface->format and
291  // tell us @lib3ds.sf.net about
292  your improvements :-)
293  //int upload_format = GL_RED; //
294  safe choice, shows errors
295  #ifdef USE_SDL
296  int bytespp =
297  pt->bitmap->format->BytesPerPixel;
298  void *pixel = nullptr;
299  glGenTextures(1, &pt->tex_id);
300  #ifdef DEBUG
301  printf("Uploading texture to
302  OpenGL, id %d, at %d bytepp\n",
303  pt->tex_id, bytespp);
304  #endif
305  if (pt->bitmap->format->palette)
306  {
307  pixel =
308  convert_to_RGB_Surface(pt->bitmap);
309  upload_format = GL_RGBA;
310  }
311  else {
312  pixel = pt->bitmap->pixels;
313  // e.g. this could also be a
314  color palette
315  if (bytespp == 1)
316  upload_format = GL_LUMINANCE;
317  else if (bytespp == 3)
318  upload_format = GL_RGB;
319  else if (bytespp == 4)
320  upload_format = GL_RGBA;
321  }
322  glBindTexture(GL_TEXTURE_2D,
323  pt->tex_id);
324  glTexImage2D(GL_TEXTURE_2D, 0,
325  GL_RGBA,
326  TEX_XSIZE, TEX_YSIZE, 0,
327  GL_RGBA, GL_UNSIGNED_BYTE,
328  nullptr);
329  glTexParameteri(GL_TEXTURE_2D,
330  GL_TEXTURE_WRAP_S, GL_CLAMP);
331  glTexParameteri(GL_TEXTURE_2D,
332  GL_TEXTURE_WRAP_T, GL_CLAMP);
333  glTexParameteri(GL_TEXTURE_2D,
334  GL_TEXTURE_MAG_FILTER,
335  GL_LINEAR);
336  glTexParameteri(GL_TEXTURE_2D,
337  GL_TEXTURE_MIN_FILTER,
338  GL_LINEAR);
339  glTexEnvi(GL_TEXTURE_ENV,
340  GL_TEXTURE_ENV_MODE, GL_REPLACE);
341  glTexSubImage2D(GL_TEXTURE_2D,
342  0, 0, 0, pt->bitmap->w,
343  pt->bitmap->h,
344  upload_format,
345  GL_UNSIGNED_BYTE, pixel);
346  pt->scale_x =
347  (float)pt->bitmap->w/(float)TEX_XSIZE;
348  pt->scale_y =
349  (float)pt->bitmap->h/(float)TEX_YSIZE;
350  #endif
351  pt->valid = 1;
352  }
353  else {
354  fprintf(stderr,
355  "Load of texture %s did not
356  succeed "
357  "(format not supported !)\n",
358  texname);
359  pt->valid = 0;
360  }
361  }
362  else {
363  pt = (Player_texture
364  *)tex->user.p;
365  }
366  tex_mode = pt->valid;
367  }
368  else */
369  {
370  tex_mode = 0;
371  }
372  glMaterialfv(GL_FRONT, GL_AMBIENT, mat->ambient);
373  glMaterialfv(GL_FRONT, GL_DIFFUSE, mat->diffuse);
374  glMaterialfv(GL_FRONT, GL_SPECULAR, mat->specular);
375  glMaterialf(
377  pow(2.0, 10.0 * mat->shininess));
378  }
379  else
380  {
381  static const Lib3dsRgba a = {0.7f, 0.7f, 0.7f,
382  1.0f};
383  static const Lib3dsRgba d = {0.7f, 0.7f, 0.7f,
384  1.0f};
385  static const Lib3dsRgba s = {1.0f, 1.0f, 1.0f,
386  1.0f};
390  glMaterialf(
391  GL_FRONT, GL_SHININESS, pow(2.0, 10.0 * 0.5));
392  }
393  oldmat = mat;
394  }
395  else if (mat != nullptr && mat->texture1_map.name[0])
396  {
397  // Lib3dsTextureMap *tex = &mat->texture1_map;
398  // if (tex != nullptr && tex->user.p != nullptr)
399  //{
400  // pt = (Player_texture *)tex->user.p;
401  // tex_mode = pt->valid;
402  //}
403  }
404 
405  {
406  int i;
407 
408  if (tex_mode)
409  {
410  // printf("Binding texture %d\n", pt->tex_id);
412  glBindTexture(GL_TEXTURE_2D, pt->tex_id);
413  }
414 
416  glNormal3fv(f->normal);
417  for (i = 0; i < 3; ++i)
418  {
419  glNormal3fv(normalL[3 * p + i]);
420 
421  if (tex_mode)
422  {
423  glTexCoord2f(
424  mesh->texelL[f->points[i]][1] * pt->scale_x,
425  pt->scale_y -
426  mesh->texelL[f->points[i]][0] *
427  pt->scale_y);
428  }
429 
430  glVertex3fv(mesh->pointL[f->points[i]].pos);
431  }
432  glEnd();
433 
434  if (tex_mode) glDisable(GL_TEXTURE_2D);
435  }
436  }
437 
438  free(normalL);
439  }
440 
441  glEndList();
442  }
443 
444  if (mesh->user.d)
445  {
446  Lib3dsObjectData* d;
447 
448  glPushMatrix();
449  d = &node->data.object;
450  glMultMatrixf(&node->matrix[0][0]);
451  glTranslatef(-d->pivot[0], -d->pivot[1], -d->pivot[2]);
452  glCallList(mesh->user.d);
453  /* glutSolidSphere(50.0, 20,20); */
454  glPopMatrix();
455  // if( flush ) glFlush();
456  }
457  }
458 #else
459  MRPT_UNUSED_PARAM(node);
460  MRPT_UNUSED_PARAM(file);
461  THROW_EXCEPTION("MRPT was compiled without OpenGL support")
462 #endif
463 }
464 
465 /*!
466 * Update information about a light. Try to find corresponding nodes
467 * if possible, and copy values from nodes into light struct.
468 */
469 static void light_update(Lib3dsLight* l, Lib3dsFile* file)
470 {
471  Lib3dsNode *ln, *sn;
472 
473  ln = lib3ds_file_node_by_name(file, l->name, LIB3DS_LIGHT_NODE);
474  sn = lib3ds_file_node_by_name(file, l->name, LIB3DS_SPOT_NODE);
475 
476  if (ln != nullptr)
477  {
478  memcpy(l->color, ln->data.light.col, sizeof(Lib3dsRgb));
479  memcpy(l->position, ln->data.light.pos, sizeof(Lib3dsVector));
480  }
481 
482  if (sn != nullptr) memcpy(l->spot, sn->data.spot.pos, sizeof(Lib3dsVector));
483 }
484 #endif
485 
486 /*---------------------------------------------------------------
487  Implements the writing to a CStream capability of
488  CSerializable objects
489  ---------------------------------------------------------------*/
490 void C3DSScene::writeToStream(mrpt::utils::CStream& out, int* version) const
491 {
492 #if MRPT_HAS_LIB3DS
493  if (version)
494  *version = 2;
495  else
496  {
497  writeToStreamRender(out);
498 
499  CMemoryChunk chunk;
500  if (m_3dsfile && m_3dsfile->file)
501  {
502  const string tmpFil = mrpt::system::getTempFileName();
503  lib3ds_file_save((Lib3dsFile*)m_3dsfile->file, tmpFil.c_str());
504  chunk.loadBufferFromFile(tmpFil);
505  mrpt::system::deleteFile(tmpFil);
506  }
507 
508  // Write the "3dsfile":
509  out << chunk;
510 
511  out << m_enable_extra_lighting; // Added in version 1
512  }
513 #else
514  THROW_EXCEPTION("This class requires compiling MRPT against lib3ds");
515 #endif
516 }
517 
518 /*---------------------------------------------------------------
519  Implements the reading from a CStream capability of
520  CSerializable objects
521  ---------------------------------------------------------------*/
523 {
524 #if MRPT_HAS_LIB3DS
525  switch (version)
526  {
527  case 0:
528  case 1:
529  case 2:
530  {
531  readFromStreamRender(in);
532 
533  // Read the memory block, save to a temp. "3dsfile" and load...
534  clear();
535 
536  CMemoryChunk chunk;
537  in >> chunk;
538 
539  if (chunk.getTotalBytesCount())
540  {
541  const string tmpFil = mrpt::system::getTempFileName();
542  if (!chunk.saveBufferToFile(tmpFil))
543  THROW_EXCEPTION("Error saving temporary 3ds file");
544 
545  try
546  {
547  loadFrom3DSFile(tmpFil);
548  }
549  catch (...)
550  {
551  THROW_EXCEPTION("Error loading temporary 3ds file");
552  }
553  mrpt::system::deleteFile(tmpFil);
554  }
555 
556  if (version >= 1)
557  {
558  if (version == 1)
559  {
560  double dummy_scale;
561  in >> dummy_scale >> dummy_scale >> dummy_scale;
562  }
563  in >> m_enable_extra_lighting;
564  }
565  else
566  {
567  m_enable_extra_lighting = false;
568  }
569  }
570  break;
571  default:
573  };
575 #else
576  THROW_EXCEPTION("This class requires compiling MRPT against lib3ds");
577 #endif
578 }
579 
580 /*---------------------------------------------------------------
581  initializeAllTextures
582  ---------------------------------------------------------------*/
584 {
585 #if MRPT_HAS_OPENGL_GLUT
586 
587 #endif
588 }
589 
591  : m_bbox_min(0, 0, 0), m_bbox_max(0, 0, 0), m_enable_extra_lighting(false)
592 {
593  m_3dsfile = mrpt::make_aligned_shared<TImpl3DS>();
594 }
595 
597 /*---------------------------------------------------------------
598  clear
599  ---------------------------------------------------------------*/
601 {
603  m_3dsfile = mrpt::make_aligned_shared<TImpl3DS>();
604 }
605 
607 {
608 #if MRPT_HAS_LIB3DS
609  clear();
611 
612  Lib3dsFile* file = 0;
613 
614  // Normal file, or .gz file?
615  if (mrpt::system::extractFileExtension(filepath) == "gz")
616  {
617  // Load compressed file:
618  vector_byte out_data;
619  if (!mrpt::compress::zip::decompress_gz_file(filepath, out_data))
621  "Error loading compressed file: %s", filepath.c_str())
622 
623  // Save to tmp file & load:
624  string tmpFil = mrpt::system::getTempFileName();
625 
626  mrpt::system::vectorToBinaryFile(out_data, tmpFil);
627  out_data.clear();
628 
629  file = lib3ds_file_load(tmpFil.c_str());
630 
631  mrpt::system::deleteFile(tmpFil);
632  }
633  else
634  {
635  // Uncompressed file:
636  file = lib3ds_file_load(filepath.c_str());
637  }
638 
639  if (!file)
640  {
641  THROW_EXCEPTION_FMT("Error loading 3DS file: %s", filepath.c_str());
642  }
643 
644  /* No nodes? Fabricate nodes to display all the meshes. */
645  if (!file->nodes)
646  {
647  for (Lib3dsMesh* mesh = file->meshes; mesh != nullptr;
648  mesh = mesh->next)
649  {
650  Lib3dsNode* node = lib3ds_node_new_object();
651  strcpy(node->name, mesh->name);
652  node->parent_id = LIB3DS_NO_PARENT;
653  lib3ds_file_insert_node(file, node);
654  }
655  }
656 
657  lib3ds_file_eval(file, 1.0f); // Eval in time
658 
659  Lib3dsVector bmin, bmax;
660  float sx, sy, sz, size; /* bounding box dimensions */
661  float cx, cy, cz; /* bounding box center */
662 
663  lib3ds_file_bounding_box_of_nodes(
664  file, LIB3DS_TRUE, LIB3DS_FALSE, LIB3DS_FALSE, bmin, bmax);
665 
666  for (int k = 0; k < 3; k++)
667  {
668  m_bbox_min[k] = bmin[k];
669  m_bbox_max[k] = bmax[k];
670  }
671 
672  sx = bmax[0] - bmin[0];
673  sy = bmax[1] - bmin[1];
674  sz = bmax[2] - bmin[2];
675  size = max(sx, sy);
676  size = max(size, sz);
677  cx = (bmin[0] + bmax[0]) / 2;
678  cy = (bmin[1] + bmax[1]) / 2;
679  cz = (bmin[2] + bmax[2]) / 2;
680 
681  /* No lights in the file? Add some. */
682 
683  if (file->lights == nullptr)
684  {
685  Lib3dsLight* light;
686 
687  light = lib3ds_light_new("light0");
688  light->spot_light = 0;
689  light->see_cone = 0;
690  light->color[0] = light->color[1] = light->color[2] = .6f;
691  light->position[0] = cx + size * .75;
692  light->position[1] = cy - size * 1.;
693  light->position[2] = cz + size * 1.5;
694  // Out of bounds? //light->position[3] = 0.;
695  light->outer_range = 100;
696  light->inner_range = 10;
697  light->multiplier = 1;
698  lib3ds_file_insert_light(file, light);
699 
700  light = lib3ds_light_new("light1");
701  light->spot_light = 0;
702  light->see_cone = 0;
703  light->color[0] = light->color[1] = light->color[2] = .3f;
704  light->position[0] = cx - size;
705  light->position[1] = cy - size;
706  light->position[2] = cz + size * .75;
707  // Out of bounds? light->position[3] = 0.;
708  light->outer_range = 100;
709  light->inner_range = 10;
710  light->multiplier = 1;
711  lib3ds_file_insert_light(file, light);
712 
713  light = lib3ds_light_new("light2");
714  light->spot_light = 0;
715  light->see_cone = 0;
716  light->color[0] = light->color[1] = light->color[2] = .3f;
717  light->position[0] = cx;
718  light->position[1] = cy + size;
719  light->position[2] = cz + size;
720  // Out of bounds? light->position[3] = 0.;
721  light->outer_range = 100;
722  light->inner_range = 10;
723  light->multiplier = 1;
724  lib3ds_file_insert_light(file, light);
725  }
726 
727  lib3ds_file_eval(file, 0.);
728 
729  m_3dsfile->file = file;
730 #else
731  THROW_EXCEPTION("This class requires compiling MRPT against lib3ds");
732 #endif
733 }
734 
735 void C3DSScene::evaluateAnimation(double time_anim)
736 {
737 #if MRPT_HAS_LIB3DS
738  if (m_3dsfile->file)
739  {
741  lib3ds_file_eval((Lib3dsFile*)m_3dsfile->file, time_anim);
742  }
743 #else
744  THROW_EXCEPTION("This class requires compiling MRPT against lib3ds");
745 #endif
746 }
747 
749  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
750 {
751  bb_min = m_bbox_min;
752  bb_max = m_bbox_max;
753 
754  // Convert to coordinates of my parent:
755  m_pose.composePoint(bb_min, bb_min);
756  m_pose.composePoint(bb_max, bb_max);
757 }
758 
759 C3DSScene::TImpl3DS::TImpl3DS() : file(nullptr) {}
761 {
762 #if MRPT_HAS_LIB3DS
763  if (file)
764  {
765  lib3ds_file_free((Lib3dsFile*)file);
766  file = nullptr;
767  }
768 #endif
769 }
770 
771 bool C3DSScene::traceRay(const mrpt::poses::CPose3D& o, double& dist) const
772 {
774  MRPT_UNUSED_PARAM(dist);
775  // TODO
776  return false;
777 }
unsigned int GLuint
Definition: glew.h:208
#define GL_SPECULAR
Definition: glew.h:580
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define GL_POLYGON_SMOOTH
Definition: glew.h:379
std::vector< uint8_t > vector_byte
Definition: types_simple.h:27
GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI GLuint GLAPIENTRY glGenLists(GLsizei range)
std::shared_ptr< TImpl3DS > m_3dsfile
An internal pointer to the lib3ds library&#39;s object of type "Lib3dsFile".
Definition: C3DSScene.h:92
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...
Definition: C3DSScene.cpp:522
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define THROW_EXCEPTION(msg)
GLAPI void GLAPIENTRY glPopMatrix(void)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
C3DSScene()
Default constructor.
Definition: C3DSScene.cpp:590
#define GL_TRIANGLES
Definition: glew.h:276
#define GL_BACK
Definition: glew.h:318
void render_dl() const override
Render child objects.
Definition: C3DSScene.cpp:57
#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.
bool vectorToBinaryFile(const vector_byte &vec, const std::string &fileName)
Saves a vector directly as a binary dump to a file:
#define GL_POSITION
Definition: glew.h:581
mrpt::math::TPoint3D m_bbox_min
Scale of the object.
Definition: C3DSScene.h:97
void initializeAllTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL) ...
Definition: C3DSScene.cpp:583
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
GLdouble s
Definition: glext.h:3676
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
#define GL_LIGHT0
Definition: glew.h:570
float GLfloat
Definition: glew.h:217
void clear()
Empty the object.
Definition: C3DSScene.cpp:600
void loadFrom3DSFile(const std::string &file_name)
Loads a scene from a 3DS file (3D Studio format) into this object, from either plain ...
Definition: C3DSScene.cpp:606
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
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
#define GL_LIGHT7
Definition: glew.h:577
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Definition: filesystem.cpp:281
#define GL_LIGHT_MODEL_AMBIENT
Definition: glew.h:388
#define MRPT_END
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#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)
GLAPI void GLAPIENTRY glCullFace(GLenum mode)
bool decompress_gz_file(const std::string &file_path, vector_byte &buffer)
Decompress a gzip file (xxxx.gz) into a memory buffer.
Definition: zip.cpp:211
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
Definition: filesystem.cpp:97
A memory buffer (implements CStream) which can be itself serialized.
Definition: CMemoryChunk.h:24
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLsizei const GLchar ** string
Definition: glext.h:4101
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...
Definition: C3DSScene.cpp:748
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Definition: C3DSScene.cpp:490
GLAPI void GLAPIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
GLAPI void GLAPIENTRY glNewList(GLuint list, GLenum mode)
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
#define MRPT_START
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
Definition: C3DSScene.cpp:771
virtual ~C3DSScene()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: C3DSScene.cpp:596
GLAPI void GLAPIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::math::TPoint3D m_bbox_max
Definition: C3DSScene.h:97
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
GLuint in
Definition: glext.h:7274
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
bool deleteFile(const std::string &fileName)
Deletes a single file.
Definition: filesystem.cpp:179
GLAPI void GLAPIENTRY glEnd(void)
#define GL_SHININESS
Definition: glew.h:607
GLAPI void GLAPIENTRY glEndList(void)
#define GL_CONSTANT_ATTENUATION
Definition: glew.h:585
#define GL_COMPILE
Definition: glew.h:588
GLsizeiptr size
Definition: glext.h:3923
GLAPI void GLAPIENTRY glPushMatrix(void)
Lightweight 3D point.
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
Definition: os.cpp:296
void evaluateAnimation(double time_anim)
Evaluates the scene at a given animation time.
Definition: C3DSScene.cpp:735
#define GL_FRONT
Definition: glew.h:317
GLAPI void GLAPIENTRY glDisable(GLenum cap)
bool loadBufferFromFile(const std::string &file_name)
Loads the entire buffer from a file *.
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLfloat GLfloat p
Definition: glext.h:6305
GLAPI void GLAPIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
#define GL_TEXTURE_2D
Definition: glew.h:7238
This element keeps a set of objects imported from a 3DStudio file (.3ds).
Definition: C3DSScene.h:26
GLAPI void GLAPIENTRY glLightModelfv(GLenum pname, const GLfloat *params)
#define GL_AMBIENT
Definition: glew.h:578
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
Definition: os.cpp:355
#define GL_SPOT_DIRECTION
Definition: glew.h:582
GLAPI void GLAPIENTRY glCallList(GLuint list)



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