Changeset 1406
- Timestamp:
- May 24, 2008, 1:39:05 PM (17 years ago)
- Location:
- code/branches/network
- Files:
-
- 15 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/bin/keybindings.ini
- Property svn:eol-style set to native
r1397 r1406 1 1 [KeyBinder] 2 KeyUNASSIGNED= 2 KeyUNASSIGNED=activateConsole 3 3 KeyESCAPE=exit 4 4 Key1= … … 15 15 KeyEQUALS=activateConsole 16 16 KeyBACK= 17 KeyTAB= 17 KeyTAB=cycleNavigationFocus 18 18 KeyQ=moveRoll 19 19 KeyW=moveLongitudinal … … 147 147 KeyMEDIASELECT= 148 148 MouseLeft=fire 149 MouseRight= fire150 MouseMiddle= fire151 MouseButton3= fire152 MouseButton4= fire153 MouseButton5= fire154 MouseButton6= fire155 MouseButton7= fire156 MouseWheel1Up= scale 0.1 slomo157 MouseWheel1Down= scale 0.1 slomo149 MouseRight= 150 MouseMiddle= 151 MouseButton3= 152 MouseButton4= 153 MouseButton5= 154 MouseButton6= 155 MouseButton7= 156 MouseWheel1Up= 157 MouseWheel1Down= 158 158 MouseWheel2Up= 159 159 MouseWheel2Down= … … 214 214 JoyAxis24Pos= 215 215 JoyAxis24Neg= 216 JoyButton0=cycle Focus216 JoyButton0=cycleNavigationFocus 217 217 JoyButton1= 218 218 JoyButton2= -
code/branches/network/bin/levels/sample.oxw
r1362 r1406 10 10 11 11 <!--Ambient colourvalue="1,1,1" /--> 12 <Skybox src="Orxonox/Star SkyBox" />12 <Skybox src="Orxonox/Starbox" /> 13 13 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" /> 14 <Model position=" 1500,0,100" scale="10" mesh="tomato.mesh" yawpitchroll="-40,30,0" rotationAxis="1,0,0" rotationRate="-30"/>15 <Model position="0, 4200,0" scale="10" mesh="tomato.mesh" yawpitchroll="-50,60,0" rotationAxis="1,0,0" rotationRate="-30"/>16 <Model position="0,0, 6800" scale="10" mesh="tomato.mesh" yawpitchroll="-50,-30,0" rotationAxis="1,0,0" rotationRate="-30"/>14 <Model position="2000,0,0" scale="10" mesh="tomato.mesh" yawpitchroll="-40,30,0" rotationAxis="1,0,0" rotationRate="-30"/> 15 <Model position="0,2000,0" scale="10" mesh="tomato.mesh" yawpitchroll="-50,60,0" rotationAxis="1,0,0" rotationRate="-30"/> 16 <Model position="0,0,2000" scale="10" mesh="tomato.mesh" yawpitchroll="-50,-30,0" rotationAxis="1,0,0" rotationRate="-30"/> 17 17 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/> 18 18 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/> -
code/branches/network/src/orxonox/CMakeLists.txt
r1362 r1406 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/branches/network/src/orxonox/Orxonox.cc
r1391 r1406 181 181 { 182 182 // keep in mind: the order of deletion is very important! 183 if (this->orxonoxHUD_)184 delete this->orxonoxHUD_;183 // if (this->orxonoxHUD_) 184 // delete this->orxonoxHUD_; 185 185 Loader::close(); 186 186 InputManager::destroy(); … … 350 350 // Load the HUD 351 351 COUT(3) << "Orxonox: Loading HUD..." << std::endl; 352 orxonoxHUD_ = new HUD(1);352 orxonoxHUD_ = &HUD::getSingleton(); 353 353 354 354 COUT(3) << "Orxonox: Loading Console..." << std::endl; … … 490 490 // orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber()); 491 491 if (eventTimes[3].back() - eventTimes[3].front() != 0) 492 // orxonoxHUD_->setRocket1((int)(50000.0f/(eventTimes[3].back() - eventTimes[3].front())));492 HUD::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
r1373 r1406 28 28 #include "OrxonoxStableHeaders.h" 29 29 #include <OgreOverlayManager.h> 30 #include <OgreOverlayElement.h>31 #include <OgrePanelOverlayElement.h>32 30 #include "GraphicsEngine.h" 33 31 #include "BarOverlayElement.h" … … 37 35 using namespace Ogre; 38 36 39 BarOverlayElement::BarOverlayElement(const String& name): Ogre::PanelOverlayElement(name){37 BarOverlayElement::BarOverlayElement(const String& name):PanelOverlayElement(name){ 40 38 name_ = name; 41 39 } … … 43 41 BarOverlayElement::~BarOverlayElement(){} 44 42 45 void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, O gre::OverlayContainer* container){43 void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){ 46 44 // init some values... 47 45 container_ = container; 48 om = &O gre::OverlayManager::getSingleton();46 om = &OverlayManager::getSingleton(); 49 47 value_ = 0; 50 48 color_ = 2; … … 54 52 topRel_ = topRel; 55 53 dimRel_ = dimRel; 56 54 57 55 // create background... 58 56 background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container")); 59 57 background_->show(); 60 58 container_->addChild(background_); 61 background_->setMetricsMode( Ogre::GMM_PIXELS);59 background_->setMetricsMode(GMM_PIXELS); 62 60 background_->setMaterialName("Orxonox/BarBackground"); 63 61 … … 66 64 67 65 show(); 68 setMetricsMode( Ogre::GMM_PIXELS);66 setMetricsMode(GMM_PIXELS); 69 67 setMaterialName("Orxonox/Green"); 70 68 background_->addChild(this); -
code/branches/network/src/orxonox/hud/BarOverlayElement.h
r1362 r1406 30 30 #define _BAR_H__ 31 31 32 #include <OgreOverlayManager.h> 33 #include <OgreOverlayElement.h> 32 34 33 #include <OgrePanelOverlayElement.h> 35 36 34 #include <OgrePrerequisites.h> 37 35 #include "../OrxonoxPrereqs.h" 38 39 40 36 41 37 namespace orxonox -
code/branches/network/src/orxonox/hud/HUD.cc
r1385 r1406 26 26 */ 27 27 28 28 #include <string.h> 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include <OgreOverlay.h> 31 31 #include <OgreOverlayContainer.h> 32 32 #include <OgreOverlayManager.h> 33 #include <OgreSceneNode.h>34 #include <OgreEntity.h>35 33 #include <OgreStringConverter.h> 34 36 35 #include "core/Debug.h" 36 #include "core/ConsoleCommand.h" 37 37 #include "objects/SpaceShip.h" 38 #include "HUD.h"39 38 #include "BarOverlayElement.h" 40 39 #include "RadarOverlayElement.h" 41 40 #include "OverlayElementFactories.h" 41 #include "HUD.h" 42 42 43 43 namespace orxonox 44 44 { 45 ConsoleCommandShortcut(HUD, cycleNavigationFocus, AccessLevel::User); 46 45 47 using namespace Ogre; 46 48 47 HUD::HUD( int zoom){49 HUD::HUD(){ 48 50 om = &Ogre::OverlayManager::getSingleton(); 51 firstRadarObject = NULL; 52 lastRadarObject = NULL; 49 53 50 54 // create Factories … … 56 60 orxonoxHUD = om->create("Orxonox/HUD"); 57 61 container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container")); 58 // test 59 test = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "test123")); 60 test->show(); 61 test->setMetricsMode(Ogre::GMM_RELATIVE); 62 test->setDimensions(0.8, 0.8); 63 test->setPosition(0.02, 0.02); 64 test->setFontName("Console"); 65 test->setCaption("init"); 62 63 // creating text to display fps 64 fpsText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "fpsText")); 65 fpsText->show(); 66 fpsText->setMetricsMode(Ogre::GMM_PIXELS); 67 fpsText->setDimensions(0.001, 0.001); 68 fpsText->setPosition(10, 10); 69 fpsText->setFontName("Console"); 70 fpsText->setCharHeight(20); 71 fpsText->setCaption("init"); 66 72 67 73 // create energy bar … … 75 81 radar->show(); 76 82 83 // create Navigation 84 nav = new Navigation(container); 85 77 86 // set up screen-wide container 78 87 container->show(); … … 85 94 container->setHeight(1.0); 86 95 container->setMetricsMode(Ogre::GMM_RELATIVE); 87 container->addChild(test); 96 container->addChild(fpsText); 97 88 98 energyBar->init(0.01, 0.94, 0.4, container); 89 99 energyBar->setValue(1); 100 90 101 speedoBar->init(0.01, 0.90, 0.4, container); 102 91 103 radar->init(0.5, 0.9, 0.2, container); 92 radar->addObject(Vector3(1500.0, 0.0, 100.0)); 93 radar->addObject(Vector3(0.0, 4000.0, 0.0)); 94 radar->addObject(Vector3(0.0, 0.0, 6800.0)); 95 RadarOverlayElement::cycleFocus(); 104 addRadarObject(Vector3(2000.0, 0.0, 0.0)); 105 addRadarObject(Vector3(0.0, 2000.0, 0.0)); 106 addRadarObject(Vector3(0.0, 0.0, 2000.0)); 107 } 108 109 HUD::~HUD(){ 110 //todo: clean up objects 96 111 } 97 112 98 113 void HUD::tick(float dt) 99 114 { 100 int d = radar->getDist2Focus()/10;101 if(d) test->setCaption("Distance: " + Ogre::StringConverter::toString(d));102 else test->setCaption("");103 104 115 energyBar->resize(); 105 116 … … 113 124 radar->resize(); 114 125 radar->update(); 126 127 nav->update(); 115 128 } 116 129 117 HUD::~HUD(void){ 130 void HUD::addRadarObject(Vector3 pos){ 131 // check if this is the first RadarObject to create 132 if(firstRadarObject == NULL){ 133 firstRadarObject = new RadarObject(container, pos); 134 lastRadarObject = firstRadarObject; 135 } 136 else{ // if not, append to list 137 lastRadarObject->next = new RadarObject(container, pos); 138 lastRadarObject = lastRadarObject->next; 139 } 140 } 141 142 RadarObject* HUD::getFirstRadarObject(){ 143 return firstRadarObject; 144 } 145 146 /*static*/HUD& HUD::getSingleton(){ 147 static HUD theInstance; 148 return theInstance; 149 } 150 151 /*static*/void HUD::setFPS(float fps){ 152 HUD::getSingleton().fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 153 } 154 155 /*static*/void HUD::setEnergy(float value){ 156 HUD::getSingleton().energyBar->setValue(value); 157 } 158 159 /*static*/void HUD::cycleNavigationFocus(){ 160 HUD::getSingleton().nav->cycleFocus(); 118 161 } 119 162 } -
code/branches/network/src/orxonox/hud/HUD.h
r1362 r1406 30 30 #define _HUD_H__ 31 31 32 #include <string.h> 33 #include <OgreOverlayElement.h> 32 #include <OgrePrerequisites.h> 34 33 #include <OgreTextAreaOverlayElement.h> 35 #include <OgrePrerequisites.h>36 37 34 #include "OrxonoxPrereqs.h" 38 35 #include "core/Tickable.h" 39 36 #include "BarOverlayElement.h" 40 37 #include "RadarOverlayElement.h" 38 #include "Navigation.h" 39 #include "RadarObject.h" 41 40 42 41 … … 46 45 { 47 46 private: 47 HUD(); 48 HUD(HUD& instance); 49 ~HUD(); 48 50 Ogre::OverlayManager* om; 49 51 Ogre::Overlay* orxonoxHUD; 50 52 Ogre::OverlayContainer* container; 51 Ogre::TextAreaOverlayElement* test;53 Ogre::TextAreaOverlayElement* fpsText; 52 54 BarOverlayElement* energyBar; 53 55 BarOverlayElement* speedoBar; 54 56 RadarOverlayElement* radar; 57 RadarObject* firstRadarObject; 58 RadarObject* lastRadarObject; 59 Navigation* nav; 55 60 56 61 public: 57 HUD(int zoom);58 ~HUD();59 62 virtual void tick(float); 63 void addRadarObject(Vector3 pos); 64 RadarObject* getFirstRadarObject(); 60 65 66 static HUD* instance_s; 67 static HUD& getSingleton(); 68 static void setFPS(float fps); 69 static void setEnergy(float value); 70 static void cycleNavigationFocus(); 61 71 }; 62 72 } -
code/branches/network/src/orxonox/hud/RadarObject.cc
r1373 r1406 29 29 #include "RadarObject.h" 30 30 31 #include <string.h> 32 #include <OgreOverlayManager.h> 33 #include <OgrePanelOverlayElement.h> 34 #include <OgreStringConverter.h> 35 #include <util/Math.h> 36 31 37 namespace orxonox 32 38 { … … 35 41 int RadarObject::count = 0; // initialize static variable 36 42 37 RadarObject::RadarObject(O gre::OverlayContainer* container){43 RadarObject::RadarObject(OverlayContainer* container){ 38 44 container_ = container; 39 45 pos_ = Vector3(0.0, 0.0, 0.0); … … 41 47 } 42 48 43 RadarObject::RadarObject(O gre::OverlayContainer* container, Vector3 pos){49 RadarObject::RadarObject(OverlayContainer* container, Vector3 pos){ 44 50 container_ = container; 45 51 pos_ = pos; … … 51 57 void RadarObject::init(){ 52 58 next = NULL; 53 om = &O gre::OverlayManager::getSingleton();59 om = &OverlayManager::getSingleton(); 54 60 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 55 "Object"+ Ogre::StringConverter::toString(count)));61 "Object"+StringConverter::toString(count))); 56 62 panel_->setMaterialName("Orxonox/RedDot"); 57 63 panel_->setDimensions(3,3); … … 63 69 } 64 70 } 65 66 /* my local clipboard...67 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";68 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl;69 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";70 */ -
code/branches/network/src/orxonox/hud/RadarObject.h
r1362 r1406 28 28 #ifndef _RADAR2_H__ 29 29 #define _RADAR2_H__ 30 31 #include <string.h>32 30 #include <OgrePrerequisites.h> 33 #include <OgreOverlayManager.h>34 #include <OgreOverlayElement.h>35 #include <OgrePanelOverlayElement.h>36 #include <OgreStringConverter.h>37 38 #include <util/Math.h>39 31 #include "../OrxonoxPrereqs.h" 40 32 … … 55 47 int index_; // index number of object 56 48 Vector3 pos_; // position in space 57 Ogre::Real radius_, phi_; // position on radar58 49 Ogre::OverlayContainer* container_; 59 50 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot -
code/branches/network/src/orxonox/hud/RadarOverlayElement.cc
r1384 r1406 22 22 * Yuning Chai 23 23 * Co-authors: 24 * ...24 * Felix Schulthess 25 25 * 26 26 */ … … 29 29 #include "RadarOverlayElement.h" 30 30 31 #include <string.h> 32 #include <OgreOverlayManager.h> 33 #include <OgreStringConverter.h> 34 #include <OgrePanelOverlayElement.h> 35 36 #include "GraphicsEngine.h" 37 #include "core/Tickable.h" 38 #include "core/ConsoleCommand.h" 39 #include "objects/SpaceShip.h" 40 #include "HUD.h" 41 31 42 namespace orxonox 32 43 { 33 ConsoleCommandShortcut(RadarOverlayElement, cycleFocus, AccessLevel::User);34 44 35 45 using namespace Ogre; 36 46 37 RadarOverlayElement* RadarOverlayElement::instance_s = NULL; 38 39 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 40 RadarOverlayElement::instance_s = this; 47 RadarOverlayElement::RadarOverlayElement(const String& name):PanelOverlayElement(name){ 41 48 } 42 49 … … 44 51 } 45 52 46 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, O gre::OverlayContainer* container){53 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){ 47 54 // some initial data 48 om = &O gre::OverlayManager::getSingleton();55 om = &OverlayManager::getSingleton(); 49 56 dimRel_ = dimRel; 50 57 leftRel_ = leftRel; 51 58 topRel_ = topRel; 52 59 container_ = container; 53 firstRadarObject_ = NULL;54 lastRadarObject_ = NULL;55 focus_ = NULL;56 60 57 // create nav marker ... 58 navMarker_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "NavMarker")); 59 navMarker_->setMetricsMode(Ogre::GMM_PIXELS); 60 navMarker_->setMaterialName("Orxonox/NavMarker"); 61 navMarker_->setDimensions(16,16); 62 navMarker_->setPosition(0,386); 63 navMarker_->hide(); 64 container_->addChild(navMarker_); 65 66 // these have to fit the data in the level 67 shipPos_ = Vector3(0.0, 0.0, 0.0); 68 initialDir_ = Vector3(1.0, 0.0, 0.0); 69 currentDir_ = initialDir_; 70 initialOrth_ = Vector3(0.0, 0.0, 1.0); 71 currentOrth_ = initialOrth_; 72 plane = Plane(currentDir_, shipPos_); 73 74 setMetricsMode(Ogre::GMM_PIXELS); 61 setMetricsMode(GMM_PIXELS); 75 62 setMaterialName("Orxonox/Radar"); 76 63 resize(); … … 91 78 92 79 void RadarOverlayElement::update() { 80 <<<<<<< .working 93 81 shipPos_ = SpaceShip::getLocalShip()->getPosition(); 94 82 currentDir_ = SpaceShip::getLocalShip()->getOrientation()*initialDir_; // according to beni.... … … 97 85 98 86 RadarObject* ro = firstRadarObject_; 87 ======= 88 shipPos_ = SpaceShip::getLocalShip()->getPosition(); 89 currentDir_ = SpaceShip::getLocalShip()->getDir(); 90 currentOrth_ = SpaceShip::getLocalShip()->getOrth(); 91 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 92 >>>>>>> .merge-right.r1401 99 93 // iterate through all RadarObjects 100 94 while(ro != NULL){ 101 95 // calc position on radar... 102 ro->radius_ = calcRadius(ro);103 ro->phi_ = calcPhi(ro);104 ro->right_ = calcRight(ro);96 float radius = calcRadius(shipPos_, currentDir_, currentOrth_, ro); 97 float phi = calcPhi(shipPos_, currentDir_, currentOrth_, ro); 98 bool right = calcRight(shipPos_, currentDir_, currentOrth_, ro); 105 99 106 100 // set size to fit distance... … … 111 105 else ro->panel_->setDimensions(1,1); 112 106 113 if (r o->right_){114 ro->panel_->setPosition(sin( ro->phi_)*ro->radius_/115 3.5*dim_/2+dim_/2+left_-2,-cos( ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2);107 if (right){ 108 ro->panel_->setPosition(sin(phi)*radius/ 109 3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2); 116 110 } 117 111 else { 118 ro->panel_->setPosition(-sin( ro->phi_)*ro->radius_/119 3.5*dim_/2+dim_/2+left_-2,-cos( ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2);112 ro->panel_->setPosition(-sin(phi)*radius/ 113 3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2); 120 114 } 121 115 ro = ro->next; 122 116 } 123 updateNavMarker();124 117 } 125 126 void RadarOverlayElement::updateNavMarker(){127 if(focus_ == NULL) return;128 // from the angle we find out where to draw the marker129 // and which of the four arrows to take130 float r1 = atan((float)(windowW_)/(float)(windowH_));131 float phi = focus_->phi_;132 if(focus_->right_){133 if(phi<r1){134 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, 0);135 navMarker_->setUV(0.5, 0.0, 1.0, 0.5);136 }137 else if(phi>3.14-r1){138 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, windowH_-16);139 navMarker_->setUV(0.0, 0.5, 0.5, 1.0);140 }141 else {142 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2);143 navMarker_->setUV(0.5, 0.5, 1.0, 1.0);144 }145 }146 else{147 if(phi<r1) {148 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, 0);149 navMarker_->setUV(0.5, 0.0, 1.0, 0.5);150 }151 else if(phi>3.14-r1) {152 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, windowH_-16);153 navMarker_->setUV(0.0, 0.5, 0.5, 1.0);154 }155 else {156 navMarker_->setPosition(0, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2);157 navMarker_->setUV(0.0, 0.0, 0.5, 0.5);158 }159 }160 }161 162 void RadarOverlayElement::addObject(Vector3 pos){163 if(firstRadarObject_ == NULL){164 firstRadarObject_ = new RadarObject(container_, pos);165 lastRadarObject_ = firstRadarObject_;166 }167 else{168 lastRadarObject_->next = new RadarObject(container_, pos);169 lastRadarObject_ = lastRadarObject_->next;170 }171 }172 118 173 119 void RadarOverlayElement::listObjects(){ 174 120 int i = 0; 175 RadarObject* ro = firstRadarObject_;121 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 176 122 COUT(3) << "List of RadarObjects:\n"; 177 123 // iterate through all Radar Objects … … 182 128 } 183 129 184 float RadarOverlayElement:: getDist2Focus(){185 if(focus_ == NULL) return(0.0);186 return((focus_->pos_-shipPos_).length());130 float RadarOverlayElement::calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 131 return(acos((dir.dotProduct(obj->pos_ - pos))/ 132 ((obj->pos_ - pos).length()*dir.length()))); 187 133 } 188 134 189 float RadarOverlayElement::calcRadius(RadarObject* obj){ 190 return(acos((currentDir_.dotProduct(obj->pos_ - shipPos_))/ 191 ((obj->pos_ - shipPos_).length()*currentDir_.length()))); 135 float RadarOverlayElement::calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 136 // project difference vector on our plane... 137 Vector3 proj = Plane(dir, pos).projectVector(obj->pos_ - pos); 138 // ...and find out the angle 139 return(acos((orth.dotProduct(proj))/ 140 (orth.length()*proj.length()))); 192 141 } 193 142 194 float RadarOverlayElement::calcPhi(RadarObject* obj){ 195 // project difference vector on our plane... 196 Ogre::Vector3 proj = plane.projectVector(obj->pos_ - shipPos_); 197 // ...and find out the angle 198 return(acos((currentOrth_.dotProduct(proj))/ 199 (currentOrth_.length()*proj.length()))); 200 } 201 202 bool RadarOverlayElement::calcRight(RadarObject* obj){ 203 if((currentDir_.crossProduct(currentOrth_)).dotProduct(obj->pos_ - shipPos_) > 0) 143 bool RadarOverlayElement::calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 144 if((dir.crossProduct(orth)).dotProduct(obj->pos_ - pos) > 0) 204 145 return true; 205 146 else return false; 206 147 } 207 208 /*static*/void RadarOverlayElement::cycleFocus(){209 if(RadarOverlayElement::instance_s == NULL) return;210 211 if(RadarOverlayElement::instance_s->focus_ == NULL){212 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->firstRadarObject_;213 }214 else{215 RadarOverlayElement::instance_s->focus_->panel_->setMaterialName("Orxonox/RedDot");216 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->focus_->next;217 }218 219 if(RadarOverlayElement::instance_s->focus_ == NULL){220 RadarOverlayElement::instance_s->navMarker_->hide();221 }222 else{223 RadarOverlayElement::instance_s->navMarker_->show();224 RadarOverlayElement::instance_s->focus_->panel_->setMaterialName("Orxonox/WhiteDot");225 }226 }227 148 } 228 229 /* my local clipboard...230 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";231 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl;232 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";233 */ -
code/branches/network/src/orxonox/hud/RadarOverlayElement.h
r1362 r1406 29 29 #define _RADAR_H__ 30 30 31 #include <string.h> 32 #include <OgreOverlayManager.h> 33 #include <OgreStringConverter.h> 34 #include <OgreOverlayElement.h> 35 #include <OgrePanelOverlayElement.h> 31 #include <util/Math.h> 36 32 #include <OgrePrerequisites.h> 37 38 #include <util/Math.h>39 #include <string.h>40 #include "core/Tickable.h"41 #include "core/ConsoleCommand.h"42 #include "objects/SpaceShip.h"43 33 #include "../OrxonoxPrereqs.h" 44 34 #include "RadarObject.h" 45 #include "GraphicsEngine.h"46 35 47 36 namespace orxonox … … 52 41 Ogre::OverlayManager* om; // our one and only overlay manager 53 42 Ogre::OverlayContainer* container_; // pointer to the container we're in 54 Vector3 initialDir_; // direction of nose55 43 Vector3 currentDir_; 56 Vector3 initialOrth_; // direction of normal57 44 Vector3 currentOrth_; 58 45 Vector3 shipPos_; // position of ship 59 Ogre::Plane plane; // plane perpendicular to dir60 46 61 47 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension … … 69 55 void resize(); 70 56 void update(); 71 void updateNavMarker();72 void addObject(Vector3 pos);73 57 void listObjects(); 74 float getDist2Focus();75 float calcRadius(RadarObject* obj);76 float calcPhi(RadarObject* obj);77 bool calcRight(RadarObject* obj);78 58 79 Ogre::PanelOverlayElement* navMarker_; // marker to help navigating 80 RadarObject* firstRadarObject_; // start of linked list 81 RadarObject* lastRadarObject_; // end of linked list 82 RadarObject* focus_; // object that is focussed 83 84 static RadarOverlayElement* instance_s; 85 static void cycleFocus(); 59 static float calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 60 static float calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 61 static bool calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 86 62 }; 87 63 } -
code/branches/network/src/orxonox/objects/Camera.h
r1293 r1406 50 50 void setTargetNode(Ogre::SceneNode* obj); 51 51 52 Ogre::Camera* cam_; 53 52 54 void tick(float dt); 53 55 void update(); … … 63 65 Ogre::SceneNode* cameraNode_; 64 66 Ogre::Vector3 oldPos; 65 Ogre::Camera* cam_;66 67 bool bHasFocus_; 67 68 }; -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r1398 r1406 75 75 return NULL; 76 76 } 77 77 78 78 SpaceShip::SpaceShip() : 79 79 //testvector_(0,0,0), … … 118 118 this->setConfigValues(); 119 119 120 initialDir_ = Vector3(1.0, 0.0, 0.0); 121 currentDir_ = initialDir_; 122 initialOrth_ = Vector3(0.0, 0.0, 1.0); 123 currentOrth_ = initialOrth_; 120 124 121 125 this->setRotationAxis(1, 0, 0); … … 233 237 CameraHandler::getInstance()->requestFocus(cam_); 234 238 239 } 240 241 Camera* SpaceShip::getCamera(){ 242 return cam_; 235 243 } 236 244 … … 318 326 } 319 327 328 Vector3 SpaceShip::getDir() { 329 return currentDir_; 330 } 331 332 Vector3 SpaceShip::getOrth(){ 333 return currentOrth_; 334 } 335 320 336 float SpaceShip::getMaxSpeed() { return maxSpeed_; } 321 337 322 338 void SpaceShip::tick(float dt) 323 339 { 340 currentDir_ = getOrientation()*initialDir_; 341 currentOrth_ = getOrientation()*initialOrth_; 342 324 343 if (this->cam_) 325 344 this->cam_->tick(dt); … … 341 360 if (this->bLMousePressed_ && this->timeToReload_ <= 0) 342 361 { 343 362 344 363 Projectile *p = new Projectile(this); 345 364 346 365 p->setBacksync(true); 347 366 this->timeToReload_ = this->reloadTime_; -
code/branches/network/src/orxonox/objects/SpaceShip.h
r1398 r1406 44 44 { 45 45 public: 46 46 47 47 static SpaceShip *getLocalShip(); 48 48 49 49 SpaceShip(); 50 50 ~SpaceShip(); … … 64 64 void setTransDamp(float value); 65 65 void setRotDamp(float value); 66 void getFocus(); 66 67 67 void getFocus();68 static Vector3 getSPosition();69 static Quaternion getSOrientation();70 68 static std::string whereAmI(); 71 69 static void setMaxSpeedTest(float value) … … 80 78 81 79 float getMaxSpeed(); 80 Vector3 getDir(); 81 Vector3 getOrth(); 82 Camera* getCamera(); 82 83 83 84 private: … … 85 86 86 87 Vector3 testvector_; 88 Vector3 initialDir_; 89 Vector3 currentDir_; 90 Vector3 initialOrth_; 91 Vector3 currentOrth_; 87 92 bool bInvertYAxis_; 88 93 bool setMouseEventCallback_;
Note: See TracChangeset
for help on using the changeset viewer.