Changeset 6914
- Timestamp:
- May 17, 2010, 3:41:40 PM (15 years ago)
- Location:
- code/branches/hudelements/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.cc
r6907 r6914 100 100 { 101 101 activeObjectListType::iterator it; 102 for( it = activeObjectList_.begin(); it!=activeObjectList_.end(); )102 for( it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it ) 103 103 { 104 removeObject( (it++)->first);104 removeObject(it->first); 105 105 } 106 106 activeObjectList_.clear(); … … 124 124 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 125 125 { 126 if (tempRadarViewable->second. second&& !fontName_.empty())127 tempRadarViewable->second. second->setFontName(fontName_);126 if (tempRadarViewable->second.text_ && !fontName_.empty()) 127 tempRadarViewable->second.text_->setFontName(fontName_); 128 128 } 129 129 } … … 142 142 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 143 143 { 144 if (tempRadarViewable->second. second&& size >= 0.0f)145 tempRadarViewable->second. second->setCharHeight(size);144 if (tempRadarViewable->second.text_ && size >= 0.0f) 145 tempRadarViewable->second.text_->setCharHeight(size); 146 146 } 147 147 } … … 185 185 //get Distance to HumanController and save it in the TextAreaOverlayElement. 186 186 int dist = (int)(tempRadarViewable->first->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 187 tempRadarViewable->second. second->setCaption(multi_cast<std::string>(dist));188 float textLength = multi_cast<std::string>(dist).size() * tempRadarViewable->second. second->getCharHeight() * 0.3f;187 tempRadarViewable->second.text_->setCaption(multi_cast<std::string>(dist)); 188 float textLength = multi_cast<std::string>(dist).size() * tempRadarViewable->second.text_->getCharHeight() * 0.3f; 189 189 190 190 … … 199 199 200 200 201 bool outOfView; 201 202 202 if (pos.z > 1.0) 203 203 { 204 204 // z > 1.0 means that the object is behind the camera 205 outOfView= true;205 tempRadarViewable->second.outOfView_ = true; 206 206 // we have to switch all coordinates (if you don't know why, 207 207 // try linear algebra lectures, because I can't explain..) … … 210 210 } 211 211 else 212 outOfView= pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;213 214 if ( outOfView)212 tempRadarViewable->second.outOfView_ = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 213 214 if (tempRadarViewable->second.outOfView_) 215 215 { 216 216 // object is not in view 217 217 // aimMarker_->hide(); 218 218 219 if (! wasOutOfView_)219 if (!tempRadarViewable->second.wasOutOfView__) 220 220 { 221 tempRadarViewable->second. first->setMaterialName("Orxonox/NavArrows");222 wasOutOfView_ = true;221 tempRadarViewable->second.panel_->setMaterialName("Orxonox/NavArrows"); 222 tempRadarViewable->second.wasOutOfView__ = true; 223 223 } 224 224 … … 231 231 // up 232 232 float position = pos.x / pos.y + 1.0f; 233 tempRadarViewable->second. first->setPosition((position - tempRadarViewable->second.first->getWidth()) * 0.5f, 0.0f);234 tempRadarViewable->second. first->setUV(0.5f, 0.0f, 1.0f, 0.5f);235 tempRadarViewable->second. second->setLeft((position - textLength) * 0.5f);236 tempRadarViewable->second. second->setTop(tempRadarViewable->second.first->getHeight());233 tempRadarViewable->second.panel_->setPosition((position - tempRadarViewable->second.panel_->getWidth()) * 0.5f, 0.0f); 234 tempRadarViewable->second.panel_->setUV(0.5f, 0.0f, 1.0f, 0.5f); 235 tempRadarViewable->second.text_->setLeft((position - textLength) * 0.5f); 236 tempRadarViewable->second.text_->setTop(tempRadarViewable->second.panel_->getHeight()); 237 237 } 238 238 else … … 240 240 // left 241 241 float position = pos.y / pos.x + 1.0f; 242 tempRadarViewable->second. first->setPosition(0.0f, (position - tempRadarViewable->second.first->getWidth()) * 0.5f);243 tempRadarViewable->second. first->setUV(0.0f, 0.0f, 0.5f, 0.5f);244 tempRadarViewable->second. second->setLeft(tempRadarViewable->second.first->getWidth() + 0.01f);245 tempRadarViewable->second. second->setTop((position - tempRadarViewable->second.second->getCharHeight()) * 0.5f);242 tempRadarViewable->second.panel_->setPosition(0.0f, (position - tempRadarViewable->second.panel_->getWidth()) * 0.5f); 243 tempRadarViewable->second.panel_->setUV(0.0f, 0.0f, 0.5f, 0.5f); 244 tempRadarViewable->second.text_->setLeft(tempRadarViewable->second.panel_->getWidth() + 0.01f); 245 tempRadarViewable->second.text_->setTop((position - tempRadarViewable->second.text_->getCharHeight()) * 0.5f); 246 246 } 247 247 } … … 253 253 // down 254 254 float position = -pos.x / pos.y + 1.0f; 255 tempRadarViewable->second. first->setPosition((position - tempRadarViewable->second.first->getWidth()) * 0.5f, 1.0f - tempRadarViewable->second.first->getHeight());256 tempRadarViewable->second. first->setUV(0.0f, 0.5f, 0.5f, 1.0f);257 tempRadarViewable->second. second->setLeft((position - textLength) * 0.5f);258 tempRadarViewable->second. second->setTop(1.0f - tempRadarViewable->second.first->getHeight() - tempRadarViewable->second.second->getCharHeight());255 tempRadarViewable->second.panel_->setPosition((position - tempRadarViewable->second.panel_->getWidth()) * 0.5f, 1.0f - tempRadarViewable->second.panel_->getHeight()); 256 tempRadarViewable->second.panel_->setUV(0.0f, 0.5f, 0.5f, 1.0f); 257 tempRadarViewable->second.text_->setLeft((position - textLength) * 0.5f); 258 tempRadarViewable->second.text_->setTop(1.0f - tempRadarViewable->second.panel_->getHeight() - tempRadarViewable->second.text_->getCharHeight()); 259 259 } 260 260 else … … 262 262 // right 263 263 float position = -pos.y / pos.x + 1.0f; 264 tempRadarViewable->second. first->setPosition(1.0f - tempRadarViewable->second.first->getWidth(), (position - tempRadarViewable->second.first->getHeight()) * 0.5f);265 tempRadarViewable->second. first->setUV(0.5f, 0.5f, 1.0f, 1.0f);266 tempRadarViewable->second. second->setLeft(1.0f - tempRadarViewable->second.first->getWidth() - textLength - 0.01f);267 tempRadarViewable->second. second->setTop((position - tempRadarViewable->second.second->getCharHeight()) * 0.5f);264 tempRadarViewable->second.panel_->setPosition(1.0f - tempRadarViewable->second.panel_->getWidth(), (position - tempRadarViewable->second.panel_->getHeight()) * 0.5f); 265 tempRadarViewable->second.panel_->setUV(0.5f, 0.5f, 1.0f, 1.0f); 266 tempRadarViewable->second.text_->setLeft(1.0f - tempRadarViewable->second.panel_->getWidth() - textLength - 0.01f); 267 tempRadarViewable->second.text_->setTop((position - tempRadarViewable->second.text_->getCharHeight()) * 0.5f); 268 268 } 269 269 } … … 278 278 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 279 279 */ 280 if ( wasOutOfView_)280 if (tempRadarViewable->second.wasOutOfView_) 281 281 { 282 tempRadarViewable->second. first->setMaterialName("Orxonox/NavTDC");283 wasOutOfView_ = false;282 tempRadarViewable->second.panel_->setMaterialName("Orxonox/NavTDC"); 283 tempRadarViewable->second.wasOutOfView__ = false; 284 284 } 285 285 286 286 // object is in view 287 tempRadarViewable->second. first->setUV(0.0f, 0.0f, 1.0f, 1.0f);288 tempRadarViewable->second. first->setLeft((pos.x + 1.0f - tempRadarViewable->second.first->getWidth()) * 0.5f);289 tempRadarViewable->second. first->setTop((-pos.y + 1.0f - tempRadarViewable->second.first->getHeight()) * 0.5f);287 tempRadarViewable->second.panel_->setUV(0.0f, 0.0f, 1.0f, 1.0f); 288 tempRadarViewable->second.panel_->setLeft((pos.x + 1.0f - tempRadarViewable->second.panel_->getWidth()) * 0.5f); 289 tempRadarViewable->second.panel_->setTop((-pos.y + 1.0f - tempRadarViewable->second.panel_->getHeight()) * 0.5f); 290 290 291 291 … … 294 294 // aimMarker_->setTop((-aimpos.y + 1.0f - aimMarker_->getHeight()) * 0.5f); 295 295 // 296 tempRadarViewable->second. second->setLeft((pos.x + 1.0f + tempRadarViewable->second.first->getWidth()) * 0.5f);297 tempRadarViewable->second. second->setTop((-pos.y + 1.0f + tempRadarViewable->second.first->getHeight()) * 0.5f);296 tempRadarViewable->second.text_->setLeft((pos.x + 1.0f + tempRadarViewable->second.panel_->getWidth()) * 0.5f); 297 tempRadarViewable->second.text_->setTop((-pos.y + 1.0f + tempRadarViewable->second.panel_->getHeight()) * 0.5f); 298 298 } 299 299 300 tempRadarViewable->second. first->show();301 tempRadarViewable->second. second->show();302 // tempRadarViewable->second. second->hide();300 tempRadarViewable->second.panel_->show(); 301 tempRadarViewable->second.text_->show(); 302 // tempRadarViewable->second.text_->hide(); 303 303 } 304 304 … … 332 332 { 333 333 334 if (tempRadarViewable->second. first)335 tempRadarViewable->second. first->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);334 if (tempRadarViewable->second.panel_) 335 tempRadarViewable->second.panel_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 336 336 // if (this->aimMarker_) 337 337 // aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale); 338 if (tempRadarViewable->second. second)339 tempRadarViewable->second. second->setCharHeight(tempRadarViewable->second.second->getCharHeight() * yScale);338 if (tempRadarViewable->second.text_) 339 tempRadarViewable->second.text_->setCharHeight(tempRadarViewable->second.text_->getCharHeight() * yScale); 340 340 } 341 341 } … … 371 371 text->setCharHeight(text->getCharHeight() * yScale); 372 372 373 activeObjectList_[object] = std::make_pair (panel, text) ; 373 objectStruct tempStruct = {panel, text, true}; 374 activeObjectList_[object] = tempStruct; 374 375 375 376 this->background_->addChild(panel); … … 388 389 { 389 390 // Remove overlays from Ogre 390 this->background_->removeChild(it->second. first->getName());391 this->background_->removeChild(it->second. second->getName());391 this->background_->removeChild(it->second.panel_->getName()); 392 this->background_->removeChild(it->second.text_->getName()); 392 393 // correctly destroy the overlay elements 393 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second. first);394 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second. second);394 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_); 395 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_); 395 396 396 397 activeObjectList_.erase(viewable); -
code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.h
r6899 r6914 108 108 */ 109 109 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 110 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap110 111 111 112 typedef std::map<RadarViewable*, std::pair<Ogre::PanelOverlayElement*, Ogre::TextAreaOverlayElement*> > activeObjectListType; 112 struct objectStruct{ 113 114 Ogre::PanelOverlayElement* panel_; 115 Ogre::TextAreaOverlayElement text_; 116 bool outOfView_; 117 bool wasOutOfView_; 118 119 }; 120 121 typedef std::map<RadarViewable*, objectStruct > activeObjectListType; 113 122 activeObjectListType activeObjectList_; 114 123 activeObjectListType::iterator tempRadarViewable;
Note: See TracChangeset
for help on using the changeset viewer.