Changeset 1410 for code/branches
- Timestamp:
- May 24, 2008, 3:38:39 PM (16 years ago)
- Location:
- code/branches/network
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/OrxonoxPrereqs.h
r1214 r1410 95 95 96 96 // hud 97 class BarOverlayElement; 97 98 class HUD; 99 class Navigation; 100 class RadarObject; 101 class RadarOverlayElement; 102 98 103 //console 99 104 class InGameConsole; -
code/branches/network/src/orxonox/hud/BarOverlayElement.cc
r1406 r1410 27 27 28 28 #include "OrxonoxStableHeaders.h" 29 #include "BarOverlayElement.h" 30 29 31 #include <OgreOverlayManager.h> 30 32 #include "GraphicsEngine.h" 31 #include "BarOverlayElement.h"32 33 33 34 namespace orxonox 34 35 { 35 using namespace Ogre;36 using namespace Ogre; 36 37 37 38 BarOverlayElement::BarOverlayElement(const String& name):PanelOverlayElement(name){ … … 125 126 } 126 127 } 127 128 129 -
code/branches/network/src/orxonox/hud/BarOverlayElement.h
r1406 r1410 27 27 28 28 29 #ifndef _B AR_H__30 #define _B AR_H__29 #ifndef _BarOverlayElement_H__ 30 #define _BarOverlayElement_H__ 31 31 32 #include "OrxonoxPrereqs.h" 32 33 34 #include <OgrePrerequisites.h> 33 35 #include <OgrePanelOverlayElement.h> 34 #include <OgrePrerequisites.h>35 #include "../OrxonoxPrereqs.h"36 36 37 37 namespace orxonox … … 40 40 { 41 41 private: 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 42 bool autoColor_; // whether bar changes color automatically 43 float value_; // progress of bar 44 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 manager 54 Ogre::OverlayContainer* container_; // our parent container to attach to 55 Ogre::OverlayContainer* background_; 56 Ogre::String name_; 57 57 58 58 public: 59 60 61 62 59 bool left2Right; 60 static const int RED = 0; // predefined colors 61 static const int YELLOW = 1; 62 static const int GREEN = 2; 63 63 64 65 66 67 68 69 70 71 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(); 72 72 }; 73 73 } 74 #endif75 74 76 75 #endif /* _BarOverlayElement_H__ */ -
code/branches/network/src/orxonox/hud/HUD.cc
r1406 r1410 26 26 */ 27 27 28 #include <string.h>29 28 #include "OrxonoxStableHeaders.h" 29 #include "HUD.h" 30 31 #include <string> 30 32 #include <OgreOverlay.h> 31 33 #include <OgreOverlayContainer.h> … … 37 39 #include "objects/SpaceShip.h" 38 40 #include "BarOverlayElement.h" 41 #include "RadarObject.h" 39 42 #include "RadarOverlayElement.h" 43 #include "Navigation.h" 40 44 #include "OverlayElementFactories.h" 41 #include "HUD.h"42 45 43 46 namespace orxonox … … 52 55 lastRadarObject = NULL; 53 56 54 57 // create Factories 55 58 BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory(); 56 59 om->addOverlayElementFactory(barOverlayElementFactory); … … 84 87 nav = new Navigation(container); 85 88 86 89 // set up screen-wide container 87 90 container->show(); 88 91 … … 144 147 } 145 148 146 /*static*/ HUD& HUD::getSingleton(){149 /*static*/ HUD& HUD::getSingleton(){ 147 150 static HUD theInstance; 148 151 return theInstance; 149 152 } 150 153 151 /*static*/ void HUD::setFPS(float fps){154 /*static*/ void HUD::setFPS(float fps){ 152 155 HUD::getSingleton().fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 153 156 } 154 157 155 /*static*/ void HUD::setEnergy(float value){158 /*static*/ void HUD::setEnergy(float value){ 156 159 HUD::getSingleton().energyBar->setValue(value); 157 160 } 158 161 159 /*static*/ void HUD::cycleNavigationFocus(){162 /*static*/ void HUD::cycleNavigationFocus(){ 160 163 HUD::getSingleton().nav->cycleFocus(); 161 164 } -
code/branches/network/src/orxonox/hud/HUD.h
r1406 r1410 30 30 #define _HUD_H__ 31 31 32 #include "OrxonoxPrereqs.h" 33 32 34 #include <OgrePrerequisites.h> 33 35 #include <OgreTextAreaOverlayElement.h> 34 #include "OrxonoxPrereqs.h"35 36 #include "core/Tickable.h" 36 #include "BarOverlayElement.h" 37 #include "RadarOverlayElement.h" 38 #include "Navigation.h" 39 #include "RadarObject.h" 40 37 #include "util/Math.h" 41 38 42 39 namespace orxonox … … 44 41 class _OrxonoxExport HUD : public Tickable 45 42 { 46 47 48 49 50 51 52 53 54 55 56 57 58 59 43 private: 44 HUD(); 45 HUD(HUD& instance); 46 ~HUD(); 47 Ogre::OverlayManager* om; 48 Ogre::Overlay* orxonoxHUD; 49 Ogre::OverlayContainer* container; 50 Ogre::TextAreaOverlayElement* fpsText; 51 BarOverlayElement* energyBar; 52 BarOverlayElement* speedoBar; 53 RadarOverlayElement* radar; 54 RadarObject* firstRadarObject; 55 RadarObject* lastRadarObject; 56 Navigation* nav; 60 57 61 62 63 64 58 public: 59 virtual void tick(float); 60 void addRadarObject(Vector3 pos); 61 RadarObject* getFirstRadarObject(); 65 62 66 67 68 69 70 63 static HUD* instance_s; 64 static HUD& getSingleton(); 65 static void setFPS(float fps); 66 static void setEnergy(float value); 67 static void cycleNavigationFocus(); 71 68 }; 72 69 } 73 70 74 #endif 71 #endif /* _HUD_H__ */ -
code/branches/network/src/orxonox/hud/Navigation.cc
r1406 r1410 26 26 */ 27 27 28 #include "OrxonoxStableHeaders.h" 29 #include "Navigation.h" 30 28 31 #include <OgreOverlayManager.h> 29 #include <OgrePanelOverlayElement.h>30 #include <OgreTextAreaOverlayElement.h>31 32 #include <OgreStringConverter.h> 32 #include <GraphicsEngine.h> 33 34 #include "GraphicsEngine.h" 35 // TODO: remove the SpaceShip and CameraHandler dependencies 33 36 #include "objects/SpaceShip.h" 34 37 #include "objects/CameraHandler.h" 38 #include "RadarObject.h" 39 #include "RadarOverlayElement.h" 35 40 #include "HUD.h" 36 #include "Navigation.h"37 41 38 42 namespace orxonox … … 53 57 54 58 void Navigation::init(){ 55 56 59 om = &OverlayManager::getSingleton(); 60 navCam_ = NULL; 57 61 // create nav text 58 62 navText_ = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "navText")); … … 73 77 navText_->hide(); 74 78 container_->addChild(navMarker_); 75 76 77 79 } 80 81 void Navigation::update(){ 78 82 if(focus_ == NULL) return; 79 83 navCamPos_ = SpaceShip::getLocalShip()->getPosition(); 80 84 currentDir_ = SpaceShip::getLocalShip()->getDir(); 81 85 currentOrth_ = SpaceShip::getLocalShip()->getOrth(); 82 86 83 87 windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); … … 168 172 navText_->setPosition(xPos+navMarker_->getWidth()/2, yPos+navMarker_->getHeight()/2); 169 173 } 170 174 } 171 175 172 176 void Navigation::cycleFocus(){ 173 177 if(focus_ == NULL){ 174 178 focus_ = HUD::getSingleton().getFirstRadarObject(); 175 179 } 176 180 else{ 177 181 focus_->panel_->setMaterialName("Orxonox/RedDot"); … … 188 192 focus_->panel_->setMaterialName("Orxonox/WhiteDot"); 189 193 } 190 191 192 193 194 195 194 } 195 196 float Navigation::getDist2Focus(){ 197 if(focus_ == NULL) return(0.0); 198 return((focus_->pos_-SpaceShip::getLocalShip()->getPosition()).length()); 199 } 196 200 } -
code/branches/network/src/orxonox/hud/Navigation.h
r1406 r1410 26 26 */ 27 27 28 #ifndef _NAVIGATION_H__ 29 #define _NAVIGATION_H__ 28 #ifndef _Navigation_H__ 29 #define _Navigation_H__ 30 31 #include "OrxonoxPrereqs.h" 30 32 31 33 #include <OgrePrerequisites.h> 32 #include "../OrxonoxPrereqs.h"33 #include <OgreP lane.h>34 #include <OgreTextAreaOverlayElement.h> 35 #include <OgrePanelOverlayElement.h> 34 36 #include "util/Math.h" 35 #include "RadarObject.h"36 37 37 38 namespace orxonox 38 39 { 40 39 41 class _OrxonoxExport Navigation 40 42 { 41 42 Ogre::OverlayManager* om;// our one and only overlay manager43 44 45 46 47 Vector3 navCamPos_;// position of ship48 49 50 51 52 43 private: 44 Ogre::OverlayManager* om; // our one and only overlay manager 45 Ogre::OverlayContainer* container_; 46 Ogre::PanelOverlayElement* navMarker_; // the panel used to show the arrow 47 Ogre::TextAreaOverlayElement* navText_; // displaying distance 48 Ogre::Camera* navCam_; 49 Vector3 navCamPos_; // position of ship 50 Vector3 currentDir_; 51 Vector3 currentOrth_; 52 int windowW_, windowH_; 53 void init(); 54 void updateMarker(); 53 55 54 55 56 57 58 56 public: 57 Navigation(Ogre::OverlayContainer* container); 58 Navigation(Ogre::OverlayContainer* container, RadarObject* focus); 59 ~Navigation(); 60 RadarObject* focus_; // next pointer of linked list 59 61 60 61 62 63 62 void update(); 63 void cycleFocus(); 64 float getDist2Focus(); 65 }; 64 66 } 65 67 66 #endif 68 #endif /* _Navigation_H__ */ -
code/branches/network/src/orxonox/hud/OverlayElementFactories.h
r1362 r1410 26 26 */ 27 27 28 #ifndef _ FACTORIES_H__29 #define _ FACTORIES_H__28 #ifndef _OverlayElementFactories_H__ 29 #define _OverlayElementFactories_H__ 30 30 31 #include "OrxonoxPrereqs.h" 32 33 #include <OgrePrerequisites.h> 31 34 #include <OgreOverlayElement.h> 32 #include <OgrePrerequisites.h>33 35 #include <OgreOverlayElementFactory.h> 34 36 35 37 #include "BarOverlayElement.h" 38 #include "RadarOverlayElement.h" 36 39 37 40 namespace orxonox{ 38 41 class _OrxonoxExport BarOverlayElementFactory : public Ogre::OverlayElementFactory{ 39 42 public: 40 43 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 41 44 return new BarOverlayElement(instanceName); … … 48 51 49 52 class _OrxonoxExport RadarOverlayElementFactory : public Ogre::OverlayElementFactory{ 50 53 public: 51 54 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 52 55 return new RadarOverlayElement(instanceName); … … 59 62 } 60 63 61 #endif 64 #endif /* _OverlayElementFactories_H__ */ -
code/branches/network/src/orxonox/hud/RadarObject.cc
r1408 r1410 29 29 #include "RadarObject.h" 30 30 31 #include <string.h>32 31 #include <OgreOverlayManager.h> 33 32 #include <OgreStringConverter.h> … … 37 36 using namespace Ogre; 38 37 39 38 int RadarObject::count = 0; // initialize static variable 40 39 41 42 43 44 45 40 RadarObject::RadarObject(OverlayContainer* container){ 41 container_ = container; 42 pos_ = Vector3(0.0, 0.0, 0.0); 43 init(); 44 } 46 45 47 48 49 50 51 46 RadarObject::RadarObject(OverlayContainer* container, Vector3 pos){ 47 container_ = container; 48 pos_ = pos; 49 init(); 50 } 52 51 53 52 RadarObject::~RadarObject(){} 54 53 55 56 57 58 59 60 61 54 void RadarObject::init(){ 55 next = NULL; 56 om = &OverlayManager::getSingleton(); 57 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 58 "Object"+StringConverter::toString(count))); 59 panel_->setMaterialName("Orxonox/RedDot"); 60 panel_->setDimensions(3,3); 62 61 panel_->setMetricsMode(Ogre::GMM_PIXELS); 63 62 panel_->show(); … … 65 64 count++; 66 65 container_->addChild(panel_); 67 66 } 68 67 } -
code/branches/network/src/orxonox/hud/RadarObject.h
r1408 r1410 26 26 */ 27 27 28 #ifndef _RADAR2_H__ 29 #define _RADAR2_H__ 28 #ifndef _RadarObject_H__ 29 #define _RadarObject_H__ 30 31 #include "OrxonoxPrereqs.h" 32 30 33 #include <OgrePrerequisites.h> 31 34 #include <OgrePanelOverlayElement.h> 32 #include "../OrxonoxPrereqs.h"33 35 #include "util/Math.h" 34 36 … … 37 39 class _OrxonoxExport RadarObject 38 40 { 39 40 41 41 private: 42 Ogre::OverlayManager* om; // our one and only overlay manager 43 void init(); 42 44 43 44 45 46 45 public: 46 RadarObject(Ogre::OverlayContainer* container); 47 RadarObject(Ogre::OverlayContainer* container, Vector3 pos); 48 ~RadarObject(); 47 49 48 49 50 51 52 53 50 bool right_; 51 int index_; // index number of object 52 Vector3 pos_; // position in space 53 Ogre::OverlayContainer* container_; 54 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot 55 RadarObject* next; // next pointer of linked list 54 56 55 56 57 static int count; 58 }; 57 59 } 58 60 59 #endif 61 #endif /* _RadarObject_H__ */ -
code/branches/network/src/orxonox/hud/RadarOverlayElement.cc
r1408 r1410 29 29 #include "RadarOverlayElement.h" 30 30 31 #include <string .h>31 #include <string> 32 32 #include <OgreOverlayManager.h> 33 33 #include <OgreStringConverter.h> 34 #include <OgrePanelOverlayElement.h>35 34 36 35 #include "GraphicsEngine.h" … … 38 37 #include "core/ConsoleCommand.h" 39 38 #include "objects/SpaceShip.h" 39 #include "RadarObject.h" 40 40 #include "HUD.h" 41 41 42 42 namespace orxonox 43 43 { 44 45 44 using namespace Ogre; 46 45 … … 53 52 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){ 54 53 // some initial data 55 54 om = &OverlayManager::getSingleton(); 56 55 dimRel_ = dimRel; 57 56 leftRel_ = leftRel; … … 80 79 shipPos_ = SpaceShip::getLocalShip()->getPosition(); 81 80 currentDir_ = SpaceShip::getLocalShip()->getDir(); 82 81 currentOrth_ = SpaceShip::getLocalShip()->getOrth(); 83 82 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 84 83 // iterate through all RadarObjects 85 86 84 while(ro != NULL){ 85 // calc position on radar... 87 86 float radius = calcRadius(shipPos_, currentDir_, currentOrth_, ro); 88 87 float phi = calcPhi(shipPos_, currentDir_, currentOrth_, ro); … … 105 104 } 106 105 ro = ro->next; 107 106 } 108 107 } 109 108 110 111 112 113 114 115 116 117 118 119 109 void RadarOverlayElement::listObjects(){ 110 int i = 0; 111 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 112 COUT(3) << "List of RadarObjects:\n"; 113 // iterate through all Radar Objects 114 while(ro != NULL) { 115 COUT(3) << i++ << ": " << ro->pos_ << std::endl; 116 ro = ro->next; 117 } 118 } 120 119 121 122 123 124 120 float RadarOverlayElement::calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 121 return(acos((dir.dotProduct(obj->pos_ - pos))/ 122 ((obj->pos_ - pos).length()*dir.length()))); 123 } 125 124 126 127 128 129 130 131 (orth.length()*proj.length())));132 125 float RadarOverlayElement::calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 126 // project difference vector on our plane... 127 Vector3 proj = Plane(dir, pos).projectVector(obj->pos_ - pos); 128 // ...and find out the angle 129 return(acos((orth.dotProduct(proj))/ 130 (orth.length()*proj.length()))); 131 } 133 132 134 135 136 133 bool RadarOverlayElement::calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 134 if((dir.crossProduct(orth)).dotProduct(obj->pos_ - pos) > 0) 135 return true; 137 136 else return false; 138 137 } 139 138 } -
code/branches/network/src/orxonox/hud/RadarOverlayElement.h
r1408 r1410 26 26 */ 27 27 28 #ifndef _R ADAR_H__29 #define _R ADAR_H__28 #ifndef _RadarOverlayElement_H__ 29 #define _RadarOverlayElement_H__ 30 30 31 #include <util/Math.h> 31 #include "OrxonoxPrereqs.h" 32 32 33 #include <OgrePrerequisites.h> 33 34 #include <OgrePanelOverlayElement.h> 34 #include "../OrxonoxPrereqs.h" 35 #include "RadarObject.h" 35 #include "util/Math.h" 36 36 37 37 namespace orxonox … … 39 39 class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement 40 40 { 41 42 43 44 45 46 41 private: 42 Ogre::OverlayManager* om; // our one and only overlay manager 43 Ogre::OverlayContainer* container_; // pointer to the container we're in 44 Vector3 currentDir_; 45 Vector3 currentOrth_; 46 Vector3 shipPos_; // position of ship 47 47 48 49 50 int windowW_, windowH_;// absolute window dimensions48 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension 49 int left_, top_, dim_; // absolute position/dimension 50 int windowW_, windowH_; // absolute window dimensions 51 51 52 53 54 55 56 57 58 52 public: 53 RadarOverlayElement(const Ogre::String& name); 54 ~RadarOverlayElement(); 55 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 56 void resize(); 57 void update(); 58 void listObjects(); 59 59 60 61 62 63 60 static float calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 61 static float calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 62 static bool calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 63 }; 64 64 } 65 65 66 #endif 66 #endif /* _RadarOverlayElement_H__ */ -
code/branches/network/visual_studio/vc8/orxonox.vcproj
r1373 r1410 196 196 </File> 197 197 <File 198 RelativePath="..\..\src\orxonox\hud\Navigation.cc" 199 > 200 </File> 201 <File 198 202 RelativePath="..\..\src\orxonox\hud\RadarObject.cc" 199 203 > … … 467 471 <File 468 472 RelativePath="..\..\src\orxonox\hud\HUD.h" 473 > 474 </File> 475 <File 476 RelativePath="..\..\src\orxonox\hud\Navigation.h" 469 477 > 470 478 </File>
Note: See TracChangeset
for help on using the changeset viewer.