- Timestamp:
- May 24, 2008, 1:49:54 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/bin/keybindings.ini
r1393 r1407 1 1 [KeyBinder] 2 KeyUNASSIGNED= activateConsole3 KeyESCAPE= exit2 KeyUNASSIGNED= 3 KeyESCAPE= exit 4 4 Key1= 5 5 Key2= … … 15 15 KeyEQUALS=activateConsole 16 16 KeyBACK= 17 KeyTAB= cycleNavigationFocus17 KeyTAB= 18 18 KeyQ= 19 19 KeyW= … … 154 154 MouseButton6= 155 155 MouseButton7= 156 MouseWheel1Up= 157 MouseWheel1Down= 156 MouseWheel1Up=AxisAmp 0.1 slomo 157 MouseWheel1Down=AxisAmp 0.1 slomo 158 158 MouseWheel2Up= 159 159 MouseWheel2Down= -
code/trunk/bin/levels/sample.oxw
r1400 r1407 10 10 11 11 <!--Ambient colourvalue="1,1,1" /--> 12 <Skybox src="Orxonox/Star box" />12 <Skybox src="Orxonox/StarSkyBox" /> 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=" 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"/>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"/> 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/trunk/src/orxonox/CMakeLists.txt
r1393 r1407 9 9 hud/RadarOverlayElement.cc 10 10 hud/RadarObject.cc 11 hud/Navigation.cc12 11 particle/ParticleInterface.cc 13 12 tolua/tolua_bind.cc -
code/trunk/src/orxonox/Orxonox.cc
r1387 r1407 180 180 { 181 181 // keep in mind: the order of deletion is very important! 182 //if (this->orxonoxHUD_)183 //delete this->orxonoxHUD_;182 if (this->orxonoxHUD_) 183 delete this->orxonoxHUD_; 184 184 Loader::close(); 185 185 InputManager::destroy(); … … 348 348 // Load the HUD 349 349 COUT(3) << "Orxonox: Loading HUD..." << std::endl; 350 orxonoxHUD_ = &HUD::getSingleton();350 orxonoxHUD_ = new HUD(1); 351 351 352 352 COUT(3) << "Orxonox: Loading Console..." << std::endl; … … 487 487 // orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber()); 488 488 if (eventTimes[3].back() - eventTimes[3].front() != 0) 489 HUD::setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front()));489 // orxonoxHUD_->setRocket1((int)(50000.0f/(eventTimes[3].back() - eventTimes[3].front()))); 490 490 491 491 // Iterate through all Tickables and call their tick(dt) function -
code/trunk/src/orxonox/hud/BarOverlayElement.cc
r1392 r1407 27 27 28 28 #include <OgreOverlayManager.h> 29 #include <OgreOverlayElement.h> 30 #include <OgrePanelOverlayElement.h> 29 31 #include "GraphicsEngine.h" 30 32 #include "BarOverlayElement.h" … … 34 36 using namespace Ogre; 35 37 36 BarOverlayElement::BarOverlayElement(const String& name): PanelOverlayElement(name){38 BarOverlayElement::BarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 37 39 name_ = name; 38 40 } … … 40 42 BarOverlayElement::~BarOverlayElement(){} 41 43 42 void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, O verlayContainer* container){44 void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){ 43 45 // init some values... 44 46 container_ = container; 45 om = &O verlayManager::getSingleton();47 om = &Ogre::OverlayManager::getSingleton(); 46 48 value_ = 0; 47 49 color_ = 2; … … 51 53 topRel_ = topRel; 52 54 dimRel_ = dimRel; 53 55 54 56 // create background... 55 57 background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container")); 56 58 background_->show(); 57 59 container_->addChild(background_); 58 background_->setMetricsMode( GMM_PIXELS);60 background_->setMetricsMode(Ogre::GMM_PIXELS); 59 61 background_->setMaterialName("Orxonox/BarBackground"); 60 62 … … 63 65 64 66 show(); 65 setMetricsMode( GMM_PIXELS);67 setMetricsMode(Ogre::GMM_PIXELS); 66 68 setMaterialName("Orxonox/Green"); 67 69 background_->addChild(this); -
code/trunk/src/orxonox/hud/BarOverlayElement.h
r1392 r1407 30 30 #define _BAR_H__ 31 31 32 #include <OgreOverlayManager.h> 33 #include <OgreOverlayElement.h> 34 #include <OgrePanelOverlayElement.h> 32 35 33 #include <OgrePanelOverlayElement.h>34 36 #include <OgrePrerequisites.h> 35 37 #include "../OrxonoxPrereqs.h" 38 39 36 40 37 41 namespace orxonox -
code/trunk/src/orxonox/hud/HUD.cc
r1400 r1407 26 26 */ 27 27 28 #include <string.h> 28 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> 33 35 #include <OgreStringConverter.h> 34 35 36 #include "core/Debug.h" 36 #include "core/ConsoleCommand.h"37 37 #include "objects/SpaceShip.h" 38 #include "HUD.h" 38 39 #include "BarOverlayElement.h" 39 40 #include "RadarOverlayElement.h" 40 41 #include "OverlayElementFactories.h" 41 #include "HUD.h"42 42 43 43 namespace orxonox 44 44 { 45 ConsoleCommandShortcut(HUD, cycleNavigationFocus, AccessLevel::User);46 47 45 using namespace Ogre; 48 46 49 HUD::HUD( ){47 HUD::HUD(int zoom){ 50 48 om = &Ogre::OverlayManager::getSingleton(); 51 firstRadarObject = NULL;52 lastRadarObject = NULL;53 49 54 50 // create Factories … … 60 56 orxonoxHUD = om->create("Orxonox/HUD"); 61 57 container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container")); 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"); 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"); 72 66 73 67 // create energy bar … … 81 75 radar->show(); 82 76 83 // create Navigation84 nav = new Navigation(container);85 86 77 // set up screen-wide container 87 78 container->show(); … … 94 85 container->setHeight(1.0); 95 86 container->setMetricsMode(Ogre::GMM_RELATIVE); 96 container->addChild(fpsText); 97 87 container->addChild(test); 98 88 energyBar->init(0.01, 0.94, 0.4, container); 99 89 energyBar->setValue(1); 100 101 90 speedoBar->init(0.01, 0.90, 0.4, container); 102 103 91 radar->init(0.5, 0.9, 0.2, container); 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 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(); 111 96 } 112 97 113 98 void HUD::tick(float dt) 114 99 { 100 int d = radar->getDist2Focus()/10; 101 if(d) test->setCaption("Distance: " + Ogre::StringConverter::toString(d)); 102 else test->setCaption(""); 103 115 104 energyBar->resize(); 116 105 … … 122 111 radar->resize(); 123 112 radar->update(); 124 125 nav->update();126 113 } 127 114 128 void HUD::addRadarObject(Vector3 pos){ 129 // check if this is the first RadarObject to create 130 if(firstRadarObject == NULL){ 131 firstRadarObject = new RadarObject(container, pos); 132 lastRadarObject = firstRadarObject; 133 } 134 else{ // if not, append to list 135 lastRadarObject->next = new RadarObject(container, pos); 136 lastRadarObject = lastRadarObject->next; 137 } 138 } 139 140 RadarObject* HUD::getFirstRadarObject(){ 141 return firstRadarObject; 142 } 143 144 /*static*/HUD& HUD::getSingleton(){ 145 static HUD theInstance; 146 return theInstance; 147 } 148 149 /*static*/void HUD::setFPS(float fps){ 150 HUD::getSingleton().fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 151 } 152 153 /*static*/void HUD::setEnergy(float value){ 154 HUD::getSingleton().energyBar->setValue(value); 155 } 156 157 /*static*/void HUD::cycleNavigationFocus(){ 158 HUD::getSingleton().nav->cycleFocus(); 115 HUD::~HUD(void){ 159 116 } 160 117 } -
code/trunk/src/orxonox/hud/HUD.h
r1394 r1407 30 30 #define _HUD_H__ 31 31 32 #include <string.h> 33 #include <OgreOverlayElement.h> 34 #include <OgreTextAreaOverlayElement.h> 32 35 #include <OgrePrerequisites.h> 33 #include <OgreTextAreaOverlayElement.h> 36 34 37 #include "OrxonoxPrereqs.h" 35 38 #include "core/Tickable.h" 36 39 #include "BarOverlayElement.h" 37 40 #include "RadarOverlayElement.h" 38 #include "Navigation.h"39 #include "RadarObject.h"40 41 41 42 … … 45 46 { 46 47 private: 47 HUD();48 HUD(HUD& instance);49 ~HUD();50 48 Ogre::OverlayManager* om; 51 49 Ogre::Overlay* orxonoxHUD; 52 50 Ogre::OverlayContainer* container; 53 Ogre::TextAreaOverlayElement* fpsText;51 Ogre::TextAreaOverlayElement* test; 54 52 BarOverlayElement* energyBar; 55 53 BarOverlayElement* speedoBar; 56 54 RadarOverlayElement* radar; 57 RadarObject* firstRadarObject;58 RadarObject* lastRadarObject;59 Navigation* nav;60 55 61 56 public: 57 HUD(int zoom); 58 ~HUD(); 62 59 virtual void tick(float); 63 void addRadarObject(Vector3 pos);64 RadarObject* getFirstRadarObject();65 60 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();71 61 }; 72 62 } -
code/trunk/src/orxonox/hud/RadarObject.cc
r1393 r1407 26 26 */ 27 27 28 #include <string.h>29 #include <OgreOverlayManager.h>30 #include <OgrePanelOverlayElement.h>31 #include <OgreStringConverter.h>32 #include <util/Math.h>33 28 #include "RadarObject.h" 34 29 … … 39 34 int RadarObject::count = 0; // initialize static variable 40 35 41 RadarObject::RadarObject(O verlayContainer* container){36 RadarObject::RadarObject(Ogre::OverlayContainer* container){ 42 37 container_ = container; 43 38 pos_ = Vector3(0.0, 0.0, 0.0); … … 45 40 } 46 41 47 RadarObject::RadarObject(O verlayContainer* container, Vector3 pos){42 RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){ 48 43 container_ = container; 49 44 pos_ = pos; … … 55 50 void RadarObject::init(){ 56 51 next = NULL; 57 om = &O verlayManager::getSingleton();52 om = &Ogre::OverlayManager::getSingleton(); 58 53 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 59 "Object"+ StringConverter::toString(count)));54 "Object"+Ogre::StringConverter::toString(count))); 60 55 panel_->setMaterialName("Orxonox/RedDot"); 61 56 panel_->setDimensions(3,3); … … 67 62 } 68 63 } 64 65 /* my local clipboard... 66 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 67 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl; 68 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 69 */ -
code/trunk/src/orxonox/hud/RadarObject.h
r1400 r1407 28 28 #ifndef _RADAR2_H__ 29 29 #define _RADAR2_H__ 30 31 #include <string.h> 30 32 #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> 31 39 #include "../OrxonoxPrereqs.h" 32 40 … … 47 55 int index_; // index number of object 48 56 Vector3 pos_; // position in space 57 Ogre::Real radius_, phi_; // position on radar 49 58 Ogre::OverlayContainer* container_; 50 59 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot -
code/trunk/src/orxonox/hud/RadarOverlayElement.cc
r1400 r1407 22 22 * Yuning Chai 23 23 * Co-authors: 24 * Felix Schulthess24 * ... 25 25 * 26 26 */ 27 #include <string.h> 28 29 30 #include <string.h> 31 #include <OgreOverlayManager.h> 32 #include <OgreStringConverter.h> 33 #include <OgrePanelOverlayElement.h> 34 35 #include "GraphicsEngine.h" 36 #include "core/Tickable.h" 37 #include "core/ConsoleCommand.h" 38 #include "objects/SpaceShip.h" 39 #include "HUD.h" 27 40 28 #include "RadarOverlayElement.h" 41 29 42 30 namespace orxonox 43 31 { 32 ConsoleCommandShortcut(RadarOverlayElement, cycleFocus, AccessLevel::User); 44 33 45 34 using namespace Ogre; 46 35 47 RadarOverlayElement::RadarOverlayElement(const String& name):PanelOverlayElement(name){ 36 RadarOverlayElement* RadarOverlayElement::instance_s = NULL; 37 38 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 39 RadarOverlayElement::instance_s = this; 48 40 } 49 41 … … 51 43 } 52 44 53 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, O verlayContainer* container){45 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){ 54 46 // some initial data 55 om = &O verlayManager::getSingleton();47 om = &Ogre::OverlayManager::getSingleton(); 56 48 dimRel_ = dimRel; 57 49 leftRel_ = leftRel; 58 50 topRel_ = topRel; 59 51 container_ = container; 60 61 setMetricsMode(GMM_PIXELS); 52 firstRadarObject_ = NULL; 53 lastRadarObject_ = NULL; 54 focus_ = NULL; 55 56 // create nav marker ... 57 navMarker_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "NavMarker")); 58 navMarker_->setMetricsMode(Ogre::GMM_PIXELS); 59 navMarker_->setMaterialName("Orxonox/NavMarker"); 60 navMarker_->setDimensions(16,16); 61 navMarker_->setPosition(0,386); 62 navMarker_->hide(); 63 container_->addChild(navMarker_); 64 65 // these have to fit the data in the level 66 shipPos_ = Vector3(0.0, 0.0, 0.0); 67 initialDir_ = Vector3(1.0, 0.0, 0.0); 68 currentDir_ = initialDir_; 69 initialOrth_ = Vector3(0.0, 0.0, 1.0); 70 currentOrth_ = initialOrth_; 71 plane = Plane(currentDir_, shipPos_); 72 73 setMetricsMode(Ogre::GMM_PIXELS); 62 74 setMaterialName("Orxonox/Radar"); 63 75 resize(); … … 78 90 79 91 void RadarOverlayElement::update() { 80 shipPos_ = SpaceShip::getLocalShip()->getPosition(); 81 currentDir_ = SpaceShip::getLocalShip()->getDir(); 82 currentOrth_ = SpaceShip::getLocalShip()->getOrth(); 83 RadarObject* ro = HUD::getSingleton().getFirstRadarObject(); 92 shipPos_ = SpaceShip::instance_s->getPosition(); 93 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 94 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 95 plane = Plane(currentDir_, shipPos_); 96 97 RadarObject* ro = firstRadarObject_; 84 98 // iterate through all RadarObjects 85 99 while(ro != NULL){ 86 100 // 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);101 ro->radius_ = calcRadius(ro); 102 ro->phi_ = calcPhi(ro); 103 ro->right_ = calcRight(ro); 90 104 91 105 // set size to fit distance... … … 96 110 else ro->panel_->setDimensions(1,1); 97 111 98 if (r ight){99 ro->panel_->setPosition(sin( phi)*radius/100 3.5*dim_/2+dim_/2+left_-2,-cos( phi)*radius/3.5*dim_/2+dim_/2+top_-2);112 if (ro->right_){ 113 ro->panel_->setPosition(sin(ro->phi_)*ro->radius_/ 114 3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2); 101 115 } 102 116 else { 103 ro->panel_->setPosition(-sin( phi)*radius/104 3.5*dim_/2+dim_/2+left_-2,-cos( phi)*radius/3.5*dim_/2+dim_/2+top_-2);117 ro->panel_->setPosition(-sin(ro->phi_)*ro->radius_/ 118 3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2); 105 119 } 106 120 ro = ro->next; 107 121 } 108 } 122 updateNavMarker(); 123 } 124 125 void RadarOverlayElement::updateNavMarker(){ 126 if(focus_ == NULL) return; 127 // from the angle we find out where to draw the marker 128 // and which of the four arrows to take 129 float r1 = atan((float)(windowW_)/(float)(windowH_)); 130 float phi = focus_->phi_; 131 if(focus_->right_){ 132 if(phi<r1){ 133 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, 0); 134 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 135 } 136 else if(phi>3.14-r1){ 137 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, windowH_-16); 138 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 139 } 140 else { 141 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 142 navMarker_->setUV(0.5, 0.5, 1.0, 1.0); 143 } 144 } 145 else{ 146 if(phi<r1) { 147 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, 0); 148 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 149 } 150 else if(phi>3.14-r1) { 151 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, windowH_-16); 152 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 153 } 154 else { 155 navMarker_->setPosition(0, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 156 navMarker_->setUV(0.0, 0.0, 0.5, 0.5); 157 } 158 } 159 } 160 161 void RadarOverlayElement::addObject(Vector3 pos){ 162 if(firstRadarObject_ == NULL){ 163 firstRadarObject_ = new RadarObject(container_, pos); 164 lastRadarObject_ = firstRadarObject_; 165 } 166 else{ 167 lastRadarObject_->next = new RadarObject(container_, pos); 168 lastRadarObject_ = lastRadarObject_->next; 169 } 170 } 109 171 110 172 void RadarOverlayElement::listObjects(){ 111 173 int i = 0; 112 RadarObject* ro = HUD::getSingleton().getFirstRadarObject();174 RadarObject* ro = firstRadarObject_; 113 175 COUT(3) << "List of RadarObjects:\n"; 114 176 // iterate through all Radar Objects … … 119 181 } 120 182 121 float RadarOverlayElement::calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 122 return(acos((dir.dotProduct(obj->pos_ - pos))/ 123 ((obj->pos_ - pos).length()*dir.length()))); 124 } 125 126 float RadarOverlayElement::calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 183 float RadarOverlayElement::getDist2Focus(){ 184 if(focus_ == NULL) return(0.0); 185 return((focus_->pos_-shipPos_).length()); 186 } 187 188 float RadarOverlayElement::calcRadius(RadarObject* obj){ 189 return(acos((currentDir_.dotProduct(obj->pos_ - shipPos_))/ 190 ((obj->pos_ - shipPos_).length()*currentDir_.length()))); 191 } 192 193 float RadarOverlayElement::calcPhi(RadarObject* obj){ 127 194 // project difference vector on our plane... 128 Vector3 proj = Plane(dir, pos).projectVector(obj->pos_ - pos);195 Ogre::Vector3 proj = plane.projectVector(obj->pos_ - shipPos_); 129 196 // ...and find out the angle 130 return(acos(( orth.dotProduct(proj))/131 ( orth.length()*proj.length())));132 } 133 134 bool RadarOverlayElement::calcRight( Vector3 pos, Vector3 dir, Vector3 orth,RadarObject* obj){135 if(( dir.crossProduct(orth)).dotProduct(obj->pos_ - pos) > 0)197 return(acos((currentOrth_.dotProduct(proj))/ 198 (currentOrth_.length()*proj.length()))); 199 } 200 201 bool RadarOverlayElement::calcRight(RadarObject* obj){ 202 if((currentDir_.crossProduct(currentOrth_)).dotProduct(obj->pos_ - shipPos_) > 0) 136 203 return true; 137 204 else return false; 138 205 } 206 207 /*static*/void RadarOverlayElement::cycleFocus(){ 208 if(RadarOverlayElement::instance_s == NULL) return; 209 210 if(RadarOverlayElement::instance_s->focus_ == NULL){ 211 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->firstRadarObject_; 212 } 213 else{ 214 RadarOverlayElement::instance_s->focus_->panel_->setMaterialName("Orxonox/RedDot"); 215 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->focus_->next; 216 } 217 218 if(RadarOverlayElement::instance_s->focus_ == NULL){ 219 RadarOverlayElement::instance_s->navMarker_->hide(); 220 } 221 else{ 222 RadarOverlayElement::instance_s->navMarker_->show(); 223 RadarOverlayElement::instance_s->focus_->panel_->setMaterialName("Orxonox/WhiteDot"); 224 } 225 } 139 226 } 227 228 /* my local clipboard... 229 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 230 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl; 231 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 232 */ -
code/trunk/src/orxonox/hud/RadarOverlayElement.h
r1400 r1407 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> 36 #include <OgrePrerequisites.h> 37 31 38 #include <util/Math.h> 32 #include <OgrePrerequisites.h> 39 #include <string.h> 40 #include "core/Tickable.h" 41 #include "core/ConsoleCommand.h" 42 #include "objects/SpaceShip.h" 33 43 #include "../OrxonoxPrereqs.h" 34 44 #include "RadarObject.h" 45 #include "GraphicsEngine.h" 35 46 36 47 namespace orxonox … … 41 52 Ogre::OverlayManager* om; // our one and only overlay manager 42 53 Ogre::OverlayContainer* container_; // pointer to the container we're in 54 Vector3 initialDir_; // direction of nose 43 55 Vector3 currentDir_; 56 Vector3 initialOrth_; // direction of normal 44 57 Vector3 currentOrth_; 45 58 Vector3 shipPos_; // position of ship 59 Ogre::Plane plane; // plane perpendicular to dir 46 60 47 61 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension … … 55 69 void resize(); 56 70 void update(); 71 void updateNavMarker(); 72 void addObject(Vector3 pos); 57 73 void listObjects(); 74 float getDist2Focus(); 75 float calcRadius(RadarObject* obj); 76 float calcPhi(RadarObject* obj); 77 bool calcRight(RadarObject* obj); 58 78 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); 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(); 62 86 }; 63 87 } -
code/trunk/src/orxonox/objects/Camera.h
r1399 r1407 50 50 void setTargetNode(Ogre::SceneNode* obj); 51 51 52 Ogre::Camera* cam_;53 54 52 void tick(float dt); 55 53 void update(); … … 65 63 Ogre::SceneNode* cameraNode_; 66 64 Ogre::Vector3 oldPos; 65 Ogre::Camera* cam_; 67 66 bool bHasFocus_; 68 67 }; -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1401 r1407 69 69 return NULL; 70 70 } 71 71 72 72 SpaceShip::SpaceShip() : 73 73 //testvector_(0,0,0), … … 112 112 this->setConfigValues(); 113 113 114 initialDir_ = Vector3(1.0, 0.0, 0.0);115 currentDir_ = initialDir_;116 initialOrth_ = Vector3(0.0, 0.0, 1.0);117 currentOrth_ = initialOrth_;118 114 119 115 this->setRotationAxis(1, 0, 0); … … 241 237 CameraHandler::getInstance()->requestFocus(cam_); 242 238 243 }244 245 Camera* SpaceShip::getCamera(){246 return cam_;247 239 } 248 240 … … 399 391 } 400 392 401 Vector3 SpaceShip::get Dir() {402 return currentDir_;403 } 404 405 Vector3 SpaceShip::getOrth(){406 return currentOrth_;393 Vector3 SpaceShip::getSPosition() { 394 return SpaceShip::getLocalShip()->getPosition(); 395 } 396 397 Quaternion SpaceShip::getSOrientation() { 398 return SpaceShip::getLocalShip()->getOrientation(); 407 399 } 408 400 … … 411 403 void SpaceShip::tick(float dt) 412 404 { 413 currentDir_ = getOrientation()*initialDir_;414 currentOrth_ = getOrientation()*initialOrth_;415 416 405 if (this->cam_) 417 406 this->cam_->tick(dt); … … 433 422 if (this->bLMousePressed_ && this->timeToReload_ <= 0) 434 423 { 435 424 436 425 Projectile *p = new Projectile(this); 437 426 438 427 p->setBacksync(true); 439 428 this->timeToReload_ = this->reloadTime_; -
code/trunk/src/orxonox/objects/SpaceShip.h
r1400 r1407 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 66 67 void getFocus(); 67 68 68 static SpaceShip* instance_s; 69 static Vector3 getSPosition(); 70 static Quaternion getSOrientation(); 69 71 static std::string whereAmI(); 70 72 static void setMaxSpeedTest(float value) … … 78 80 79 81 float getMaxSpeed(); 80 Vector3 getDir();81 Vector3 getOrth();82 Camera* getCamera();83 82 84 83 private: … … 86 85 87 86 Vector3 testvector_; 88 Vector3 initialDir_;89 Vector3 currentDir_;90 Vector3 initialOrth_;91 Vector3 currentOrth_;92 87 bool bInvertYAxis_; 93 88 bool setMouseEventCallback_;
Note: See TracChangeset
for help on using the changeset viewer.