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



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019