Changeset 9818 for code/branches/radarDreiD/src/modules
- Timestamp:
- Nov 25, 2013, 4:01:10 PM (11 years ago)
- Location:
- code/branches/radarDreiD/src/modules/overlays/hud
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/radarDreiD/src/modules/overlays/hud/HUDNavigation.cc
r9667 r9818 74 74 OrxonoxOverlay(context) 75 75 { 76 RegisterObject(HUDNavigation) 77 ;this->setConfigValues();76 RegisterObject(HUDNavigation); 77 this->setConfigValues(); 78 78 79 79 // Set default values -
code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc
r9796 r9818 42 42 #include "Scene.h" 43 43 #include "Radar.h" 44 #include "core/config/ConfigValueIncludes.h" 44 45 45 46 namespace orxonox … … 51 52 { 52 53 RegisterObject(HUDRadar); 54 this->setConfigValues(); 53 55 54 56 this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() … … 61 63 this->setHalfDotSizeDistance(3000.0f); 62 64 this->setMaximumDotSize(0.1f); 65 this->setMaximumDotSize3D(0.07f); 63 66 64 67 this->shapeMaterials_[RadarViewable::Dot] = "RadarDot.png"; … … 82 85 } 83 86 87 88 89 void HUDRadar::setConfigValues() 90 { 91 SetConfigValue(RadarMode_, true); 92 } 93 84 94 void HUDRadar::XMLPort(Element& xmlelement, XMLPort::Mode mode) 85 95 { … … 89 99 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode); 90 100 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlelement, mode); 101 XMLPortParam(HUDRadar, "maximumDotSize3D", setMaximumDotSize3D, getMaximumDotSize3D, xmlelement, mode); 102 XMLPortParam(HUDRadar, "Material2D", set2DMaterial, get2DMaterial, xmlelement, mode); 103 XMLPortParam(HUDRadar, "Material3D", set3DMaterial, get3DMaterial, xmlelement, mode); 91 104 } 92 105 … … 153 166 // update the distances for all objects 154 167 std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it; 168 169 170 if(RadarMode_) 171 { 172 this->setBackgroundMaterial(material3D_); 173 174 175 176 } 177 else 178 this->setBackgroundMaterial(material2D_); 179 180 181 155 182 for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it ) 156 183 { … … 166 193 float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length(); 167 194 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 168 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 169 170 195 196 float size; 197 if(RadarMode_) 198 size = maximumDotSize3D_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 199 else 200 size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 171 201 it->second->setDimensions(size, size); 172 202 173 203 // calc position on radar... 174 //Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 175 Vector2 coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_); 176 177 // set zOrder on screen 178 bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011); 179 180 if(overXZPlain == false && (it->second->getZOrder() > 100 * this->overlay_->getZOrder())) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay 181 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1); 182 if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())) 183 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1); 184 185 204 Vector2 coord; 205 if(RadarMode_) 206 { 207 coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_); 208 209 // set zOrder on screen 210 bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011); 211 212 if(overXZPlain == false && (it->second->getZOrder() > 100 * this->overlay_->getZOrder())) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay 213 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1); 214 if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())) 215 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1); 216 } 217 else 218 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 186 219 187 220 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture -
code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.h
r9667 r9818 35 35 #include <map> 36 36 #include <vector> 37 #include <string> 37 38 38 39 #include "util/OgreForwardRefs.h" … … 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 53 virtual void changedOwner(); 54 void setConfigValues(); 53 55 54 56 private: … … 64 66 float getMaximumDotSize() const { return this->maximumDotSize_; } 65 67 void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } 68 69 float getMaximumDotSize3D() const { return this->maximumDotSize3D_; } 70 void setMaximumDotSize3D(float size) { this->maximumDotSize3D_ = size;} 71 72 std::string get2DMaterial() const {return this->material2D_; } 73 void set2DMaterial(std::string material2D) { this->material2D_ = material2D; } 74 75 std::string get3DMaterial() const {return this->material3D_; } 76 void set3DMaterial(std::string material3D) { this->material3D_ = material3D; } 66 77 67 78 float getRadarSensitivity() const { return this->sensitivity_; } … … 85 96 Ogre::PanelOverlayElement* marker_; 86 97 98 bool RadarMode_; // Determines, if Radar runs in 3D or 2D Mode 99 87 100 float halfDotSizeDistance_; 88 101 float maximumDotSize_; 102 float maximumDotSize3D_; 103 104 std::string material2D_; 105 std::string material3D_; 89 106 90 107 float sensitivity_;
Note: See TracChangeset
for help on using the changeset viewer.