Changeset 6971 for code/branches/presentation3
- Timestamp:
- May 27, 2010, 3:58:24 PM (15 years ago)
- Location:
- code/branches/presentation3/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
r6947 r6971 47 47 #include "worldentities/WorldEntity.h" 48 48 #include "interfaces/RadarViewable.h" 49 // #include <boost/bind/bind_template.hpp> 50 49 51 50 52 namespace orxonox 51 53 { 52 CreateFactory(HUDNavigation); 53 54 HUDNavigation::HUDNavigation(BaseObject* creator) 55 : OrxonoxOverlay(creator) 56 { 57 RegisterObject(HUDNavigation); 58 59 // Set default values 60 setFont("Monofur"); 61 setTextSize(0.05f); 62 setNavMarkerSize(0.05f); 63 } 64 65 HUDNavigation::~HUDNavigation() 66 { 67 if (this->isInitialized()) 54 bool compareDistance ( std::pair<RadarViewable*, unsigned int > a, std::pair<RadarViewable*, unsigned int > b ) 55 { 56 return a.second<b.second; 57 58 } 59 CreateFactory ( HUDNavigation ); 60 61 HUDNavigation::HUDNavigation ( BaseObject* creator ) 62 : OrxonoxOverlay ( creator ) 63 { 64 RegisterObject ( HUDNavigation ); 65 66 // Set default values 67 setFont ( "Monofur" ); 68 setTextSize ( 0.05f ); 69 setNavMarkerSize ( 0.05f ); 70 } 71 72 HUDNavigation::~HUDNavigation() 73 { 74 if ( this->isInitialized() ) 75 { 76 for ( ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ) 77 removeObject ( ( it++ )->first ); 78 79 } 80 81 sortedObjectList_.clear(); 82 } 83 84 void HUDNavigation::XMLPort ( Element& xmlElement, XMLPort::Mode mode ) 85 { 86 SUPER ( HUDNavigation, XMLPort, xmlElement, mode ); 87 88 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlElement, mode ); 89 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode ); 90 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode ); 91 } 92 93 void HUDNavigation::setFont ( const std::string& font ) 94 { 95 const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName ( font ); 96 if ( fontPtr.isNull() ) 97 { 98 COUT ( 2 ) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl; 99 return; 100 } 101 fontName_ = font; 102 for ( ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it ) 103 { 104 if ( it->second.text_ != NULL ) 105 it->second.text_->setFontName ( fontName_ ); 106 } 107 } 108 109 const std::string& HUDNavigation::getFont() const 110 { 111 return fontName_; 112 } 113 114 void HUDNavigation::setTextSize ( float size ) 115 { 116 if ( size <= 0.0f ) 117 { 118 COUT ( 2 ) << "Warning: HUDNavigation: Negative font size not allowed" << std::endl; 119 return; 120 } 121 textSize_ = size; 122 for ( ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it ) 123 { 124 if ( it->second.text_ ) 125 it->second.text_->setCharHeight ( size ); 126 } 127 } 128 129 float HUDNavigation::getTextSize() const 130 { 131 return textSize_; 132 } 133 134 void HUDNavigation::tick ( float dt ) 135 { 136 SUPER ( HUDNavigation, tick, dt ); 137 138 Camera* cam = CameraManager::getInstance().getActiveCamera(); 139 if ( cam == NULL ) 140 return; 141 const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 142 143 144 //TODO: sort list 'sortedObjectList_' according to distance.$ 145 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt ) 146 { 147 listIt->second = ( int ) ( ( listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition() ).length() + 0.5f ); 148 } 149 150 sortedObjectList_.sort ( compareDistance ); 151 152 unsigned int markerCount_ = 0; 153 154 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 155 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt ) 156 { 157 ObjectMap::iterator it = activeObjectList_.find ( listIt->first ); 158 159 if ( markerCount_ < markerLimit_ ) 68 160 { 69 for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end();) 70 removeObject((it++)->first); 71 } 72 } 73 74 void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode) 75 { 76 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 77 78 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 79 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 80 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 81 } 82 83 void HUDNavigation::setFont(const std::string& font) 84 { 85 const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName(font); 86 if (fontPtr.isNull()) 87 { 88 COUT(2) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl; 89 return; 90 } 91 fontName_ = font; 92 for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 93 { 94 if (it->second.text_ != NULL) 95 it->second.text_->setFontName(fontName_); 96 } 97 } 98 99 const std::string& HUDNavigation::getFont() const 100 { 101 return fontName_; 102 } 103 104 void HUDNavigation::setTextSize(float size) 105 { 106 if (size <= 0.0f) 107 { 108 COUT(2) << "Warning: HUDNavigation: Negative font size not allowed" << std::endl; 109 return; 110 } 111 textSize_ = size; 112 for (ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it) 113 { 114 if (it->second.text_) 115 it->second.text_->setCharHeight(size); 116 } 117 } 118 119 float HUDNavigation::getTextSize() const 120 { 121 return textSize_; 122 } 123 124 void HUDNavigation::tick(float dt) 125 { 126 SUPER(HUDNavigation, tick, dt); 127 128 Camera* cam = CameraManager::getInstance().getActiveCamera(); 129 if (cam == NULL) 130 return; 131 const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 132 133 for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 134 { 161 162 135 163 // Get Distance to HumanController and save it in the TextAreaOverlayElement. 136 int dist = (int)((it->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);137 it->second.text_->setCaption (multi_cast<std::string>(dist));138 float textLength = multi_cast<std::string> (dist).size() * it->second.text_->getCharHeight() * 0.3f;164 int dist = listIt->second; 165 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); 166 float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f; 139 167 140 168 // Transform to screen coordinates … … 142 170 143 171 bool outOfView = true; 144 if ( pos.z > 1.0)172 if ( pos.z > 1.0 ) 145 173 { 146 174 // z > 1.0 means that the object is behind the camera … … 153 181 else 154 182 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 155 156 if (outOfView) 183 // Get Distance to HumanController and save it in the TextAreaOverlayElement. 184 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); 185 186 if ( outOfView ) 157 187 { 158 188 // Object is not in view 159 189 160 190 // Change material only if outOfView changed 161 if ( !it->second.wasOutOfView_)191 if ( !it->second.wasOutOfView_ ) 162 192 { 163 it->second.panel_->setMaterialName ("Orxonox/NavArrows");193 it->second.panel_->setMaterialName ( "Orxonox/NavArrows" ); 164 194 it->second.wasOutOfView_ = true; 165 195 } 166 196 167 197 // Switch between top, bottom, left and right position of the arrow at the screen border 168 if ( pos.x < pos.y)198 if ( pos.x < pos.y ) 169 199 { 170 if ( pos.y > -pos.x)200 if ( pos.y > -pos.x ) 171 201 { 172 202 // Top 173 203 float position = pos.x / pos.y + 1.0f; 174 it->second.panel_->setPosition ((position - it->second.panel_->getWidth()) * 0.5f, 0.0f);175 it->second.panel_->setUV (0.5f, 0.0f, 1.0f, 0.5f);176 it->second.text_->setLeft ((position - textLength) * 0.5f);177 it->second.text_->setTop (it->second.panel_->getHeight());204 it->second.panel_->setPosition ( ( position - it->second.panel_->getWidth() ) * 0.5f, 0.0f ); 205 it->second.panel_->setUV ( 0.5f, 0.0f, 1.0f, 0.5f ); 206 it->second.text_->setLeft ( ( position - textLength ) * 0.5f ); 207 it->second.text_->setTop ( it->second.panel_->getHeight() ); 178 208 } 179 209 else … … 181 211 // Left 182 212 float position = pos.y / pos.x + 1.0f; 183 it->second.panel_->setPosition (0.0f, (position - it->second.panel_->getWidth()) * 0.5f);184 it->second.panel_->setUV (0.0f, 0.0f, 0.5f, 0.5f);185 it->second.text_->setLeft (it->second.panel_->getWidth() + 0.01f);186 it->second.text_->setTop ((position - it->second.text_->getCharHeight()) * 0.5f);213 it->second.panel_->setPosition ( 0.0f, ( position - it->second.panel_->getWidth() ) * 0.5f ); 214 it->second.panel_->setUV ( 0.0f, 0.0f, 0.5f, 0.5f ); 215 it->second.text_->setLeft ( it->second.panel_->getWidth() + 0.01f ); 216 it->second.text_->setTop ( ( position - it->second.text_->getCharHeight() ) * 0.5f ); 187 217 } 188 218 } 219 189 220 else 190 221 { 191 222 192 if ( pos.y < -pos.x)223 if ( pos.y < -pos.x ) 193 224 { 194 225 // Bottom 195 226 float position = -pos.x / pos.y + 1.0f; 196 it->second.panel_->setPosition ((position - it->second.panel_->getWidth()) * 0.5f, 1.0f - it->second.panel_->getHeight());197 it->second.panel_->setUV (0.0f, 0.5f, 0.5f, 1.0f);198 it->second.text_->setLeft ((position - textLength) * 0.5f);199 it->second.text_->setTop (1.0f - it->second.panel_->getHeight() - it->second.text_->getCharHeight());227 it->second.panel_->setPosition ( ( position - it->second.panel_->getWidth() ) * 0.5f, 1.0f - it->second.panel_->getHeight() ); 228 it->second.panel_->setUV ( 0.0f, 0.5f, 0.5f, 1.0f ); 229 it->second.text_->setLeft ( ( position - textLength ) * 0.5f ); 230 it->second.text_->setTop ( 1.0f - it->second.panel_->getHeight() - it->second.text_->getCharHeight() ); 200 231 } 201 232 else … … 203 234 // Right 204 235 float position = -pos.y / pos.x + 1.0f; 205 it->second.panel_->setPosition (1.0f - it->second.panel_->getWidth(), (position - it->second.panel_->getHeight()) * 0.5f);206 it->second.panel_->setUV (0.5f, 0.5f, 1.0f, 1.0f);207 it->second.text_->setLeft (1.0f - it->second.panel_->getWidth() - textLength - 0.01f);208 it->second.text_->setTop ((position - it->second.text_->getCharHeight()) * 0.5f);236 it->second.panel_->setPosition ( 1.0f - it->second.panel_->getWidth(), ( position - it->second.panel_->getHeight() ) * 0.5f ); 237 it->second.panel_->setUV ( 0.5f, 0.5f, 1.0f, 1.0f ); 238 it->second.text_->setLeft ( 1.0f - it->second.panel_->getWidth() - textLength - 0.01f ); 239 it->second.text_->setTop ( ( position - it->second.text_->getCharHeight() ) * 0.5f ); 209 240 } 210 241 } … … 215 246 216 247 // Change material only if outOfView changed 217 if ( it->second.wasOutOfView_)248 if ( it->second.wasOutOfView_ ) 218 249 { 219 it->second.panel_->setMaterialName ("Orxonox/NavTDC");250 it->second.panel_->setMaterialName ( "Orxonox/NavTDC" ); 220 251 it->second.wasOutOfView_ = false; 221 252 } 222 253 223 254 // Position marker 224 it->second.panel_->setUV (0.0f, 0.0f, 1.0f, 1.0f);225 it->second.panel_->setLeft ((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);226 it->second.panel_->setTop ((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);255 it->second.panel_->setUV ( 0.0f, 0.0f, 1.0f, 1.0f ); 256 it->second.panel_->setLeft ( ( pos.x + 1.0f - it->second.panel_->getWidth() ) * 0.5f ); 257 it->second.panel_->setTop ( ( -pos.y + 1.0f - it->second.panel_->getHeight() ) * 0.5f ); 227 258 228 259 // Position text 229 it->second.text_->setLeft ((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);230 it->second.text_->setTop ((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);260 it->second.text_->setLeft ( ( pos.x + 1.0f + it->second.panel_->getWidth() ) * 0.5f ); 261 it->second.text_->setTop ( ( -pos.y + 1.0f + it->second.panel_->getHeight() ) * 0.5f ); 231 262 } 232 263 … … 235 266 it->second.text_->show(); 236 267 } 237 } 238 239 240 /** Overridden method of OrxonoxOverlay. 241 @details 242 Usually the entire overlay scales with scale(). 243 Here we obviously have to adjust this. 244 */ 245 void HUDNavigation::sizeChanged() 246 { 247 // Use size to compensate for aspect ratio if enabled. 248 float xScale = this->getActualSize().x; 249 float yScale = this->getActualSize().y; 250 251 for (ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it) 268 else 252 269 { 253 if (it->second.panel_ != NULL) 254 it->second.panel_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 255 if (it->second.text_ != NULL) 256 it->second.text_->setCharHeight(it->second.text_->getCharHeight() * yScale); 270 it->second.panel_->hide(); 271 it->second.text_->hide(); 257 272 } 258 } 259 260 void HUDNavigation::addObject(RadarViewable* object) 261 { 262 if (object == NULL) 273 274 } 275 } 276 277 278 /** Overridden method of OrxonoxOverlay. 279 @details 280 Usually the entire overlay scales with scale(). 281 Here we obviously have to adjust this. 282 */ 283 void HUDNavigation::sizeChanged() 284 { 285 // Use size to compensate for aspect ratio if enabled. 286 float xScale = this->getActualSize().x; 287 float yScale = this->getActualSize().y; 288 289 for ( ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it ) 290 { 291 if ( it->second.panel_ != NULL ) 292 it->second.panel_->setDimensions ( navMarkerSize_ * xScale, navMarkerSize_ * yScale ); 293 if ( it->second.text_ != NULL ) 294 it->second.text_->setCharHeight ( it->second.text_->getCharHeight() * yScale ); 295 } 296 } 297 298 void HUDNavigation::addObject ( RadarViewable* object ) 299 { 300 301 if ( activeObjectList_.size() >= markerLimit_ ) 302 if ( object == NULL ) 263 303 return; 264 304 265 // Don't display our own ship 266 if (object == dynamic_cast<RadarViewable*>(this->getOwner())) 267 return; 268 269 // Object hasn't been added yet (we know that) 270 assert(this->activeObjectList_.find(object) == this->activeObjectList_.end()); 271 272 // Scales used for dimensions and text size 273 float xScale = this->getActualSize().x; 274 float yScale = this->getActualSize().y; 275 276 // Create everything needed to display the object on the radar and add it to the map 277 278 // Create arrow/marker 279 Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 280 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 281 panel->setMaterialName("Orxonox/NavTDC"); 282 panel->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 283 284 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 285 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 286 text->setFontName(this->fontName_); 287 text->setCharHeight(text->getCharHeight() * yScale); 288 289 ObjectInfo tempStruct = {panel, text, false}; 290 activeObjectList_[object] = tempStruct; 291 292 this->background_->addChild(panel); 293 this->background_->addChild(text); 294 } 295 296 void HUDNavigation::removeObject(RadarViewable* viewable) 297 { 298 ObjectMap::iterator it = activeObjectList_.find(viewable); 299 300 if (activeObjectList_.find(viewable) != activeObjectList_.end()) 305 // Don't display our own ship 306 if ( object == dynamic_cast<RadarViewable*> ( this->getOwner() ) ) 307 return; 308 309 // Object hasn't been added yet (we know that) 310 assert ( this->activeObjectList_.find ( object ) == this->activeObjectList_.end() ); 311 312 // Scales used for dimensions and text size 313 float xScale = this->getActualSize().x; 314 float yScale = this->getActualSize().y; 315 316 // Create everything needed to display the object on the radar and add it to the map 317 318 // Create arrow/marker 319 Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*> ( Ogre::OverlayManager::getSingleton() 320 .createOverlayElement ( "Panel", "HUDNavigation_navMarker_" + getUniqueNumberString() ) ); 321 panel->setMaterialName ( "Orxonox/NavTDC" ); 322 panel->setDimensions ( navMarkerSize_ * xScale, navMarkerSize_ * yScale ); 323 324 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*> ( Ogre::OverlayManager::getSingleton() 325 .createOverlayElement ( "TextArea", "HUDNavigation_navText_" + getUniqueNumberString() ) ); 326 text->setFontName ( this->fontName_ ); 327 text->setCharHeight ( text->getCharHeight() * yScale ); 328 329 panel->hide(); 330 text->hide(); 331 332 ObjectInfo tempStruct = {panel, text, false}; 333 activeObjectList_[object] = tempStruct; 334 335 this->background_->addChild ( panel ); 336 this->background_->addChild ( text ); 337 338 sortedObjectList_.push_front ( std::make_pair ( object, ( unsigned int ) 0 ) ); 339 340 //TODO: hide elements 341 } 342 343 void HUDNavigation::removeObject ( RadarViewable* viewable ) 344 { 345 346 ObjectMap::iterator it = activeObjectList_.find ( viewable ); 347 348 if ( activeObjectList_.find ( viewable ) != activeObjectList_.end() ) 349 { 350 // Detach overlays 351 this->background_->removeChild ( it->second.panel_->getName() ); 352 this->background_->removeChild ( it->second.text_->getName() ); 353 // Properly destroy the overlay elements (do not use delete!) 354 Ogre::OverlayManager::getSingleton().destroyOverlayElement ( it->second.panel_ ); 355 Ogre::OverlayManager::getSingleton().destroyOverlayElement ( it->second.text_ ); 356 // Remove from the list 357 activeObjectList_.erase ( viewable ); 358 359 360 } 361 362 363 else 364 COUT ( 2 ) << "Warning, HUDNavigation: Attempting to remove non-existent object" << std::endl; 365 366 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt ) 367 { 368 if ( (listIt->first) == viewable ) 301 369 { 302 // Detach overlays 303 this->background_->removeChild(it->second.panel_->getName()); 304 this->background_->removeChild(it->second.text_->getName()); 305 // Properly destroy the overlay elements (do not use delete!) 306 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_); 307 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_); 308 // Remove from the list 309 activeObjectList_.erase(viewable); 370 sortedObjectList_.erase ( listIt ); 371 break; 310 372 } 311 else 312 COUT(2) << "Warning, HUDNavigation: Attempting to remove non-existent object" << std::endl; 313 } 314 315 void HUDNavigation::changedOwner() 316 { 317 // TODO: Delete old objects? 318 const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects(); 319 for (std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it) 320 { 321 if (!(*it)->isHumanShip_) 322 this->addObject(*it); 323 } 324 } 325 } 373 374 } 375 376 } 377 378 void HUDNavigation::changedOwner() 379 { 380 // TODO: Delete old objects? 381 const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects(); 382 for ( std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it ) 383 { 384 if ( ! ( *it )->isHumanShip_ ) 385 this->addObject ( *it ); 386 } 387 } 388 } -
code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
r6942 r6971 35 35 #include <string> 36 36 37 37 38 #include "util/OgreForwardRefs.h" 38 39 #include "tools/interfaces/Tickable.h" … … 42 43 namespace orxonox 43 44 { 44 class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener 45 class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener 46 { 47 public: 48 HUDNavigation ( BaseObject* creator ); 49 virtual ~HUDNavigation(); 50 51 virtual void XMLPort ( Element& xmlElement, XMLPort::Mode mode ); 52 virtual void tick ( float dt ); 53 54 virtual void addObject ( RadarViewable* object ); 55 virtual void removeObject ( RadarViewable* viewable ); 56 virtual void objectChanged ( RadarViewable* viewable ) {} 57 58 virtual void changedOwner(); 59 virtual void sizeChanged(); 60 virtual void angleChanged() { } 61 virtual void positionChanged() { } 62 virtual void radarTick ( float dt ) {} 63 64 inline float getRadarSensitivity() const 65 { return 1.0f; } 66 67 private: 68 struct ObjectInfo 45 69 { 46 public: 47 HUDNavigation(BaseObject* creator); 48 virtual ~HUDNavigation(); 70 Ogre::PanelOverlayElement* panel_; 71 Ogre::TextAreaOverlayElement* text_; 72 bool outOfView_; 73 bool wasOutOfView_; 49 74 50 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 51 virtual void tick(float dt); 75 }; 52 76 53 virtual void addObject(RadarViewable* object); 54 virtual void removeObject(RadarViewable* viewable); 55 virtual void objectChanged(RadarViewable* viewable) {} 77 // XMLPort accessors 78 void setNavMarkerSize ( float size ) 79 { navMarkerSize_ = size; this->sizeChanged(); } 80 float getNavMarkerSize() const 81 { return navMarkerSize_; } 56 82 57 virtual void changedOwner(); 58 virtual void sizeChanged(); 59 virtual void angleChanged() { } 60 virtual void positionChanged() { } 61 virtual void radarTick(float dt) {} 83 void setTextSize ( float size ); 84 float getTextSize() const; 62 85 63 inline float getRadarSensitivity() const64 { return 1.0f; }86 void setFont ( const std::string& font ); 87 const std::string& getFont() const; 65 88 66 private: 67 struct ObjectInfo 68 { 69 Ogre::PanelOverlayElement* panel_; 70 Ogre::TextAreaOverlayElement* text_; 71 bool outOfView_; 72 bool wasOutOfView_; 73 }; 89 typedef std::map<RadarViewable*, ObjectInfo > ObjectMap; 90 ObjectMap activeObjectList_; 74 91 75 // XMLPort accessors 76 void setNavMarkerSize(float size) 77 { navMarkerSize_ = size; this->sizeChanged(); } 78 float getNavMarkerSize() const 79 { return navMarkerSize_; } 92 typedef std::list < std::pair<RadarViewable*, unsigned int > > sortedList; 93 sortedList sortedObjectList_; 80 94 81 void setTextSize(float size);82 float getTextSize() const;83 95 84 void setFont(const std::string& font); 85 const std::string& getFont() const; 96 float navMarkerSize_; 97 std::string fontName_; 98 float textSize_; 86 99 87 typedef std::map<RadarViewable*, ObjectInfo > ObjectMap; 88 ObjectMap activeObjectList_; 100 static const unsigned int markerLimit_ = 5; //TODO: is it possible to set this over the console and/or the IG-Setting 89 101 90 float navMarkerSize_; 91 std::string fontName_; 92 float textSize_; 93 }; 102 103 }; 94 104 } 95 105
Note: See TracChangeset
for help on using the changeset viewer.