Changeset 70 in flair-src for trunk/lib/FlairSimulator/src/Gui_impl.cpp
- Timestamp:
- 09/06/16 17:49:32 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSimulator/src/Gui_impl.cpp
r69 r70 98 98 smgr->setAmbientLight(video::SColorf(1, 1, 1)); 99 99 100 /*101 // camera102 camera = smgr->addCameraSceneNode();103 104 camera->setAspectRatio(105 (float)scene_width / (float)scene_height); // on force a cause du view port106 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);*/113 100 /* 114 101 env = device->getGUIEnvironment(); … … 146 133 delete receiver; 147 134 // printf("del Gui_impl ok\n"); 135 } 136 137 void Gui_impl::AddVisualizationCamera(VisualizationCamera* camera) { 138 cameras.push_back(camera); 148 139 } 149 140 … … 187 178 int cam_id = 0; 188 179 189 receiver->SetModel(models.at( cam_id));180 receiver->SetModel(models.at(0)); 190 181 191 182 for (size_t i = 0; i < models.size(); i++) { … … 213 204 } 214 205 215 setWindowCaption( models.at(0), 0);206 setWindowCaption(0, 0); 216 207 217 208 while (device->run()) { … … 247 238 248 239 // 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()); 250 242 driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height)); 251 243 smgr->drawAll(); // commente voir plus bas … … 279 271 // mais a priori souci avec models.at(i)->pimpl_->CheckCollision(); 280 272 // (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()); 282 275 driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height)); 283 276 smgr->drawAll(); … … 286 279 287 280 int fps = driver->getFPS(); 288 // printf("fps %i\n",fps); 281 289 282 if (lastFPS != fps) { 290 setWindowCaption( models.at(cam_id), fps);283 setWindowCaption(cam_id, fps); 291 284 lastFPS = fps; 292 285 } … … 294 287 if (receiver->IsKeyDown(KEY_PRIOR)) { 295 288 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); 299 292 } 300 293 if (receiver->IsKeyDown(KEY_NEXT)) { 301 294 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); 305 298 } 306 299 … … 354 347 } 355 348 356 void Gui_impl::setWindowCaption(Object *object, int fps) { 349 Model *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 356 void Gui_impl::setWindowCaption(int cam_id, int fps) { 357 357 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; 360 361 361 362 device->setWindowCaption(stringw(text.str().c_str()).c_str());
Note:
See TracChangeset
for help on using the changeset viewer.