Changeset 286 in flair-src for trunk/lib/FlairSimulator/src/Gui_impl.cpp


Ignore:
Timestamp:
01/08/19 10:13:03 (5 years ago)
Author:
Sanahuja Guillaume
Message:

draw vrpn axis in simulator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSimulator/src/Gui_impl.cpp

    r166 r286  
    9494  device->setResizable(false);
    9595
    96   // font = device->getGUIEnvironment()->getBuiltInFont();
    9796  driver = device->getVideoDriver();
    9897  smgr = device->getSceneManager();
     
    179178  int lastFPS = -1;
    180179  int cam_id = 0;
     180  ITexture* texture=0;
     181  IGUIFont* font =0;
     182 
     183  if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) {
     184    self->Warn("rendering to texture is not possible, axis will not be displayed\n");
     185  } else {
     186    texture= getGui()->getSceneManager()->getVideoDriver()->addRenderTargetTexture(dimension2d<u32>(128,128));
     187    device->getGUIEnvironment()->addImage(texture,position2d<s32>(0,scene_height-texture->getSize().Height));
     188    font = getGui()->getDevice()->getGUIEnvironment()->getFont((media_path+"/font/simu_axis_font.xml").c_str());
     189  }
    181190
    182191  receiver->SetModel(models.at(0));
     
    242251    driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height));
    243252    smgr->drawAll(); // commente voir plus bas
    244                      /*
    245                  env->drawAll();
    246                  if (font)
    247                  {
    248                                      font->draw(L"This demo shows that Irrlicht is also capable
    249                  of drawing 2D graphics.",
    250                                              core::rect<s32>(130,10,300,50),
    251                                              video::SColor(255,255,255,255));
    252                  }
    253                  else
    254                  {
    255                  printf("err\n");
    256                  }
    257                  device->setWindowCaption(L"toto");*/
    258 
     253                   
    259254    if (dbtFile_r == NULL) {// mode normal
    260255      for (size_t i = 0; i < models.size(); i++) {
     
    263258    }
    264259
     260    //render to texture for axis if possible
     261    if (texture) {
     262      cameras.at(cam_id)->renderAxisToTexture(texture);
     263    }
     264   
     265    //process update for sensors (cam, us...)
     266    //also draws embedded cameras (see SimuCameraGL::UpdateFrom)
    265267    for (size_t i = 0; i < models.size(); i++) {
    266268      models.at(i)->ProcessUpdate(NULL);
    267269    }
    268 
     270   
    269271    // on fait ca ici, devrait etre un peu plus haut
    270272    // mais a priori souci avec models.at(i)->pimpl_->CheckCollision();
     
    274276    driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height));
    275277    smgr->drawAll();
    276 
     278   
     279    driver->setViewPort(core::rect<s32>(0, 0, smgr->getVideoDriver()->getScreenSize().Width, smgr->getVideoDriver()->getScreenSize().Height));
     280    if(font) {
     281      font->draw(L"VRPN:",rect<s32>(10,scene_height-30,100,50),SColor(128,255,255,255));
     282      font->draw(L"X",rect<s32>(60,scene_height-30,100,50),SColor(255,255,0,0));
     283      font->draw(L"Y",rect<s32>(70,scene_height-30,100,50),SColor(255,0,255,0));
     284      font->draw(L"Z",rect<s32>(80,scene_height-30,100,50),SColor(255,0,0,255));
     285     
     286    }
     287    device->getGUIEnvironment()->drawAll();
    277288    driver->endScene();
    278 
     289   
    279290    int fps = driver->getFPS();
    280291
Note: See TracChangeset for help on using the changeset viewer.