Changeset 1411
- Timestamp:
- May 24, 2008, 5:35:34 PM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/Orxonox.cc
r1406 r1411 401 401 client_g = network::Client::createSingleton(); 402 402 else 403 403 404 404 client_g = network::Client::createSingleton(serverIp_, serverPort_); 405 405 … … 490 490 // orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber()); 491 491 if (eventTimes[3].back() - eventTimes[3].front() != 0) 492 HUD:: setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front()));492 HUD::getSingleton().setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front())); 493 493 494 494 // Iterate through all Tickables and call their tick(dt) function -
code/branches/network/src/orxonox/hud/BarOverlayElement.cc
r1410 r1411 28 28 #include "OrxonoxStableHeaders.h" 29 29 #include "BarOverlayElement.h" 30 31 30 #include <OgreOverlayManager.h> 32 31 #include "GraphicsEngine.h" -
code/branches/network/src/orxonox/hud/BarOverlayElement.h
r1410 r1411 26 26 */ 27 27 28 #ifndef _BAR_H__ 29 #define _BAR_H__ 28 30 29 #ifndef _BarOverlayElement_H__ 30 #define _BarOverlayElement_H__ 31 32 #include "OrxonoxPrereqs.h" 33 31 #include <OgrePanelOverlayElement.h> 34 32 #include <OgrePrerequisites.h> 35 #include <OgrePanelOverlayElement.h>33 #include "../OrxonoxPrereqs.h" 36 34 37 35 namespace orxonox … … 40 38 { 41 39 private: 42 bool autoColor_; // whether bar changes color automatically43 float value_; // progress of bar44 int color_;45 int left_;46 int top_;47 int width_;48 int height_;49 int windowW_, windowH_;50 Ogre::Real leftRel_;51 Ogre::Real topRel_;52 Ogre::Real dimRel_;53 Ogre::OverlayManager* om; // our overlay manager54 Ogre::OverlayContainer* container_; // our parent container to attach to55 Ogre::OverlayContainer* background_;56 Ogre::String name_;40 bool autoColor_; // whether bar changes color automatically 41 float value_; // progress of bar 42 int color_; 43 int left_; 44 int top_; 45 int width_; 46 int height_; 47 int windowW_, windowH_; 48 Ogre::Real leftRel_; 49 Ogre::Real topRel_; 50 Ogre::Real dimRel_; 51 Ogre::OverlayManager* om; // our overlay manager 52 Ogre::OverlayContainer* container_; // our parent container to attach to 53 Ogre::OverlayContainer* background_; 54 Ogre::String name_; 57 55 58 56 public: 59 bool left2Right;60 static const int RED = 0; // predefined colors61 static const int YELLOW = 1;62 static const int GREEN = 2;57 bool left2Right; 58 static const int RED = 0; // predefined colors 59 static const int YELLOW = 1; 60 static const int GREEN = 2; 63 61 64 BarOverlayElement(const Ogre::String& name);65 virtual ~BarOverlayElement();66 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);67 void resize();68 void setValue(float value);69 void setColor(int color);70 float getValue();71 int getBarColor();62 BarOverlayElement(const Ogre::String& name); 63 virtual ~BarOverlayElement(); 64 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 65 void resize(); 66 void setValue(float value); 67 void setColor(int color); 68 float getValue(); 69 int getBarColor(); 72 70 }; 73 71 } 72 #endif 74 73 75 #endif /* _BarOverlayElement_H__ */ 74 -
code/branches/network/src/orxonox/hud/HUD.cc
r1410 r1411 131 131 } 132 132 133 void HUD::setFPS(float fps){ 134 fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 135 } 136 133 137 void HUD::addRadarObject(Vector3 pos){ 134 138 // check if this is the first RadarObject to create … … 152 156 } 153 157 154 /*static*/ void HUD::setFPS(float fps){155 HUD::getSingleton().fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps));156 }157 158 158 /*static*/ void HUD::setEnergy(float value){ 159 159 HUD::getSingleton().energyBar->setValue(value); -
code/branches/network/src/orxonox/hud/HUD.h
r1410 r1411 58 58 public: 59 59 virtual void tick(float); 60 void setFPS(float fps); 60 61 void addRadarObject(Vector3 pos); 61 62 RadarObject* getFirstRadarObject(); … … 63 64 static HUD* instance_s; 64 65 static HUD& getSingleton(); 65 static void setFPS(float fps);66 66 static void setEnergy(float value); 67 67 static void cycleNavigationFocus(); -
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); -
code/branches/network/src/orxonox/hud/RadarObject.h
r1410 r1411 20 20 * 21 21 * Author: 22 * Yuning Chai22 * Felix Schulthess 23 23 * Co-authors: 24 24 * ... -
code/branches/network/src/orxonox/hud/RadarOverlayElement.h
r1410 r1411 22 22 * Yuning Chai 23 23 * Co-authors: 24 * ...24 * Felix Schulthess 25 25 * 26 26 */
Note: See TracChangeset
for help on using the changeset viewer.