- Timestamp:
- Nov 25, 2008, 1:14:19 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDRadar.cc
r2087 r2256 40 40 #include "core/XMLPort.h" 41 41 #include "objects/Radar.h" 42 #include "objects/worldentities/WorldEntity.h" 43 #include "objects/worldentities/pawns/Pawn.h" 42 44 #include "tools/TextureGenerator.h" 43 45 … … 51 53 RegisterObject(HUDRadar); 52 54 53 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()55 this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 54 56 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString())); 55 marker_->setMaterialName("Orxonox/RadarMarker");56 overlay_->add2D(marker_);57 marker_->hide();57 this->marker_->setMaterialName("Orxonox/RadarMarker"); 58 this->overlay_->add2D(this->marker_); 59 this->marker_->hide(); 58 60 59 setRadarSensitivity(1.0f);60 setHalfDotSizeDistance(3000.0f);61 setMaximumDotSize(0.1f);61 this->setRadarSensitivity(1.0f); 62 this->setHalfDotSizeDistance(3000.0f); 63 this->setMaximumDotSize(0.1f); 62 64 63 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 64 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 65 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 65 this->shapeMaterials_[RadarViewable::Dot] = "RadarDot.tga"; 66 this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 67 this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 68 69 this->owner_ = 0; 66 70 } 67 71 … … 90 94 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 91 95 { 92 /* 96 if (object == (RadarViewable*)this->owner_) 97 return; 98 93 99 const WorldEntity* wePointer = object->getWorldEntity(); 94 100 95 101 // Just to be sure that we actually have a WorldEntity. 96 102 // We could do a dynamic_cast, but that would be a lot slower. 97 if (!wePointer )103 if (!wePointer || !this->owner_) 98 104 { 99 CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl; 105 if (!wePointer) 106 CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl; 107 if (!this->owner_) 108 CCOUT(2) << "No owner defined" << std::endl; 100 109 return; 101 110 } 102 */ 111 103 112 // try to find a panel already created 104 113 Ogre::PanelOverlayElement* panel; … … 112 121 // get right material 113 122 panel->setMaterialName(TextureGenerator::getMaterialName( 114 shapeMaterials_[object->getRadarObject Type()], object->getRadarObjectColour()));123 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour())); 115 124 this->overlay_->add2D(panel); 116 125 this->itRadarDots_ = this->radarDots_.end(); … … 121 130 ++itRadarDots_; 122 131 std::string materialName = TextureGenerator::getMaterialName( 123 shapeMaterials_[object->getRadarObject Type()], object->getRadarObjectColour());132 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()); 124 133 if (materialName != panel->getMaterialName()) 125 134 panel->setMaterialName(materialName); 126 135 } 127 136 panel->show(); 128 /* 137 129 138 // set size to fit distance... 130 float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();139 float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length(); 131 140 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 132 141 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance); … … 134 143 135 144 // calc position on radar... 136 Vector2 coord = get2DViewcoordinates( SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());145 Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 137 146 coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture 138 147 panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5); … … 144 153 this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5); 145 154 } 146 */147 155 } 148 156 … … 154 162 this->marker_->hide(); 155 163 } 164 165 void HUDRadar::changedOwner() 166 { 167 SUPER(HUDRadar, changedOwner); 168 169 this->owner_ = dynamic_cast<Pawn*>(this->getOwner()); 170 } 156 171 }
Note: See TracChangeset
for help on using the changeset viewer.