Changeset 1456
- Timestamp:
- May 28, 2008, 7:12:28 PM (17 years ago)
- Location:
- code/branches/network/src/orxonox/hud
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/hud/HUD.cc
r1454 r1456 31 31 32 32 #include <string> 33 #include <set> 33 34 #include <OgreOverlay.h> 34 35 #include <OgreOverlayContainer.h> … … 57 58 om = &Ogre::OverlayManager::getSingleton(); 58 59 sm = GraphicsEngine::getSingleton().getSceneManager(); 59 firstRadarObject = NULL;60 lastRadarObject = NULL;61 60 showFPS = true; 62 61 showRenderTime = true; … … 178 177 179 178 void HUD::addRadarObject(SceneNode* node, int colour){ 180 // check if this is the first RadarObject to create 181 if(firstRadarObject == NULL){ 182 firstRadarObject = new RadarObject(container, node, colour); 183 lastRadarObject = firstRadarObject; 184 } 185 else{ // if not, append to list 186 lastRadarObject->next = new RadarObject(container, node, colour); 187 lastRadarObject = lastRadarObject->next; 188 } 189 } 190 191 RadarObject* HUD::getFirstRadarObject(){ 192 return firstRadarObject; 179 RadarObject* obj = new RadarObject(container, node, colour); 180 roSet.insert(obj); 181 // // check if this is the first RadarObject to create 182 // if(firstRadarObject == NULL){ 183 // firstRadarObject = new RadarObject(container, node, colour); 184 // lastRadarObject = firstRadarObject; 185 // } 186 // else{ // if not, append to list 187 // lastRadarObject->next = new RadarObject(container, node, colour); 188 // lastRadarObject = lastRadarObject->next; 189 // } 190 } 191 192 void HUD::removeRadarObject(SceneNode* node){ 193 for(std::set<RadarObject*>::iterator it=roSet.begin(); it!=roSet.end(); it++){ 194 if((*it)->getNode() == node) { 195 delete (*it); 196 roSet.erase(it); 197 } 198 } 193 199 } 194 200 -
code/branches/network/src/orxonox/hud/HUD.h
r1454 r1456 56 56 BarOverlayElement* speedoBar; 57 57 RadarOverlayElement* radar; 58 RadarObject* firstRadarObject;59 RadarObject* lastRadarObject;60 58 Navigation* nav; 61 59 … … 66 64 virtual void tick(float); 67 65 void addRadarObject(Ogre::SceneNode* node, int colour = 0); 68 RadarObject* getFirstRadarObject();66 void removeRadarObject(Ogre::SceneNode* node); 69 67 void setRenderTimeRatio(float ratio); 70 68 void setFPS(); 69 70 std::set<RadarObject*> roSet; 71 71 72 72 static HUD* instance_s; -
code/branches/network/src/orxonox/hud/Navigation.cc
r1454 r1456 40 40 #include "RadarOverlayElement.h" 41 41 #include "HUD.h" 42 #include "core/Debug.h" 42 43 43 44 namespace orxonox … … 204 205 void Navigation::cycleFocus(){ 205 206 if(focus_ == NULL){ 206 focus_ = HUD::getSingleton().getFirstRadarObject(); 207 it_ = HUD::getSingleton().roSet.begin(); 208 focus_ = *it_; 207 209 } 208 210 else{ 209 211 focus_->resetColour(); 210 if(focus_ != NULL) focus_ = focus_->next; 211 } 212 212 if(it_ != HUD::getSingleton().roSet.end()){ 213 focus_ = *it_; 214 ++it_; 215 } 216 else focus_ = NULL; 217 } 213 218 if(focus_ == NULL){ 214 219 navMarker_->hide(); -
code/branches/network/src/orxonox/hud/Navigation.h
r1454 r1456 51 51 Vector3 currentDir_; 52 52 Vector3 currentOrth_; 53 std::set<RadarObject*>::iterator it_; 53 54 int windowW_, windowH_; 54 55 void init(); -
code/branches/network/src/orxonox/hud/RadarObject.cc
r1454 r1456 43 43 node_ = node; 44 44 colour_ = colour; 45 next = NULL;46 45 om = &OverlayManager::getSingleton(); 47 46 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", … … 57 56 58 57 RadarObject::~RadarObject(){ 59 // todo: clean up stuff58 delete panel_; 60 59 } 61 60 … … 78 77 return node_->getPosition(); 79 78 } 79 80 SceneNode* RadarObject::getNode(){ 81 return node_; 82 } 80 83 } 81 84 -
code/branches/network/src/orxonox/hud/RadarObject.h
r1454 r1456 51 51 void resetColour(); 52 52 Vector3 getPosition(); 53 Ogre::SceneNode* getNode(); 53 54 54 55 bool right_; … … 56 57 Ogre::OverlayContainer* container_; 57 58 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot 58 RadarObject* next; // next pointer of linked list59 59 60 60 static int count; -
code/branches/network/src/orxonox/hud/RadarOverlayElement.cc
r1454 r1456 81 81 currentDir_ = SpaceShip::getLocalShip()->getDir(); 82 82 currentOrth_ = SpaceShip::getLocalShip()->getOrth(); 83 RadarObject* ro = HUD::getSingleton().getFirstRadarObject();84 83 // iterate through all RadarObjects 85 while(ro != NULL){84 for(std::set<RadarObject*>::iterator it=HUD::getSingleton().roSet.begin(); it!=HUD::getSingleton().roSet.end(); it++){ 86 85 // calc position on radar... 87 float radius = calcRadius(shipPos_, currentDir_, currentOrth_, ro);88 float phi = calcPhi(shipPos_, currentDir_, currentOrth_, ro);89 bool right = calcRight(shipPos_, currentDir_, currentOrth_, ro);86 float radius = calcRadius(shipPos_, currentDir_, currentOrth_, (*it)); 87 float phi = calcPhi(shipPos_, currentDir_, currentOrth_, (*it)); 88 bool right = calcRight(shipPos_, currentDir_, currentOrth_, (*it)); 90 89 91 90 // set size to fit distance... 92 float d = ( ro->getPosition()-shipPos_).length();93 if(d<4000) ro->panel_->setDimensions(4,4);94 else if(d<8000) ro->panel_->setDimensions(3,3);95 else if(d<16000) ro->panel_->setDimensions(2,2);96 else ro->panel_->setDimensions(1,1);91 float d = ((*it)->getPosition()-shipPos_).length(); 92 if(d<4000) (*it)->panel_->setDimensions(4,4); 93 else if(d<8000) (*it)->panel_->setDimensions(3,3); 94 else if(d<16000) (*it)->panel_->setDimensions(2,2); 95 else (*it)->panel_->setDimensions(1,1); 97 96 98 97 if (right){ 99 ro->panel_->setPosition(sin(phi)*radius/98 (*it)->panel_->setPosition(sin(phi)*radius/ 100 99 3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2); 101 100 } 102 101 else { 103 ro->panel_->setPosition(-sin(phi)*radius/102 (*it)->panel_->setPosition(-sin(phi)*radius/ 104 103 3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2); 105 104 } 106 ro = ro->next;107 105 } 108 106 } … … 110 108 void RadarOverlayElement::listObjects(){ 111 109 int i = 0; 112 RadarObject* ro = HUD::getSingleton().getFirstRadarObject();113 110 COUT(3) << "List of RadarObjects:\n"; 114 111 // iterate through all Radar Objects 115 while(ro != NULL) { 116 COUT(3) << i++ << ": " << ro->getPosition() << std::endl; 117 ro = ro->next; 112 for(std::set<RadarObject*>::iterator it=HUD::getSingleton().roSet.begin(); it!=HUD::getSingleton().roSet.end(); it++){ 113 COUT(3) << i++ << ": " << (*it)->getPosition() << std::endl; 118 114 } 119 115 }
Note: See TracChangeset
for help on using the changeset viewer.