Changeset 1502 for code/trunk/src/orxonox/hud
- Timestamp:
- Jun 1, 2008, 3:54:20 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/hud
- Files:
-
- 9 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/hud/BarOverlayElement.cc
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * Felix Schulthess 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 27 28 29 #include "OrxonoxStableHeaders.h" 30 #include "BarOverlayElement.h" 28 31 #include <OgreOverlayManager.h> 29 #include <OgreOverlayElement.h>30 #include <OgrePanelOverlayElement.h>31 32 #include "GraphicsEngine.h" 32 #include "BarOverlayElement.h"33 33 34 34 namespace orxonox 35 35 { 36 using namespace Ogre;36 using namespace Ogre; 37 37 38 BarOverlayElement::BarOverlayElement(const String& name): Ogre::PanelOverlayElement(name){38 BarOverlayElement::BarOverlayElement(const String& name):PanelOverlayElement(name){ 39 39 name_ = name; 40 40 } … … 42 42 BarOverlayElement::~BarOverlayElement(){} 43 43 44 void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, O gre::OverlayContainer* container){44 void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){ 45 45 // init some values... 46 46 container_ = container; 47 om = &O gre::OverlayManager::getSingleton();47 om = &OverlayManager::getSingleton(); 48 48 value_ = 0; 49 49 color_ = 2; … … 53 53 topRel_ = topRel; 54 54 dimRel_ = dimRel; 55 55 56 56 // create background... 57 57 background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container")); 58 58 background_->show(); 59 59 container_->addChild(background_); 60 background_->setMetricsMode( Ogre::GMM_PIXELS);60 background_->setMetricsMode(GMM_PIXELS); 61 61 background_->setMaterialName("Orxonox/BarBackground"); 62 62 … … 65 65 66 66 show(); 67 setMetricsMode( Ogre::GMM_PIXELS);67 setMetricsMode(GMM_PIXELS); 68 68 setMaterialName("Orxonox/Green"); 69 69 background_->addChild(this); … … 126 126 } 127 127 } 128 129 -
code/trunk/src/orxonox/hud/BarOverlayElement.h
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * Felix Schulthess 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 27 28 29 #ifndef _BarOverlayElement_H__ 30 #define _BarOverlayElement_H__ 28 31 29 #ifndef _BAR_H__ 30 #define _BAR_H__ 31 32 #include <OgreOverlayManager.h> 33 #include <OgreOverlayElement.h> 34 #include <OgrePanelOverlayElement.h> 32 #include "OrxonoxPrereqs.h" 35 33 36 34 #include <OgrePrerequisites.h> 37 #include "../OrxonoxPrereqs.h" 38 39 35 #include <OgrePanelOverlayElement.h> 40 36 41 37 namespace orxonox … … 44 40 { 45 41 private: 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 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_; 61 57 62 58 public: 63 64 65 66 59 bool left2Right; 60 static const int RED = 0; // predefined colors 61 static const int YELLOW = 1; 62 static const int GREEN = 2; 67 63 68 69 70 71 72 73 74 75 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(); 76 72 }; 77 73 } 78 #endif 79 80 74 #endif /* _BarOverlayElement_H__ */ -
code/trunk/src/orxonox/hud/HUD.cc
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist3 * 4 *5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * Felix Schulthess 25 * 26 */ 27 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include "HUD.h" 31 32 #include <string> 33 #include <set> 30 34 #include <OgreOverlay.h> 31 35 #include <OgreOverlayContainer.h> 32 36 #include <OgreOverlayManager.h> 33 #include <OgreSceneNode.h>34 #include <OgreEntity.h>35 37 #include <OgreStringConverter.h> 38 36 39 #include "core/Debug.h" 40 #include "core/ConsoleCommand.h" 37 41 #include "objects/SpaceShip.h" 38 #include " HUD.h"42 #include "GraphicsEngine.h" 39 43 #include "BarOverlayElement.h" 44 #include "RadarObject.h" 40 45 #include "RadarOverlayElement.h" 46 #include "Navigation.h" 41 47 #include "OverlayElementFactories.h" 42 48 43 49 namespace orxonox 44 50 { 51 SetConsoleCommandShortcut(HUD, cycleNavigationFocus).setAccessLevel(AccessLevel::User); 52 SetConsoleCommandShortcut(HUD, toggleFPS).setAccessLevel(AccessLevel::User); 53 SetConsoleCommandShortcut(HUD, toggleRenderTime).setAccessLevel(AccessLevel::User); 54 45 55 using namespace Ogre; 46 56 47 HUD::HUD( int zoom){57 HUD::HUD(){ 48 58 om = &Ogre::OverlayManager::getSingleton(); 49 50 // create Factories 59 sm = GraphicsEngine::getSingleton().getSceneManager(); 60 showFPS = true; 61 showRenderTime = true; 62 63 // create Factories 51 64 BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory(); 52 65 om->addOverlayElementFactory(barOverlayElementFactory); … … 56 69 orxonoxHUD = om->create("Orxonox/HUD"); 57 70 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"); 71 72 // creating text to display fps 73 fpsText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "fpsText")); 74 fpsText->show(); 75 fpsText->setMetricsMode(Ogre::GMM_PIXELS); 76 fpsText->setDimensions(0.001, 0.001); 77 fpsText->setPosition(10, 10); 78 fpsText->setFontName("Console"); 79 fpsText->setCharHeight(20); 80 fpsText->setCaption("init"); 81 82 // creating text to display render time ratio 83 rTRText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "rTRText")); 84 rTRText->show(); 85 rTRText->setMetricsMode(Ogre::GMM_PIXELS); 86 rTRText->setDimensions(0.001, 0.001); 87 rTRText->setPosition(10, 30); 88 rTRText->setFontName("Console"); 89 rTRText->setCharHeight(20); 90 rTRText->setCaption("init"); 66 91 67 92 // create energy bar … … 75 100 radar->show(); 76 101 77 // set up screen-wide container 102 // create Navigation 103 nav = new Navigation(container); 104 105 // set up screen-wide container 78 106 container->show(); 79 107 … … 85 113 container->setHeight(1.0); 86 114 container->setMetricsMode(Ogre::GMM_RELATIVE); 87 container->addChild(test); 115 container->addChild(fpsText); 116 container->addChild(rTRText); 117 88 118 energyBar->init(0.01, 0.94, 0.4, container); 89 119 energyBar->setValue(1); 120 90 121 speedoBar->init(0.01, 0.90, 0.4, container); 122 91 123 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(); 124 SceneNode* node; 125 node = sm->getRootSceneNode()->createChildSceneNode("tomato1", Vector3(2000.0, 0.0, 0.0)); 126 addRadarObject(node); 127 node = sm->getRootSceneNode()->createChildSceneNode("tomato2", Vector3(0.0, 2000.0, 0.0)); 128 addRadarObject(node); 129 node = sm->getRootSceneNode()->createChildSceneNode("tomato3", Vector3(0.0, 0.0, 2000.0)); 130 addRadarObject(node); 131 node = sm->getRootSceneNode()->createChildSceneNode("station", Vector3(10000.0,16000.0,0.0)); 132 addRadarObject(node, 3); 133 } 134 135 HUD::~HUD(){ 136 //todo: clean up objects 96 137 } 97 138 98 139 void HUD::tick(float dt) 99 140 { 100 int d = radar->getDist2Focus()/10;101 if(d) test->setCaption("Distance: " + Ogre::StringConverter::toString(d));102 else test->setCaption("");103 104 141 energyBar->resize(); 105 142 106 float v = SpaceShip::instance_s->getVelocity().length(); 107 float vmax = SpaceShip::instance_s->getMaxSpeed(); 143 if(!SpaceShip::getLocalShip()) 144 return; 145 float v = SpaceShip::getLocalShip()->getVelocity().length(); 146 float vmax = SpaceShip::getLocalShip()->getMaxSpeed(); 108 147 speedoBar->setValue(v/vmax); 109 148 speedoBar->resize(); … … 111 150 radar->resize(); 112 151 radar->update(); 113 } 114 115 HUD::~HUD(void){ 152 153 nav->update(); 154 155 setFPS(); 156 } 157 158 void HUD::setRenderTimeRatio(float ratio) 159 { 160 if(showRenderTime){ 161 rTRText->setCaption("Render time ratio: " + Ogre::StringConverter::toString(ratio)); 162 } 163 else{ 164 rTRText->setCaption(""); 165 return; 166 } 167 } 168 169 void HUD::setFPS(){ 170 if(showFPS){ 171 float fps = GraphicsEngine::getSingleton().getAverageFPS(); 172 fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 173 } 174 else{ 175 fpsText->setCaption(""); 176 return; 177 } 178 } 179 180 void HUD::addRadarObject(SceneNode* node, int colour){ 181 RadarObject* obj = new RadarObject(container, node, colour); 182 roSet.insert(obj); 183 // // check if this is the first RadarObject to create 184 // if(firstRadarObject == NULL){ 185 // firstRadarObject = new RadarObject(container, node, colour); 186 // lastRadarObject = firstRadarObject; 187 // } 188 // else{ // if not, append to list 189 // lastRadarObject->next = new RadarObject(container, node, colour); 190 // lastRadarObject = lastRadarObject->next; 191 // } 192 } 193 194 void HUD::removeRadarObject(Ogre::SceneNode* node){ 195 COUT(3) << "blabla" << std::endl; 196 for(std::set<RadarObject*>::iterator it=roSet.begin(); it!=roSet.end(); it++){ 197 if((*it)->getNode() == node) { 198 delete (*it); 199 roSet.erase(it); 200 } 201 } 202 } 203 204 /*static*/ HUD& HUD::getSingleton(){ 205 static HUD theInstance; 206 return theInstance; 207 } 208 209 /*static*/ void HUD::setEnergy(float value){ 210 HUD::getSingleton().energyBar->setValue(value); 211 } 212 213 /*static*/ void HUD::cycleNavigationFocus(){ 214 HUD::getSingleton().nav->cycleFocus(); 215 } 216 217 /*static*/ void HUD::toggleFPS(){ 218 HUD::getSingleton().showFPS = !HUD::getSingleton().showFPS; 219 } 220 221 /*static*/ void HUD::toggleRenderTime(){ 222 HUD::getSingleton().showRenderTime = !HUD::getSingleton().showRenderTime; 116 223 } 117 224 } -
code/trunk/src/orxonox/hud/HUD.h
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * Felix Schulthess 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 27 28 28 29 … … 30 31 #define _HUD_H__ 31 32 32 #include <string.h> 33 #include <OgreOverlayElement.h> 33 #include "OrxonoxPrereqs.h" 34 35 #include <OgrePrerequisites.h> 34 36 #include <OgreTextAreaOverlayElement.h> 35 #include <OgrePrerequisites.h> 36 37 #include "OrxonoxPrereqs.h" 37 #include <OgreSceneNode.h> 38 38 #include "core/Tickable.h" 39 #include "BarOverlayElement.h" 40 #include "RadarOverlayElement.h" 41 39 #include "util/Math.h" 42 40 43 41 namespace orxonox … … 45 43 class _OrxonoxExport HUD : public Tickable 46 44 { 47 private: 48 Ogre::OverlayManager* om; 49 Ogre::Overlay* orxonoxHUD; 50 Ogre::OverlayContainer* container; 51 Ogre::TextAreaOverlayElement* test; 52 BarOverlayElement* energyBar; 53 BarOverlayElement* speedoBar; 54 RadarOverlayElement* radar; 45 private: 46 HUD(); 47 HUD(HUD& instance); 48 ~HUD(); 49 Ogre::OverlayManager* om; 50 Ogre::SceneManager* sm; 51 Ogre::Overlay* orxonoxHUD; 52 Ogre::OverlayContainer* container; 53 Ogre::TextAreaOverlayElement* fpsText; 54 Ogre::TextAreaOverlayElement* rTRText; 55 BarOverlayElement* energyBar; 56 BarOverlayElement* speedoBar; 57 RadarOverlayElement* radar; 58 Navigation* nav; 55 59 56 public: 57 HUD(int zoom); 58 ~HUD(); 59 virtual void tick(float); 60 bool showFPS; 61 bool showRenderTime; 60 62 63 public: 64 virtual void tick(float); 65 void addRadarObject(Ogre::SceneNode* node, int colour = 0); 66 void removeRadarObject(Ogre::SceneNode* node); 67 void setRenderTimeRatio(float ratio); 68 void setFPS(); 69 70 std::set<RadarObject*> roSet; 71 72 static HUD* instance_s; 73 static HUD& getSingleton(); 74 static void setEnergy(float value); 75 static void cycleNavigationFocus(); 76 static void toggleFPS(); 77 static void toggleRenderTime(); 61 78 }; 62 79 } 63 80 64 #endif 81 #endif /* _HUD_H__ */ -
code/trunk/src/orxonox/hud/OverlayElementFactories.h
r1362 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * Felix Schulthess 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 27 28 28 #ifndef _ FACTORIES_H__29 #define _ FACTORIES_H__29 #ifndef _OverlayElementFactories_H__ 30 #define _OverlayElementFactories_H__ 30 31 32 #include "OrxonoxPrereqs.h" 33 34 #include <OgrePrerequisites.h> 31 35 #include <OgreOverlayElement.h> 32 #include <OgrePrerequisites.h>33 36 #include <OgreOverlayElementFactory.h> 34 37 35 38 #include "BarOverlayElement.h" 39 #include "RadarOverlayElement.h" 36 40 37 41 namespace orxonox{ 38 42 class _OrxonoxExport BarOverlayElementFactory : public Ogre::OverlayElementFactory{ 39 43 public: 40 44 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 41 45 return new BarOverlayElement(instanceName); … … 48 52 49 53 class _OrxonoxExport RadarOverlayElementFactory : public Ogre::OverlayElementFactory{ 50 54 public: 51 55 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 52 56 return new RadarOverlayElement(instanceName); … … 59 63 } 60 64 61 #endif 65 #endif /* _OverlayElementFactories_H__ */ -
code/trunk/src/orxonox/hud/RadarObject.cc
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Felix Schulthess 23 * Co-authors: 24 * ... 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Felix Schulthess 24 * Co-authors: 25 * ... 26 * 27 */ 27 28 29 #include "OrxonoxStableHeaders.h" 28 30 #include "RadarObject.h" 31 32 #include <OgreOverlayManager.h> 33 #include <OgreStringConverter.h> 34 #include "GraphicsEngine.h" 29 35 30 36 namespace orxonox … … 32 38 using namespace Ogre; 33 39 34 40 int RadarObject::count = 0; // initialize static variable 35 41 36 RadarObject::RadarObject(Ogre::OverlayContainer* container){ 37 container_ = container; 38 pos_ = Vector3(0.0, 0.0, 0.0); 39 init(); 40 } 41 42 RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){ 43 container_ = container; 44 pos_ = pos; 45 init(); 46 } 47 48 RadarObject::~RadarObject(){} 49 50 void RadarObject::init(){ 51 next = NULL; 52 om = &Ogre::OverlayManager::getSingleton(); 53 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 54 "Object"+Ogre::StringConverter::toString(count))); 55 panel_->setMaterialName("Orxonox/RedDot"); 56 panel_->setDimensions(3,3); 42 RadarObject::RadarObject(OverlayContainer* container, SceneNode* node, int colour){ 43 container_ = container; 44 node_ = node; 45 colour_ = colour; 46 om = &OverlayManager::getSingleton(); 47 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 48 "Object"+StringConverter::toString(count))); 49 setColour(colour_); 50 panel_->setDimensions(3,3); 57 51 panel_->setMetricsMode(Ogre::GMM_PIXELS); 58 52 panel_->show(); … … 60 54 count++; 61 55 container_->addChild(panel_); 62 } 56 } 57 58 RadarObject::~RadarObject(){ 59 delete panel_; 60 } 61 62 void RadarObject::setColour(int colour){ 63 switch(colour){ 64 case RED: panel_->setMaterialName("Orxonox/RedDot"); break; 65 case YELLOW: panel_->setMaterialName("Orxonox/YellowDot"); break; 66 case GREEN: panel_->setMaterialName("Orxonox/GreenDot"); break; 67 case BLUE: panel_->setMaterialName("Orxonox/BlueDot"); break; 68 case WHITE: panel_->setMaterialName("Orxonox/WhiteDot"); break; 69 default: panel_->setMaterialName("Orxonox/RedDot"); break; 70 } 71 } 72 73 void RadarObject::resetColour(){ 74 setColour(colour_); 75 } 76 77 Vector3 RadarObject::getPosition(){ 78 return node_->getPosition(); 79 } 80 81 SceneNode* RadarObject::getNode(){ 82 return node_; 83 } 63 84 } 64 85 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
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * ... 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Felix Schulthess 24 * Co-authors: 25 * ... 26 * 27 */ 27 28 28 #ifndef _R ADAR2_H__29 #define _R ADAR2_H__29 #ifndef _RadarObject_H__ 30 #define _RadarObject_H__ 30 31 31 #include <string.h>32 32 #include <OgrePrerequisites.h> 33 #include <OgreOverlayManager.h> 34 #include <OgreOverlayElement.h> 33 #include <OgreSceneNode.h> 35 34 #include <OgrePanelOverlayElement.h> 36 #include <OgreStringConverter.h> 37 38 #include <util/Math.h> 39 #include "../OrxonoxPrereqs.h" 35 #include "OrxonoxPrereqs.h" 36 #include "util/Math.h" 40 37 41 38 namespace orxonox … … 43 40 class _OrxonoxExport RadarObject 44 41 { 45 private: 46 Ogre::OverlayManager* om; // our one and only overlay manager 47 void init(); 42 private: 43 Ogre::OverlayManager* om; // our one and only overlay manager 44 Ogre::SceneNode* node_; // node of object 45 int colour_; 48 46 49 public: 50 RadarObject(Ogre::OverlayContainer* container); 51 RadarObject(Ogre::OverlayContainer* container, Vector3 pos); 52 ~RadarObject(); 47 public: 48 RadarObject(Ogre::OverlayContainer* container, Ogre::SceneNode* node, int colour = 0); 49 ~RadarObject(); 50 void setColour(int colour); 51 void resetColour(); 52 Vector3 getPosition(); 53 Ogre::SceneNode* getNode(); 53 54 54 bool right_; 55 int index_; // index number of object 56 Vector3 pos_; // position in space 57 Ogre::Real radius_, phi_; // position on radar 58 Ogre::OverlayContainer* container_; 59 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot 60 RadarObject* next; // next pointer of linked list 55 bool right_; 56 int index_; // index number of object 57 Ogre::OverlayContainer* container_; 58 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot 61 59 62 static int count; 63 }; 60 static int count; 61 static const int RED = 0; 62 static const int YELLOW = 1; 63 static const int GREEN = 2; 64 static const int BLUE = 3; 65 static const int WHITE = 99; // used if object got nav focus 66 }; 64 67 } 65 68 66 #endif 69 #endif /* _RadarObject_H__ */ -
code/trunk/src/orxonox/hud/RadarOverlayElement.cc
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * ... 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 27 28 29 #include "OrxonoxStableHeaders.h" 28 30 #include "RadarOverlayElement.h" 31 32 #include <string> 33 #include <OgreOverlayManager.h> 34 #include <OgreStringConverter.h> 35 36 #include "GraphicsEngine.h" 37 #include "core/Tickable.h" 38 #include "core/ConsoleCommand.h" 39 #include "objects/SpaceShip.h" 40 #include "RadarObject.h" 41 #include "HUD.h" 29 42 30 43 namespace orxonox 31 44 { 32 ConsoleCommandShortcut(RadarOverlayElement, cycleFocus, AccessLevel::User);33 34 45 using namespace Ogre; 35 46 36 RadarOverlayElement* RadarOverlayElement::instance_s = NULL; 37 38 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 39 RadarOverlayElement::instance_s = this; 47 RadarOverlayElement::RadarOverlayElement(const String& name):PanelOverlayElement(name){ 40 48 } 41 49 … … 43 51 } 44 52 45 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){ 46 54 // some initial data 47 om = &Ogre::OverlayManager::getSingleton();55 om = &OverlayManager::getSingleton(); 48 56 dimRel_ = dimRel; 49 57 leftRel_ = leftRel; 50 58 topRel_ = topRel; 51 59 container_ = container; 52 firstRadarObject_ = NULL;53 lastRadarObject_ = NULL;54 focus_ = NULL;55 60 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); 61 setMetricsMode(GMM_PIXELS); 74 62 setMaterialName("Orxonox/Radar"); 75 63 resize(); … … 90 78 91 79 void RadarOverlayElement::update() { 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_; 80 shipPos_ = SpaceShip::getLocalShip()->getPosition(); 81 currentDir_ = SpaceShip::getLocalShip()->getDir(); 82 currentOrth_ = SpaceShip::getLocalShip()->getOrth(); 98 83 // iterate through all RadarObjects 99 while(ro != NULL){100 101 ro->radius_ = calcRadius(ro);102 ro->phi_ = calcPhi(ro);103 ro->right_ = calcRight(ro);84 for(std::set<RadarObject*>::iterator it=HUD::getSingleton().roSet.begin(); it!=HUD::getSingleton().roSet.end(); it++){ 85 // calc position on radar... 86 float radius = calcRadius(shipPos_, currentDir_, currentOrth_, (*it)); 87 float phi = calcPhi(shipPos_, currentDir_, currentOrth_, (*it)); 88 bool right = calcRight(shipPos_, currentDir_, currentOrth_, (*it)); 104 89 105 90 // set size to fit distance... 106 float d = (ro->pos_-shipPos_).length(); 107 if(d<4000) ro->panel_->setDimensions(4,4); 108 else if(d<8000) ro->panel_->setDimensions(3,3); 109 else if(d<16000) ro->panel_->setDimensions(2,2); 110 else ro->panel_->setDimensions(1,1); 91 float d = ((*it)->getPosition()-shipPos_).length(); 92 if(d<10000) (*it)->panel_->setDimensions(4,4); 93 else if(d<20000) (*it)->panel_->setDimensions(3,3); 94 else (*it)->panel_->setDimensions(2,2); 111 95 112 if (r o->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);96 if (right){ 97 (*it)->panel_->setPosition(sin(phi)*radius/ 98 3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2); 115 99 } 116 100 else { 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); 119 } 120 ro = ro->next; 121 } 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); 101 (*it)->panel_->setPosition(-sin(phi)*radius/ 102 3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2); 157 103 } 158 104 } 159 105 } 160 106 161 void RadarOverlayElement::addObject(Vector3 pos){ 162 if(firstRadarObject_ == NULL){ 163 firstRadarObject_ = new RadarObject(container_, pos); 164 lastRadarObject_ = firstRadarObject_; 107 void RadarOverlayElement::listObjects(){ 108 int i = 0; 109 COUT(3) << "List of RadarObjects:\n"; 110 // iterate through all Radar Objects 111 for(std::set<RadarObject*>::iterator it=HUD::getSingleton().roSet.begin(); it!=HUD::getSingleton().roSet.end(); it++){ 112 COUT(3) << i++ << ": " << (*it)->getPosition() << std::endl; 165 113 } 166 else{ 167 lastRadarObject_->next = new RadarObject(container_, pos); 168 lastRadarObject_ = lastRadarObject_->next; 169 } 170 } 114 } 171 115 172 void RadarOverlayElement::listObjects(){ 173 int i = 0; 174 RadarObject* ro = firstRadarObject_; 175 COUT(3) << "List of RadarObjects:\n"; 176 // iterate through all Radar Objects 177 while(ro != NULL) { 178 COUT(3) << i++ << ": " << ro->pos_ << std::endl; 179 ro = ro->next; 180 } 181 } 116 float RadarOverlayElement::calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 117 return(acos((dir.dotProduct(obj->getPosition() - pos))/ 118 ((obj->getPosition() - pos).length()*dir.length()))); 119 } 182 120 183 float RadarOverlayElement::getDist2Focus(){ 184 if(focus_ == NULL) return(0.0); 185 return((focus_->pos_-shipPos_).length()); 186 } 121 float RadarOverlayElement::calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 122 // project difference vector on our plane... 123 Vector3 proj = Plane(dir, pos).projectVector(obj->getPosition() - pos); 124 // ...and find out the angle 125 return(acos((orth.dotProduct(proj))/ 126 (orth.length()*proj.length()))); 127 } 187 128 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){ 194 // project difference vector on our plane... 195 Ogre::Vector3 proj = plane.projectVector(obj->pos_ - shipPos_); 196 // ...and find out the angle 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) 203 return true; 129 bool RadarOverlayElement::calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 130 if((dir.crossProduct(orth)).dotProduct(obj->getPosition() - pos) > 0) 131 return true; 204 132 else return false; 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 } 133 } 226 134 } 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
r1407 r1502 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Yuning Chai 23 * Co-authors: 24 * ... 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Yuning Chai 24 * Co-authors: 25 * Felix Schulthess 26 * 27 */ 27 28 28 #ifndef _R ADAR_H__29 #define _R ADAR_H__29 #ifndef _RadarOverlayElement_H__ 30 #define _RadarOverlayElement_H__ 30 31 31 #include <string.h> 32 #include <OgreOverlayManager.h> 33 #include <OgreStringConverter.h> 34 #include <OgreOverlayElement.h> 32 #include "OrxonoxPrereqs.h" 33 34 #include <OgrePrerequisites.h> 35 35 #include <OgrePanelOverlayElement.h> 36 #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 #include "../OrxonoxPrereqs.h" 44 #include "RadarObject.h" 45 #include "GraphicsEngine.h" 36 #include "util/Math.h" 46 37 47 38 namespace orxonox … … 49 40 class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement 50 41 { 51 private: 52 Ogre::OverlayManager* om; // our one and only overlay manager 53 Ogre::OverlayContainer* container_; // pointer to the container we're in 54 Vector3 initialDir_; // direction of nose 55 Vector3 currentDir_; 56 Vector3 initialOrth_; // direction of normal 57 Vector3 currentOrth_; 58 Vector3 shipPos_; // position of ship 59 Ogre::Plane plane; // plane perpendicular to dir 42 private: 43 Ogre::OverlayManager* om; // our one and only overlay manager 44 Ogre::OverlayContainer* container_; // pointer to the container we're in 45 Vector3 currentDir_; 46 Vector3 currentOrth_; 47 Vector3 shipPos_; // position of ship 60 48 61 62 63 int windowW_, windowH_;// absolute window dimensions49 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension 50 int left_, top_, dim_; // absolute position/dimension 51 int windowW_, windowH_; // absolute window dimensions 64 52 65 public: 66 RadarOverlayElement(const Ogre::String& name); 67 ~RadarOverlayElement(); 68 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 69 void resize(); 70 void update(); 71 void updateNavMarker(); 72 void addObject(Vector3 pos); 73 void listObjects(); 74 float getDist2Focus(); 75 float calcRadius(RadarObject* obj); 76 float calcPhi(RadarObject* obj); 77 bool calcRight(RadarObject* obj); 53 public: 54 RadarOverlayElement(const Ogre::String& name); 55 ~RadarOverlayElement(); 56 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 57 void resize(); 58 void update(); 59 void listObjects(); 78 60 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(); 86 }; 61 static float calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 62 static float calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 63 static bool calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj); 64 }; 87 65 } 88 66 89 #endif 67 #endif /* _RadarOverlayElement_H__ */
Note: See TracChangeset
for help on using the changeset viewer.