void CVirtualWorld::GetWorld(mrpt::opengl::CSetOfObjectsPtr &world) { using namespace mrpt::gui; world->clear(); for (size_t i=0;i<list_objects.size();i++) { double sizex,longitud; std::deque<std::string> tok; mrpt::system::tokenize(list_objects[i].size,"[ ",tok); //printf("%f,%f\n",atof(tok[0].c_str()),atof(tok[1].c_str())); sizex=atof(tok[1].c_str()); longitud=atof(tok[0].c_str()); CTexturedPlanePtr plane=CTexturedPlane::Create(0,sizex,0,longitud); plane->setPose(*list_objects[i].pose.pointer()); CImagePtr image=CImage::Create(); if (image->loadFromFile( list_objects[i].texture)) plane->assignImage(*image.pointer()); else printf("Texture file is missing or there was an error while loading\n"); world->insert(plane); } }
/*--------------------------------------------------------------- getAs3DObject ---------------------------------------------------------------*/ void COccupancyGridMap2D::getAs3DObject(mrpt::opengl::CSetOfObjectsPtr &outSetOfObj ) const { if (!genericMapParams.enableSaveAs3DObject) return; MRPT_START opengl::CTexturedPlanePtr outObj = opengl::CTexturedPlane::Create(); outObj->setPlaneCorners(x_min,x_max,y_min,y_max); outObj->setLocation(0,0, insertionOptions.mapAltitude ); // Create the color & transparecy (alpha) images: CImage imgColor(size_x,size_y,1); CImage imgTrans(size_x,size_y,1); const cellType *srcPtr = &map[0]; for (unsigned int y=0;y<size_y;y++) { unsigned char *destPtr_color = imgColor(0,y); unsigned char *destPtr_trans = imgTrans(0,y); for (unsigned int x=0;x<size_x;x++) { uint8_t cell255 = l2p_255(*srcPtr++); *destPtr_color++ = cell255; int8_t auxC = (int8_t)((signed short)cell255)-127; *destPtr_trans++ = auxC>0 ? (auxC << 1) : ((-auxC) << 1); } } outObj->assignImage_fast( imgColor,imgTrans ); outSetOfObj->insert( outObj ); MRPT_END }