Changeset 1411 for code/branches/network/src/orxonox/hud/Navigation.cc
- Timestamp:
- May 24, 2008, 5:35:34 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/hud/Navigation.cc
r1410 r1411 103 103 int xPos = xPosRel*windowW_; 104 104 int yPos = yPosRel*windowH_; 105 int xFromCenter = xPos-windowW_/2; 106 int yFromCenter = yPos-windowH_/2; 105 107 // is object in view? 108 float radius = RadarOverlayElement::calcRadius(navCamPos_, currentDir_, currentOrth_, focus_); 109 bool isRight = (currentDir_.crossProduct(currentOrth_)).dotProduct(focus_->pos_ - navCamPos_)>0; 110 bool isAbove = currentOrth_.dotProduct(focus_->pos_ - navCamPos_)>0; 106 111 bool outOfView = (xPosRel<0 || xPosRel>1 || yPosRel<0 || yPosRel>1); 107 112 // if object is behind us, it is out of view anyway: 108 if(!outOfView && RadarOverlayElement::calcRadius(navCamPos_, currentDir_, currentOrth_, focus_)>3.14/2) outOfView = true;113 if(!outOfView && radius>3.14/2) outOfView = true; 109 114 110 115 if(outOfView){ 111 // NO!116 // object is not in view 112 117 navMarker_->setMaterialName("Orxonox/NavArrows"); 113 118 navMarker_->setDimensions(16,16); 114 float phiUp Right= atan((float)(windowW_)/(float)(windowH_));115 // from the angle we find out where to draw the marker119 float phiUpperCorner = atan((float)(windowW_)/(float)(windowH_)); 120 // from the angle we find out on which edge to draw the marker 116 121 // and which of the four arrows to take 117 float phiNav = RadarOverlayElement::calcPhi(navCamPos_, currentDir_, currentOrth_, focus_); 118 bool right = RadarOverlayElement::calcRight(navCamPos_, currentDir_, currentOrth_, focus_); 119 if(right){ 120 if(phiNav<phiUpRight){ 121 // arrow up 122 navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, 0); 122 float phiNav = atan((float) xFromCenter / (float) yFromCenter); 123 124 if(isAbove && isRight){ 125 // top right quadrant 126 if(-phiNav<phiUpperCorner){ 127 COUT(3) << "arrow up\n"; 128 navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, 0); 123 129 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 124 130 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 125 131 navText_->setTop(navMarker_->getHeight()); 126 132 } 127 else if(phiNav>3.14-phiUpRight){ 128 // arrow down 129 navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, windowH_-16); 130 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 131 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 132 navText_->setTop(navMarker_->getTop()-navMarker_->getHeight()); 133 } 134 else { 135 // arrow right 136 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2); 133 else { 134 COUT(3) << "arrow right\n"; 135 navMarker_->setPosition(windowW_-16, tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2); 137 136 navMarker_->setUV(0.5, 0.5, 1.0, 1.0); 138 137 navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth()); … … 140 139 } 141 140 } 142 else{ 143 if(phiNav<phiUpRight) { 144 // arrow up 141 if(!isAbove && isRight){ 142 // bottom right quadrant 143 if(phiNav<phiUpperCorner) { 144 COUT(3) << "arrow down\n"; 145 navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16); 146 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 147 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 148 navText_->setTop(navMarker_->getTop()-navMarker_->getHeight()); 149 } 150 else { 151 COUT(3) << "arrow right\n"; 152 navMarker_->setPosition(windowW_-16, tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2); 153 navMarker_->setUV(0.5, 0.5, 1.0, 1.0); 154 navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth()); 155 navText_->setTop(navMarker_->getTop()+navMarker_->getHeight()); 156 } 157 } 158 if(isAbove && !isRight){ 159 // top left quadrant 160 if(phiNav<phiUpperCorner){ 161 COUT(3) << "arrow up\n"; 145 162 navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, 0); 146 163 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); … … 148 165 navText_->setTop(navMarker_->getHeight()); 149 166 } 150 else if(phiNav>3.14-phiUpRight) { 151 // arrow down 152 navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16); 153 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 154 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 155 navText_->setTop(navMarker_->getTop()-navMarker_->getHeight()); 156 } 157 else { 158 // arrow left 167 else { 168 COUT(3) << "arrow left\n"; 159 169 navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2); 160 170 navMarker_->setUV(0.0, 0.0, 0.5, 0.5); … … 163 173 } 164 174 } 175 if(!isAbove && !isRight){ 176 // bottom left quadrant 177 if(phiNav>-phiUpperCorner) { 178 COUT(3) << "arrow down\n"; 179 navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16); 180 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 181 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 182 navText_->setTop(navMarker_->getTop()-navMarker_->getHeight()); 183 } 184 else { 185 COUT(3) << "arrow left\n"; 186 navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2); 187 navMarker_->setUV(0.0, 0.0, 0.5, 0.5); 188 navText_->setLeft(navMarker_->getWidth()); 189 navText_->setTop(navMarker_->getTop()+navMarker_->getHeight()); 190 } 191 } 165 192 } 166 193 else{ 167 // YES!194 // object is in view 168 195 navMarker_->setMaterialName("Orxonox/NavTDC"); 169 196 navMarker_->setDimensions(24,24);
Note: See TracChangeset
for help on using the changeset viewer.