Changeset 6874 for code/branches
- Timestamp:
- May 10, 2010, 2:55:46 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
r6873 r6874 49 49 namespace orxonox 50 50 { 51 52 53 51 CreateFactory(HUDNavigation); 52 53 HUDNavigation::HUDNavigation(BaseObject* creator) 54 54 : OrxonoxOverlay(creator) 55 56 57 55 { 56 RegisterObject(HUDNavigation); 57 58 58 // // create nav text 59 59 // navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 60 60 // .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 61 // 61 // 62 62 // // create nav marker 63 63 // navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() … … 65 65 // navMarker_->setMaterialName("Orxonox/NavArrows"); 66 66 67 /*68 // create aim marker69 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()70 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));71 aimMarker_->setMaterialName("Orxonox/NavCrosshair");72 this->wasOutOfView_ = true; // Ensure the material is changed right the first time..73 74 75 */76 /*77 background_->addChild(navMarker_);*/67 /* 68 // create aim marker 69 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 70 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString())); 71 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 72 this->wasOutOfView_ = true; // Ensure the material is changed right the first time.. 73 74 75 */ 76 /* 77 background_->addChild(navMarker_);*/ 78 78 // background_->addChild(aimMarker_); 79 79 // background_->addChild(navText_); 80 80 81 81 // hide at first 82 82 // this->setVisible(false); 83 84 85 86 87 83 84 85 setFont("Monofur"); 86 setTextSize(0.05f); 87 setNavMarkerSize(0.05f); 88 88 // setAimMarkerSize(0.04f); 89 } 90 91 HUDNavigation::~HUDNavigation() 89 } 90 91 HUDNavigation::~HUDNavigation() 92 { 93 94 if (this->isInitialized()) 92 95 { 93 94 if (this->isInitialized()) 95 { 96 if(!activeObjectList_.empty()) 97 { 98 for(tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 99 { 100 Ogre::OverlayManager::getSingleton().destroyOverlayElement(tempRadarViewable->second.first); 101 Ogre::OverlayManager::getSingleton().destroyOverlayElement(tempRadarViewable->second.second); 96 if (!activeObjectList_.empty()) 97 { 98 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 99 { 100 Ogre::OverlayManager::getSingleton().destroyOverlayElement(tempRadarViewable->second.first); 101 Ogre::OverlayManager::getSingleton().destroyOverlayElement(tempRadarViewable->second.second); 102 102 // Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 103 } 104 } 105 } 106 } 107 108 void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode) 103 } 104 } 105 } 106 } 107 108 void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode) 109 { 110 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 111 112 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 113 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 114 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 115 // XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 116 } 117 118 void HUDNavigation::setFont(const std::string& font) 119 { 120 fontName_ = font; 121 if (!activeObjectList_.empty()) 109 122 { 110 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 111 112 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 113 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 114 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 115 // XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 116 } 117 118 void HUDNavigation::setFont(const std::string& font) 123 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 124 { 125 if (tempRadarViewable->second.second && !fontName_.empty()) 126 tempRadarViewable->second.second->setFontName(fontName_); 127 } 128 } 129 } 130 131 const std::string& HUDNavigation::getFont() const 132 { 133 return fontName_; 134 } 135 136 void HUDNavigation::setTextSize(float size) 137 { 138 textSize_ = size; 139 if (!activeObjectList_.empty()) 119 140 { 120 fontName_ = font; 121 if(!activeObjectList_.empty()) 122 { 123 for(tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 124 { 125 if (tempRadarViewable->second.second && !fontName_.empty()) 126 tempRadarViewable->second.second->setFontName(fontName_); 127 } 128 } 129 } 130 131 const std::string& HUDNavigation::getFont() const 132 { 133 return fontName_; 134 } 135 136 void HUDNavigation::setTextSize(float size) 137 { 138 textSize_ = size; 139 if(!activeObjectList_.empty()) 140 { 141 for(tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 142 { 143 if (tempRadarViewable->second.second && size >= 0.0f) 144 tempRadarViewable->second.second->setCharHeight(size); 145 } 146 } 147 } 148 149 float HUDNavigation::getTextSize() const 150 { 151 return textSize_; 152 } 153 154 void HUDNavigation::tick(float dt) 155 { 156 SUPER(HUDNavigation, tick, dt); 157 141 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 142 { 143 if (tempRadarViewable->second.second && size >= 0.0f) 144 tempRadarViewable->second.second->setCharHeight(size); 145 } 146 } 147 } 148 149 float HUDNavigation::getTextSize() const 150 { 151 return textSize_; 152 } 153 154 void HUDNavigation::tick(float dt) 155 { 156 SUPER(HUDNavigation, tick, dt); 157 158 158 // updateActiveObjectList(activeObjectList_); 159 159 160 160 // Get radar 161 161 // Radar* radar = this->getOwner()->getScene()->getRadar(); 162 // 162 // 163 163 // if (!radar->getFocus()) 164 164 // { … … 171 171 // } 172 172 173 173 // set text 174 174 // int dist = static_cast<int>(getDist2Focus()); 175 175 // navText_->setCaption(multi_cast<std::string>(dist)); 176 176 // float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3f; 177 177 178 if(!activeObjectList_.empty()) {179 for(tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable)180 181 182 183 184 185 186 187 188 189 190 191 if (!cam)192 return;193 const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();194 // transform to screen coordinates195 Vector3 pos = transform * tempRadarViewable->first->getRVWorldPosition();196 197 198 199 bool outOfView;200 if (pos.z > 1.0)201 {202 // z > 1.0 means that the object is behind the camera203 outOfView = true;204 // we have to switch all coordinates (if you don't know why,205 // try linear algebra lectures, because I can't explain..)206 pos.x = -pos.x;207 pos.y = -pos.y;208 }209 else210 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;211 212 if (outOfView)213 {214 // object is not in view178 if (!activeObjectList_.empty()) { 179 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 180 { 181 COUT(0) << "check 174" << std::endl; 182 183 //get Distance to HumanController and save it in the TextAreaOverlayElement. 184 int dist = (int)(tempRadarViewable->first->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 185 tempRadarViewable->second.second->setCaption(multi_cast<std::string>(dist)); 186 float textLength = multi_cast<std::string>(dist).size() * tempRadarViewable->second.second->getCharHeight() * 0.3f; 187 188 COUT(0) << "check 181" << std::endl; 189 190 orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera(); 191 if (!cam) 192 return; 193 const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 194 // transform to screen coordinates 195 Vector3 pos = transform * tempRadarViewable->first->getRVWorldPosition(); 196 197 COUT(0) << "check 190" << std::endl; 198 199 bool outOfView; 200 if (pos.z > 1.0) 201 { 202 // z > 1.0 means that the object is behind the camera 203 outOfView = true; 204 // we have to switch all coordinates (if you don't know why, 205 // try linear algebra lectures, because I can't explain..) 206 pos.x = -pos.x; 207 pos.y = -pos.y; 208 } 209 else 210 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 211 212 if (outOfView) 213 { 214 // object is not in view 215 215 // aimMarker_->hide(); 216 216 217 if (!wasOutOfView_) 218 { 219 tempRadarViewable->second.first->setMaterialName("Orxonox/NavArrows"); 220 wasOutOfView_ = true; 221 } 222 223 COUT(0) << "check 174" << std::endl; 224 225 if (pos.x < pos.y) 226 { 227 if (pos.y > -pos.x) 217 if (!wasOutOfView_) 228 218 { 229 // up 230 float position = pos.x / pos.y + 1.0f; 231 tempRadarViewable->second.first->setPosition((position - tempRadarViewable->second.first->getWidth()) * 0.5f, 0.0f); 232 tempRadarViewable->second.first->setUV(0.5f, 0.0f, 1.0f, 0.5f); 233 tempRadarViewable->second.second->setLeft((position - textLength) * 0.5f); 234 tempRadarViewable->second.second->setTop(tempRadarViewable->second.first->getHeight()); 219 tempRadarViewable->second.first->setMaterialName("Orxonox/NavArrows"); 220 wasOutOfView_ = true; 221 } 222 223 COUT(0) << "check 174" << std::endl; 224 225 if (pos.x < pos.y) 226 { 227 if (pos.y > -pos.x) 228 { 229 // up 230 float position = pos.x / pos.y + 1.0f; 231 tempRadarViewable->second.first->setPosition((position - tempRadarViewable->second.first->getWidth()) * 0.5f, 0.0f); 232 tempRadarViewable->second.first->setUV(0.5f, 0.0f, 1.0f, 0.5f); 233 tempRadarViewable->second.second->setLeft((position - textLength) * 0.5f); 234 tempRadarViewable->second.second->setTop(tempRadarViewable->second.first->getHeight()); 235 } 236 else 237 { 238 // left 239 float position = pos.y / pos.x + 1.0f; 240 tempRadarViewable->second.first->setPosition(0.0f, (position - tempRadarViewable->second.first->getWidth()) * 0.5f); 241 tempRadarViewable->second.first->setUV(0.0f, 0.0f, 0.5f, 0.5f); 242 tempRadarViewable->second.second->setLeft(tempRadarViewable->second.first->getWidth() + 0.01f); 243 tempRadarViewable->second.second->setTop((position - tempRadarViewable->second.second->getCharHeight()) * 0.5f); 244 } 235 245 } 236 246 else 237 247 { 238 // left 239 float position = pos.y / pos.x + 1.0f; 240 tempRadarViewable->second.first->setPosition(0.0f, (position - tempRadarViewable->second.first->getWidth()) * 0.5f); 241 tempRadarViewable->second.first->setUV(0.0f, 0.0f, 0.5f, 0.5f); 242 tempRadarViewable->second.second->setLeft(tempRadarViewable->second.first->getWidth() + 0.01f); 243 tempRadarViewable->second.second->setTop((position - tempRadarViewable->second.second->getCharHeight()) * 0.5f); 248 COUT(0) << "check 241" << std::endl; 249 if (pos.y < -pos.x) 250 { 251 // down 252 float position = -pos.x / pos.y + 1.0f; 253 tempRadarViewable->second.first->setPosition((position - tempRadarViewable->second.first->getWidth()) * 0.5f, 1.0f - navMarker_->getHeight()); 254 tempRadarViewable->second.first->setUV(0.0f, 0.5f, 0.5f, 1.0f); 255 tempRadarViewable->second.second->setLeft((position - textLength) * 0.5f); 256 tempRadarViewable->second.second->setTop(1.0f - tempRadarViewable->second.first->getHeight() - tempRadarViewable->second.second->getCharHeight()); 257 } 258 else 259 { 260 // right 261 float position = -pos.y / pos.x + 1.0f; 262 tempRadarViewable->second.first->setPosition(1.0f - tempRadarViewable->second.first->getWidth(), (position - tempRadarViewable->second.first->getHeight()) * 0.5f); 263 tempRadarViewable->second.first->setUV(0.5f, 0.5f, 1.0f, 1.0f); 264 tempRadarViewable->second.second->setLeft(1.0f - tempRadarViewable->second.first->getWidth() - textLength - 0.01f); 265 tempRadarViewable->second.second->setTop((position - tempRadarViewable->second.second->getCharHeight()) * 0.5f); 266 } 244 267 } 245 268 } 246 269 else 247 270 { 248 COUT(0) << "check 241" << std::endl; 249 if (pos.y < -pos.x) 271 COUT(0) << "check 264" << std::endl; 272 273 // object is in view 274 /* 275 Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 276 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 277 */ 278 if (wasOutOfView_) 250 279 { 251 // down 252 float position = -pos.x / pos.y + 1.0f; 253 tempRadarViewable->second.first->setPosition((position - tempRadarViewable->second.first->getWidth()) * 0.5f, 1.0f - navMarker_->getHeight()); 254 tempRadarViewable->second.first->setUV(0.0f, 0.5f, 0.5f, 1.0f); 255 tempRadarViewable->second.second->setLeft((position - textLength) * 0.5f); 256 tempRadarViewable->second.second->setTop(1.0f - tempRadarViewable->second.first->getHeight() - tempRadarViewable->second.second->getCharHeight()); 280 tempRadarViewable->second.first->setMaterialName("Orxonox/NavTDC"); 281 wasOutOfView_ = false; 257 282 } 258 else 259 { 260 // right 261 float position = -pos.y / pos.x + 1.0f; 262 tempRadarViewable->second.first->setPosition(1.0f - tempRadarViewable->second.first->getWidth(), (position - tempRadarViewable->second.first->getHeight()) * 0.5f); 263 tempRadarViewable->second.first->setUV(0.5f, 0.5f, 1.0f, 1.0f); 264 tempRadarViewable->second.second->setLeft(1.0f - tempRadarViewable->second.first->getWidth() - textLength - 0.01f); 265 tempRadarViewable->second.second->setTop((position - tempRadarViewable->second.second->getCharHeight()) * 0.5f); 266 } 283 284 // object is in view 285 tempRadarViewable->second.first->setUV(0.0f, 0.0f, 1.0f, 1.0f); 286 tempRadarViewable->second.first->setLeft((pos.x + 1.0f - tempRadarViewable->second.first->getWidth()) * 0.5f); 287 tempRadarViewable->second.first->setTop((-pos.y + 1.0f - tempRadarViewable->second.first->getHeight()) * 0.5f); 288 289 /* 290 aimMarker_->show(); 291 aimMarker_->setLeft((aimpos.x + 1.0f - aimMarker_->getWidth()) * 0.5f); 292 aimMarker_->setTop((-aimpos.y + 1.0f - aimMarker_->getHeight()) * 0.5f); 293 */ 294 tempRadarViewable->second.second->setLeft((pos.x + 1.0f + tempRadarViewable->second.first->getWidth()) * 0.5f); 295 tempRadarViewable->second.second->setTop((-pos.y + 1.0f + tempRadarViewable->second.first->getHeight()) * 0.5f); 267 296 } 268 297 } 269 else 270 { 271 COUT(0) << "check 264" << std::endl; 272 273 // object is in view 274 /* 275 Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 276 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 298 tempRadarViewable->second.first->show(); 299 tempRadarViewable->second.second->show(); 300 } 301 302 } 303 304 305 float HUDNavigation::getDist2Focus() const { 306 307 Radar* radar = this->getOwner()->getScene()->getRadar(); 308 if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn()) 309 return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 310 else 311 return 0; 312 } 313 314 /** 315 @brief Overridden method of OrxonoxOverlay. Usually the entire overlay 316 scales with scale(). Here we obviously have to adjust this. 277 317 */ 278 if (wasOutOfView_) 279 { 280 tempRadarViewable->second.first->setMaterialName("Orxonox/NavTDC"); 281 wasOutOfView_ = false; 282 } 283 284 // object is in view 285 tempRadarViewable->second.first->setUV(0.0f, 0.0f, 1.0f, 1.0f); 286 tempRadarViewable->second.first->setLeft((pos.x + 1.0f - tempRadarViewable->second.first->getWidth()) * 0.5f); 287 tempRadarViewable->second.first->setTop((-pos.y + 1.0f - tempRadarViewable->second.first->getHeight()) * 0.5f); 288 289 /* 290 aimMarker_->show(); 291 aimMarker_->setLeft((aimpos.x + 1.0f - aimMarker_->getWidth()) * 0.5f); 292 aimMarker_->setTop((-aimpos.y + 1.0f - aimMarker_->getHeight()) * 0.5f); 293 */ 294 tempRadarViewable->second.second->setLeft((pos.x + 1.0f + tempRadarViewable->second.first->getWidth()) * 0.5f); 295 tempRadarViewable->second.second->setTop((-pos.y + 1.0f + tempRadarViewable->second.first->getHeight()) * 0.5f); 296 } 297 } 298 } 299 } 300 301 302 float HUDNavigation::getDist2Focus() const{ 303 304 Radar* radar = this->getOwner()->getScene()->getRadar(); 305 if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn()) 306 return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 307 else 308 return 0; 309 } 310 311 /** 312 @brief Overridden method of OrxonoxOverlay. Usually the entire overlay 313 scales with scale(). Here we obviously have to adjust this. 314 */ 315 void HUDNavigation::sizeChanged(){ 316 // use size to compensate for aspect ratio if enabled. 317 float xScale = this->getActualSize().x; 318 float yScale = this->getActualSize().y; 319 320 if(!activeObjectList_.empty()) 321 { 322 for(tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 323 { 324 325 if (tempRadarViewable->second.first) 326 tempRadarViewable->second.first->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 318 void HUDNavigation::sizeChanged() { 319 // use size to compensate for aspect ratio if enabled. 320 float xScale = this->getActualSize().x; 321 float yScale = this->getActualSize().y; 322 323 if (!activeObjectList_.empty()) 324 { 325 for (tempRadarViewable = activeObjectList_.begin(); tempRadarViewable!=activeObjectList_.end(); ++tempRadarViewable) 326 { 327 328 if (tempRadarViewable->second.first) 329 tempRadarViewable->second.first->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 327 330 // if (this->aimMarker_) 328 331 // aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale); 329 if (tempRadarViewable->second.second) 330 tempRadarViewable->second.second->setCharHeight(tempRadarViewable->second.second->getCharHeight() * yScale); 331 } 332 } 333 } 332 if (tempRadarViewable->second.second) 333 tempRadarViewable->second.second->setCharHeight(tempRadarViewable->second.second->getCharHeight() * yScale); 334 } 335 } 336 } 337 338 339 void HUDNavigation::addObject(RadarViewable* object) { 340 if (object == dynamic_cast<RadarViewable*>(this->getOwner())) 341 return; 342 343 assert(object); 344 345 // Make sure the object hasn't been added yet 346 assert( this->activeObjectList_.find(object) == this->activeObjectList_.end() ); 347 348 // Create everything needed to display the object on the radar and add it to the map 349 350 // create nav marker 351 Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 352 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 353 354 panel->setMaterialName("Orxonox/NavArrows"); 355 356 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 357 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 358 334 359 335 336 void HUDNavigation::addObject(RadarViewable* object){ 337 if (object == dynamic_cast<RadarViewable*>(this->getOwner())) 338 return; 339 340 assert(object); 341 342 // Make sure the object hasn't been added yet 343 assert( this->activeObjectList_.find(object) == this->activeObjectList_.end() ); 344 345 // Create everything needed to display the object on the radar and add it to the map 346 347 // create nav marker 348 Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 349 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 350 351 panel->setMaterialName("Orxonox/NavArrows"); 352 353 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 354 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 355 356 int dist = (int)(object->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 357 activeObjectList_[object].second->setCaption(multi_cast<std::string>(dist)); 358 359 activeObjectList_[object] = std::make_pair (panel, text) ; 360 activeObjectList_[object].first->show(); 361 activeObjectList_[object].second->show(); 360 361 activeObjectList_[object] = std::make_pair (panel, text) ; 362 362 363 // background_->addChild(activeObjectList_[object].first); 363 364 // background_->addChild(activeObjectList_[object].second); 364 365 366 367 void HUDNavigation::removeObject(RadarViewable* viewable){368 369 370 365 COUT(0) << "check 357" << std::endl; 366 } 367 368 void HUDNavigation::removeObject(RadarViewable* viewable) { 369 assert(activeObjectList_.find(viewable)!=activeObjectList_.end()); 370 activeObjectList_.erase(viewable); 371 } 371 372 372 373 // void updateActiveObjectList(map activeObjectList_){} 373 // 374 // 374 375 // void HUDNavigation::objectChanged(RadarViewable* viewable){} 375 // 376 // 376 // 377 // 377 378 // float HUDNavigation::getRadarSensitivity(){} 378 379 // void HUDNavigation::radarTick(float dt){} 379 380 381 } 382 383 380 381 382 } 383 384 -
code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.h
r6873 r6874 43 43 namespace orxonox 44 44 { 45 46 47 48 49 45 class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener 46 { 47 public: 48 HUDNavigation(BaseObject* creator); 49 virtual ~HUDNavigation(); 50 50 51 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 52 virtual void tick(float dt); 53 virtual void addObject(RadarViewable* object); 54 55 virtual void removeObject(RadarViewable* viewable); 56 virtual void objectChanged(RadarViewable* viewable){} 57 inline float getRadarSensitivity() const{} 58 inline void radarTick(float dt) {} 59 51 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 52 virtual void tick(float dt); 53 virtual void addObject(RadarViewable* object); 60 54 61 private: 55 virtual void removeObject(RadarViewable* viewable); 56 virtual void objectChanged(RadarViewable* viewable) {} 57 inline float getRadarSensitivity() const {return 1.0f;} 58 inline void radarTick(float dt) {} 62 59 63 64 65 void sizeChanged(); 66 void angleChanged() { } 67 void positionChanged() { } 68 60 61 private: 62 63 64 65 void sizeChanged(); 66 void angleChanged() { } 67 void positionChanged() { } 68 69 69 // void updateActiveObjectList(map activeObjectList_); 70 71 72 70 73 // XMLPort accessors74 void setNavMarkerSize(float size) { navMarkerSize_ = size;75 this->sizeChanged(); }76 float getNavMarkerSize() const { return navMarkerSize_; }77 71 78 /*79 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); }80 float getAimMarkerSize() const { return this->aimMarkerSize_; }81 */82 72 83 void setTextSize(float size); 84 float getTextSize() const; 73 // XMLPort accessors 74 void setNavMarkerSize(float size) { 75 navMarkerSize_ = size; 76 this->sizeChanged(); 77 } 78 float getNavMarkerSize() const { 79 return navMarkerSize_; 80 } 85 81 86 void setFont(const std::string& font); 87 const std::string& getFont() const; 82 /* 83 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); } 84 float getAimMarkerSize() const { return this->aimMarkerSize_; } 85 */ 88 86 89 void updateMarker(); 90 void updateFocus(); 91 float getDist2Focus() const; 92 void getSingleton(); 87 void setTextSize(float size); 88 float getTextSize() const; 93 89 94 95 void updateActiveObjectMap(); 96 97 Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker 98 float navMarkerSize_; //!< One paramter size of the navigation marker 99 /* 100 Ogre::PanelOverlayElement* aimMarker_; //!< Panel used to show the aim Marker 101 float aimMarkerSize_; //!< One paramter size of the aim marker 102 */ 103 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 104 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap 105 106 typedef std::map<RadarViewable*, std::pair<Ogre::PanelOverlayElement*, Ogre::TextAreaOverlayElement*> > activeObjectListType; 107 activeObjectListType activeObjectList_; 108 activeObjectListType::iterator tempRadarViewable; 109 110 std::string fontName_; 111 float textSize_; 90 void setFont(const std::string& font); 91 const std::string& getFont() const; 112 92 113 }; 114 93 void updateMarker(); 94 void updateFocus(); 95 float getDist2Focus() const; 96 void getSingleton(); 97 98 99 void updateActiveObjectMap(); 100 101 Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker 102 float navMarkerSize_; //!< One paramter size of the navigation marker 103 /* 104 Ogre::PanelOverlayElement* aimMarker_; //!< Panel used to show the aim Marker 105 float aimMarkerSize_; //!< One paramter size of the aim marker 106 */ 107 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 108 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap 109 110 typedef std::map<RadarViewable*, std::pair<Ogre::PanelOverlayElement*, Ogre::TextAreaOverlayElement*> > activeObjectListType; 111 activeObjectListType activeObjectList_; 112 activeObjectListType::iterator tempRadarViewable; 113 114 std::string fontName_; 115 float textSize_; 116 117 }; 118 115 119 } 116 120
Note: See TracChangeset
for help on using the changeset viewer.