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


Ignore:
Timestamp:
09/06/16 17:49:32 (6 years ago)
Author:
Sanahuja Guillaume
Message:

simu cameras

File:
1 edited

Legend:

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

    r69 r70  
    9898  smgr->setAmbientLight(video::SColorf(1, 1, 1));
    9999
    100 /*
    101    // camera
    102   camera = smgr->addCameraSceneNode();
    103 
    104   camera->setAspectRatio(
    105       (float)scene_width / (float)scene_height); // on force a cause du view port
    106 
    107   camera->setUpVector(vector3df(0, 0, 1));
    108 
    109   FixedCamera* animator = new FixedCamera(vector3df(1,1,1));
    110   camera->addAnimator(animator);
    111 
    112   camera->setFarValue(8000);*/
    113100  /*
    114101env = device->getGUIEnvironment();
     
    146133  delete receiver;
    147134  // printf("del Gui_impl ok\n");
     135}
     136
     137void Gui_impl::AddVisualizationCamera(VisualizationCamera* camera) {
     138  cameras.push_back(camera);
    148139}
    149140
     
    187178  int cam_id = 0;
    188179
    189   receiver->SetModel(models.at(cam_id));
     180  receiver->SetModel(models.at(0));
    190181
    191182  for (size_t i = 0; i < models.size(); i++) {
     
    213204  }
    214205
    215   setWindowCaption(models.at(0), 0);
     206  setWindowCaption(0, 0);
    216207
    217208  while (device->run()) {
     
    247238
    248239    // vue poursuite
    249     smgr->setActiveCamera(models.at(cam_id)->getFollowMeCamera()->getCameraSceneNode());
     240    //smgr->setActiveCamera(models.at(cam_id)->getFollowMeCamera()->getCameraSceneNode());
     241    smgr->setActiveCamera(cameras.at(cam_id)->getCameraSceneNode());
    250242    driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height));
    251243    smgr->drawAll(); // commente voir plus bas
     
    279271    // mais a priori souci avec models.at(i)->pimpl_->CheckCollision();
    280272    // (setelipsoid?)
    281     smgr->setActiveCamera(models.at(cam_id)->getFollowMeCamera()->getCameraSceneNode());
     273    //smgr->setActiveCamera(models.at(cam_id)->getFollowMeCamera()->getCameraSceneNode());
     274    smgr->setActiveCamera(cameras.at(cam_id)->getCameraSceneNode());
    282275    driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height));
    283276    smgr->drawAll();
     
    286279
    287280    int fps = driver->getFPS();
    288     // printf("fps %i\n",fps);
     281
    289282    if (lastFPS != fps) {
    290       setWindowCaption(models.at(cam_id), fps);
     283      setWindowCaption(cam_id, fps);
    291284      lastFPS = fps;
    292285    }
     
    294287    if (receiver->IsKeyDown(KEY_PRIOR)) {
    295288      cam_id++;
    296       if (cam_id >= (int)models.size()) cam_id = 0;
    297       receiver->SetModel(models.at(cam_id));
    298       setWindowCaption(models.at(cam_id), fps);
     289      if (cam_id >= (int)cameras.size()) cam_id = 0;
     290      receiver->SetModel(getModelFromVisualizationCamera(models,cameras.at(cam_id)));
     291      setWindowCaption(cam_id, fps);
    299292    }
    300293    if (receiver->IsKeyDown(KEY_NEXT)) {
    301294      cam_id--;
    302       if (cam_id < 0) cam_id = models.size() - 1;
    303       receiver->SetModel(models.at(cam_id));
    304       setWindowCaption(models.at(cam_id), fps);
     295      if (cam_id < 0) cam_id = cameras.size() - 1;
     296      receiver->SetModel(getModelFromVisualizationCamera(models,cameras.at(cam_id)));
     297      setWindowCaption(cam_id, fps);
    305298    }
    306299
     
    354347}
    355348
    356 void Gui_impl::setWindowCaption(Object *object, int fps) {
     349Model *Gui_impl::getModelFromVisualizationCamera(std::vector<Model *> models,VisualizationCamera *camera) {
     350  for (size_t i = 0; i < models.size(); i++) {
     351      if(models.at(i)->getFollowMeCamera()==camera) return models.at(i);
     352  }
     353  return NULL;
     354}
     355
     356void Gui_impl::setWindowCaption(int cam_id, int fps) {
    357357  std::ostringstream text;
    358   text << "Cam: " << object->ObjectName().c_str()
    359        << ", Kbd: " << object->ObjectName().c_str() << ", FPS: " << fps;
     358
     359  text << "Cam: " << cameras.at(cam_id)->getName().c_str()
     360     << ", FPS: " << fps;
    360361
    361362  device->setWindowCaption(stringw(text.str().c_str()).c_str());
Note: See TracChangeset for help on using the changeset viewer.