Changeset 6417 for code/trunk/src/modules/overlays/hud/HUDNavigation.cc
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r5929 r6417 30 30 31 31 #include <string> 32 #include <OgreCamera.h> 32 33 #include <OgreOverlayManager.h> 33 34 #include <OgreTextAreaOverlayElement.h> … … 35 36 36 37 #include "util/Math.h" 37 #include "util/StringUtils.h"38 38 #include "util/Convert.h" 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/XMLPort.h" 41 #include "CameraManager.h" 41 42 #include "Scene.h" 42 43 #include "Radar.h" 44 #include "graphics/Camera.h" 45 #include "controllers/HumanController.h" 46 #include "worldentities/pawns/Pawn.h" 43 47 44 48 namespace orxonox … … 60 64 navMarker_->setMaterialName("Orxonox/NavArrows"); 61 65 66 /* 62 67 // create aim marker 63 68 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() … … 70 75 setNavMarkerSize(0.05f); 71 76 setAimMarkerSize(0.04f); 77 */ 72 78 73 79 background_->addChild(navMarker_); 74 background_->addChild(aimMarker_);80 // background_->addChild(aimMarker_); 75 81 background_->addChild(navText_); 76 82 … … 85 91 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 86 92 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 87 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);93 // Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 88 94 } 89 95 } … … 96 102 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 97 103 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 98 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);104 // XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 99 105 } 100 106 101 107 void HUDNavigation::setFont(const std::string& font) 102 108 { 103 if (this->navText_ && font != "")109 if (this->navText_ && !font.empty()) 104 110 this->navText_->setFontName(font); 105 111 } … … 149 155 float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3; 150 156 151 /* 152 Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;153 Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();154 */ 157 orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera(); 158 if (!cam) 159 return; 160 const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 155 161 // transform to screen coordinates 156 Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();162 Vector3 pos = transform * radar->getFocus()->getRVWorldPosition(); 157 163 158 164 bool outOfView; … … 172 178 { 173 179 // object is not in view 174 aimMarker_->hide();180 // aimMarker_->hide(); 175 181 176 182 if (!wasOutOfView_) … … 227 233 // object is in view 228 234 /* 229 Vector3 aimpos = transform ationMatrix* getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),235 Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 230 236 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 231 237 */ … … 241 247 navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5); 242 248 249 /* 243 250 aimMarker_->show(); 244 /*245 251 aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5); 246 252 aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5); … … 253 259 float HUDNavigation::getDist2Focus() const 254 260 { 255 /* 256 if (Radar::getInstance().getFocus()) 257 return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); 258 else 259 */ 261 Radar* radar = this->getOwner()->getScene()->getRadar(); 262 if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn()) 263 return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 264 else 260 265 return 0; 261 266 } … … 267 272 void HUDNavigation::sizeChanged() 268 273 { 269 // use size to compensate for a pspect ratio if enabled.274 // use size to compensate for aspect ratio if enabled. 270 275 float xScale = this->getActualSize().x; 271 276 float yScale = this->getActualSize().y; 272 277 if (this->navMarker_) 273 278 navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 279 /* 274 280 if (this->aimMarker_) 275 281 aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale); 282 */ 276 283 if (this->navText_) 277 284 navText_->setCharHeight(navText_->getCharHeight() * yScale);
Note: See TracChangeset
for help on using the changeset viewer.