Changeset 1350 for code/branches
- Timestamp:
- May 21, 2008, 11:00:40 PM (16 years ago)
- Location:
- code/branches/hud3/src/orxonox/hud
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/HUD.cc
r1342 r1350 81 81 radar->addObject(Vector3(1500.0, 0.0, 0.0)); 82 82 radar->addObject(Vector3(0.0, 4000.0, 0.0)); 83 RadarOverlayElement::cycleFocus(); 83 84 } 84 85 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1346 r1350 32 32 using namespace Ogre; 33 33 34 RadarOverlayElement* RadarOverlayElement::instance_s = NULL; 35 34 36 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 37 RadarOverlayElement::instance_s = this; 35 38 } 36 39 … … 47 50 firstRadarObject_ = NULL; 48 51 lastRadarObject_ = NULL; 52 focus_ = NULL; 53 54 // create nav marker ... 55 navMarker_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "NavMarker")); 56 navMarker_->setMetricsMode(Ogre::GMM_PIXELS); 57 navMarker_->setMaterialName("Orxonox/NavMarker"); 58 navMarker_->setDimensions(16,16); 59 navMarker_->setPosition(0,386); 60 navMarker_->hide(); 61 container_->addChild(navMarker_); 49 62 50 63 // these have to fit the data in the level … … 105 118 ro = ro->next; 106 119 } 120 updateNavMarker(); 121 } 122 123 void RadarOverlayElement::updateNavMarker(){ 124 if(focus_ == NULL) return; 125 // from the angle we find out where to draw the marker 126 // and which of the four arrows to take 127 float r1 = 0.97;//atan(windowW_/windowH_); // doesn't work correctly yet 128 float phi = focus_->phi_; 129 if(focus_->right_){ 130 if(phi<r1){ 131 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, 0); 132 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 133 } 134 else if(phi>3.14-r1){ 135 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, windowH_-16); 136 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 137 } 138 else { 139 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 140 navMarker_->setUV(0.5, 0.5, 1.0, 1.0); 141 } 142 } 143 else{ 144 if(phi<r1) { 145 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, 0); 146 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 147 } 148 else if(phi>3.14-r1) { 149 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, windowH_-16); 150 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 151 } 152 else { 153 navMarker_->setPosition(0, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 154 navMarker_->setUV(0.0, 0.0, 0.5, 0.5); 155 } 156 } 107 157 } 108 158 … … 147 197 else return false; 148 198 } 199 200 /*static*/void RadarOverlayElement::cycleFocus(){ 201 if(RadarOverlayElement::instance_s == NULL) return; 202 if(RadarOverlayElement::instance_s->focus_ == NULL) 203 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->firstRadarObject_; 204 else 205 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->focus_->next; 206 if(RadarOverlayElement::instance_s->focus_ == NULL) 207 RadarOverlayElement::instance_s->navMarker_->hide(); 208 else 209 RadarOverlayElement::instance_s->navMarker_->show(); 210 } 149 211 } 150 212 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
r1346 r1350 50 50 private: 51 51 Ogre::OverlayManager* om; // our one and only overlay manager 52 Ogre::OverlayContainer* container_; 52 Ogre::OverlayContainer* container_; // pointer to the container we're in 53 53 Vector3 initialDir_; // direction of nose 54 54 Vector3 currentDir_; … … 57 57 Vector3 shipPos_; // position of ship 58 58 Ogre::Plane plane; // plane perpendicular to dir 59 60 RadarObject* firstRadarObject_; // start of linked list61 RadarObject* lastRadarObject_; // end of linked list62 59 63 60 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension … … 71 68 void resize(); 72 69 void update(); 70 void updateNavMarker(); 73 71 void addObject(Vector3 pos); 74 72 void listObjects(); … … 76 74 float calcPhi(RadarObject* obj); 77 75 bool calcRight(RadarObject* obj); 76 77 Ogre::PanelOverlayElement* navMarker_; // marker to help navigating 78 RadarObject* firstRadarObject_; // start of linked list 79 RadarObject* lastRadarObject_; // end of linked list 80 RadarObject* focus_; // object that is focussed 81 82 static RadarOverlayElement* instance_s; 83 static void cycleFocus(); 78 84 }; 79 85 }
Note: See TracChangeset
for help on using the changeset viewer.