Changeset 1393 for code/trunk
- Timestamp:
- May 23, 2008, 6:40:19 PM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/bin/keybindings.ini
r1387 r1393 15 15 KeyEQUALS=activateConsole 16 16 KeyBACK= 17 KeyTAB=cycle RadarFocus17 KeyTAB=cycleNavigationFocus 18 18 KeyQ= 19 19 KeyW= -
code/trunk/src/orxonox/CMakeLists.txt
r1362 r1393 9 9 hud/RadarOverlayElement.cc 10 10 hud/RadarObject.cc 11 hud/Navigation.cc 11 12 particle/ParticleInterface.cc 12 13 tolua/tolua_bind.cc -
code/trunk/src/orxonox/hud/HUD.cc
r1392 r1393 43 43 namespace orxonox 44 44 { 45 ConsoleCommandShortcut(HUD, cycle RadarFocus, AccessLevel::User);45 ConsoleCommandShortcut(HUD, cycleNavigationFocus, AccessLevel::User); 46 46 47 47 using namespace Ogre; … … 49 49 HUD::HUD(){ 50 50 om = &Ogre::OverlayManager::getSingleton(); 51 firstRadarObject = NULL; 52 lastRadarObject = NULL; 51 53 52 54 // create Factories … … 86 88 radar->show(); 87 89 90 // create Navigation 91 nav = new Navigation(container); 92 88 93 // set up screen-wide container 89 94 container->show(); … … 98 103 container->addChild(test); 99 104 container->addChild(fpsText); 105 100 106 energyBar->init(0.01, 0.94, 0.4, container); 101 107 energyBar->setValue(1); 108 102 109 speedoBar->init(0.01, 0.90, 0.4, container); 110 103 111 radar->init(0.5, 0.9, 0.2, container); 104 radar->addObject(Vector3(2000.0, 1000.0, 1000.0));105 radar->addObject(Vector3(0.0, 4000.0, 0.0));106 radar->addObject(Vector3(0.0, 0.0, 6800.0));112 addRadarObject(Vector3(2000.0, 1000.0, 1000.0)); 113 addRadarObject(Vector3(0.0, 4000.0, 0.0)); 114 addRadarObject(Vector3(0.0, 0.0, 6800.0)); 107 115 } 108 116 … … 113 121 void HUD::tick(float dt) 114 122 { 115 int d = (float)( radar->getDist2Focus()/10);123 int d = (float)(nav->getDist2Focus()/10); 116 124 if(d) test->setCaption("Distance: " + Ogre::StringConverter::toString(d)); 117 125 else test->setCaption(""); … … 126 134 radar->resize(); 127 135 radar->update(); 136 137 nav->update(); 138 } 139 140 void HUD::addRadarObject(Vector3 pos){ 141 // check if this is the first RadarObject to create 142 if(firstRadarObject == NULL){ 143 firstRadarObject = new RadarObject(container, pos); 144 lastRadarObject = firstRadarObject; 145 } 146 else{ // if not, append to list 147 lastRadarObject->next = new RadarObject(container, pos); 148 lastRadarObject = lastRadarObject->next; 149 } 150 } 151 152 RadarObject* HUD::getFirstRadarObject(){ 153 return firstRadarObject; 128 154 } 129 155 … … 141 167 } 142 168 143 /*static*/void HUD::cycle RadarFocus(){144 HUD::getSingleton(). radar->cycleFocus();169 /*static*/void HUD::cycleNavigationFocus(){ 170 HUD::getSingleton().nav->cycleFocus(); 145 171 } 146 172 } -
code/trunk/src/orxonox/hud/HUD.h
r1392 r1393 36 36 #include "BarOverlayElement.h" 37 37 #include "RadarOverlayElement.h" 38 #include "Navigation.h" 39 #include "RadarObject.h" 38 40 39 41 … … 54 56 BarOverlayElement* speedoBar; 55 57 RadarOverlayElement* radar; 58 RadarObject* firstRadarObject; 59 RadarObject* lastRadarObject; 60 Navigation* nav; 56 61 57 62 public: 58 63 virtual void tick(float); 64 void addRadarObject(Vector3 pos); 65 RadarObject* getFirstRadarObject(); 59 66 60 67 static HUD* instance_s; … … 62 69 static void setFPS(float fps); 63 70 static void setEnergy(float value); 64 static void cycle RadarFocus();71 static void cycleNavigationFocus(); 65 72 }; 66 73 } -
code/trunk/src/orxonox/hud/RadarObject.cc
r1392 r1393 67 67 } 68 68 } 69 70 /* my local clipboard...71 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";72 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl;73 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";74 */ -
code/trunk/src/orxonox/hud/RadarObject.h
r1392 r1393 28 28 #ifndef _RADAR2_H__ 29 29 #define _RADAR2_H__ 30 31 30 #include <OgrePrerequisites.h> 32 31 #include "../OrxonoxPrereqs.h" -
code/trunk/src/orxonox/hud/RadarOverlayElement.cc
r1392 r1393 22 22 * Yuning Chai 23 23 * Co-authors: 24 * ...24 * Felix Schulthess 25 25 * 26 26 */ … … 37 37 #include "core/ConsoleCommand.h" 38 38 #include "objects/SpaceShip.h" 39 #include "HUD.h" 39 40 #include "RadarOverlayElement.h" 40 41 … … 57 58 topRel_ = topRel; 58 59 container_ = container; 59 firstRadarObject_ = NULL;60 lastRadarObject_ = NULL;61 focus_ = NULL;62 63 // create nav marker ...64 navMarker_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "NavMarker"));65 navMarker_->setMetricsMode(GMM_PIXELS);66 navMarker_->setMaterialName("Orxonox/NavMarker");67 navMarker_->setDimensions(16,16);68 navMarker_->setPosition(0,386);69 navMarker_->hide();70 container_->addChild(navMarker_);71 60 72 61 // these have to fit the data in the level … … 98 87 void RadarOverlayElement::update() { 99 88 shipPos_ = SpaceShip::instance_s->getPosition(); 100 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni....89 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; 101 90 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 102 91 plane = Plane(currentDir_, shipPos_); 103 104 RadarObject* ro = firstRadarObject_; 92 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 105 93 // iterate through all RadarObjects 106 94 while(ro != NULL){ … … 125 113 3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2); 126 114 } 115 listObjects(); 127 116 ro = ro->next; 128 117 } 129 updateNavMarker();130 118 } 131 132 void RadarOverlayElement::updateNavMarker(){133 if(focus_ == NULL) return;134 // from the angle we find out where to draw the marker135 // and which of the four arrows to take136 float r1 = atan((float)(windowW_)/(float)(windowH_));137 float phi = focus_->phi_;138 if(focus_->right_){139 if(phi<r1){140 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, 0);141 navMarker_->setUV(0.5, 0.0, 1.0, 0.5);142 }143 else if(phi>3.14-r1){144 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, windowH_-16);145 navMarker_->setUV(0.0, 0.5, 0.5, 1.0);146 }147 else {148 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2);149 navMarker_->setUV(0.5, 0.5, 1.0, 1.0);150 }151 }152 else{153 if(phi<r1) {154 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, 0);155 navMarker_->setUV(0.5, 0.0, 1.0, 0.5);156 }157 else if(phi>3.14-r1) {158 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, windowH_-16);159 navMarker_->setUV(0.0, 0.5, 0.5, 1.0);160 }161 else {162 navMarker_->setPosition(0, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2);163 navMarker_->setUV(0.0, 0.0, 0.5, 0.5);164 }165 }166 }167 168 void RadarOverlayElement::addObject(Vector3 pos){169 if(firstRadarObject_ == NULL){170 firstRadarObject_ = new RadarObject(container_, pos);171 lastRadarObject_ = firstRadarObject_;172 }173 else{174 lastRadarObject_->next = new RadarObject(container_, pos);175 lastRadarObject_ = lastRadarObject_->next;176 }177 }178 119 179 120 void RadarOverlayElement::listObjects(){ 180 121 int i = 0; 181 RadarObject* ro = firstRadarObject_;122 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 182 123 COUT(3) << "List of RadarObjects:\n"; 183 124 // iterate through all Radar Objects … … 186 127 ro = ro->next; 187 128 } 188 }189 190 float RadarOverlayElement::getDist2Focus(){191 if(focus_ == NULL) return(0.0);192 return((focus_->pos_-shipPos_).length());193 129 } 194 130 … … 211 147 else return false; 212 148 } 213 214 void RadarOverlayElement::cycleFocus(){215 if(focus_ == NULL){216 focus_ = firstRadarObject_;217 }218 else{219 focus_->panel_->setMaterialName("Orxonox/RedDot");220 focus_ = focus_->next;221 }222 223 if(focus_ == NULL){224 navMarker_->hide();225 }226 else{227 navMarker_->show();228 focus_->panel_->setMaterialName("Orxonox/WhiteDot");229 }230 }231 149 } 232 233 /* my local clipboard...234 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";235 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl;236 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";237 */ -
code/trunk/src/orxonox/hud/RadarOverlayElement.h
r1392 r1393 58 58 void resize(); 59 59 void update(); 60 void updateNavMarker();61 void addObject(Vector3 pos);62 60 void listObjects(); 63 void cycleFocus();64 float getDist2Focus();65 61 float calcRadius(RadarObject* obj); 66 62 float calcPhi(RadarObject* obj); 67 63 bool calcRight(RadarObject* obj); 68 69 Ogre::PanelOverlayElement* navMarker_; // marker to help navigating70 RadarObject* firstRadarObject_; // start of linked list71 RadarObject* lastRadarObject_; // end of linked list72 RadarObject* focus_; // object that is focussed73 64 }; 74 65 }
Note: See TracChangeset
for help on using the changeset viewer.