Changeset 1254
- Timestamp:
- May 11, 2008, 2:34:01 PM (17 years ago)
- Location:
- code/branches/hud2/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud2/src/orxonox/CMakeLists.txt
r1099 r1254 6 6 hud/HUD.cc 7 7 hud/BarOverlayElement.cc 8 hud/RadarOverlayElement.cc 8 9 particle/ParticleInterface.cc 9 10 tools/BillboardSet.cc -
code/branches/hud2/src/orxonox/OrxonoxPlatform.h
r975 r1254 175 175 //For apple, we always have a custom config.h file 176 176 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE 177 # include "config.h"177 //# include "config.h" 178 178 #endif 179 179 -
code/branches/hud2/src/orxonox/hud/BarOverlayElement.h
r1099 r1254 44 44 { 45 45 private: 46 46 47 int percentage_; 47 48 int dir_; … … 50 51 int width_; 51 52 int height_; 52 53 53 54 static Ogre::String& typeName_s; 54 55 55 56 public: 56 57 … … 75 76 76 77 }; 77 78 78 79 79 80 class _OrxonoxExport SmartBarOverlayElement : public BarOverlayElement … … 89 90 void initSmartBarOverlayElement(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height, int dir); 90 91 void reset(int percentage); 92 91 93 }; 92 93 94 94 } 95 95 -
code/branches/hud2/src/orxonox/hud/HUD.cc
r1099 r1254 33 33 #include <OgreSceneNode.h> 34 34 #include <OgreEntity.h> 35 #include "core/Debug.h" 35 36 36 37 #include "HUD.h" 37 38 #include "BarOverlayElement.h" 39 #include "RadarOverlayElement.h" 38 40 #include "OverlayElementFactories.h" 39 41 // ugly hack … … 55 57 overlayManager.addOverlayElementFactory(smartBarOverlayElementFactory); 56 58 59 RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory(); 60 overlayManager.addOverlayElementFactory(radarOverlayElementFactory); 61 57 62 Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); 58 63 … … 62 67 energyCounter->show(); 63 68 69 70 radar = static_cast<RadarOverlayElement*>(overlayManager.createOverlayElement("Radar", "radar")); 71 radar->show(); 72 73 74 /* TextAreaOverlayElement* test = static_cast<TextAreaOverlayElement*>(overlayManager.createOverlayElement("TextArea", "test")); 75 76 int dirX, dirY, dirZ; //flying direction 77 int ortX, ortY, ortZ; //orthogonal direction 78 int dX, dY, dZ; //distance between main ship and the object 79 int vecX, vecY, vecZ; //vector product dir X ort 80 double alpha; //defines the radius in the radar 81 double beta; //defines the angle in the radar 82 bool right; //checks whether the object is on the right side (since cos is not bijective) 83 84 dirX = 1; 85 dirY = 0; 86 dirZ = 0; 87 88 ortX = 0; 89 ortY = 0; 90 ortZ = 1; 91 92 dX = -2; 93 dY = 2; 94 dZ = 0; 95 96 alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2)))); 97 beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2)))); 98 vecX = dirY*ortZ - dirZ*ortY; 99 vecY = dirZ*ortX - dirX*ortZ; 100 vecZ = dirX*ortY - dirY*ortX; 101 102 if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;} 103 else right=false; 104 105 test->setCaption("hell"); 106 test->setPosition(10,10); 107 test->setDimensions(20,20); 108 test->show(); 109 test->setMetricsMode(Ogre::GMM_PIXELS); 110 energyCounterPanel->addChild(test); 111 112 COUT(0)<<alpha<<" "<<beta<<" "<<right<<std::endl; 113 */ 114 64 115 energyCounterPanel->addChild(energyCounter); 116 energyCounterPanel->addChild(radar); 65 117 energyCounterPanel->show(); 66 118 67 119 orxonoxOverlay->add2D(energyCounterPanel); 68 120 orxonoxOverlay->show(); 69 121 122 123 70 124 // important: don't use SceneManager to create the node! but register the creator scene manager. 71 125 /* ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely"); … … 88 142 energyCounter->initSmartBarOverlayElement(-100,0,200,20,BarOverlayElement::LEFT); 89 143 energyCounter->reset(80); 144 145 radar->initRadarOverlayElement(10,10,200,energyCounterPanel); 90 146 91 147 -
code/branches/hud2/src/orxonox/hud/HUD.h
r1099 r1254 39 39 #include "core/Tickable.h" 40 40 #include "BarOverlayElement.h" 41 #include "RadarOverlayElement.h" 41 42 42 43 … … 54 55 55 56 SmartBarOverlayElement* energyCounter; 57 58 RadarOverlayElement* radar; 56 59 // Ogre::SceneNode* ogreNode_; 57 60 }; 58 61 } 59 62 60 61 63 #endif -
code/branches/hud2/src/orxonox/hud/OverlayElementFactories.h
r1099 r1254 40 40 41 41 class _OrxonoxExport BarOverlayElementFactory : public Ogre::OverlayElementFactory{ 42 public:42 public: 43 43 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 44 44 return new BarOverlayElement(instanceName); … … 53 53 class _OrxonoxExport SmartBarOverlayElementFactory : public Ogre::OverlayElementFactory{ 54 54 public: 55 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 56 return new SmartBarOverlayElement(instanceName); 57 } 58 const Ogre::String& getTypeName(void) const{ 59 static Ogre::String name = "SmartBar"; 60 return name; 61 } 62 }; 63 64 class _OrxonoxExport RadarOverlayElementFactory : public Ogre::OverlayElementFactory{ 65 public: 55 66 Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){ 56 return new SmartBarOverlayElement(instanceName);67 return new RadarOverlayElement(instanceName); 57 68 } 58 69 const Ogre::String& getTypeName(void) const{ 59 static Ogre::String name = " SmartBar";70 static Ogre::String name = "Radar"; 60 71 return name; 61 72 } 62 73 }; 63 64 74 } 65 75 -
code/branches/hud2/src/orxonox/hud/RadarOverlayElement.cc
r1221 r1254 28 28 #include <OgreOverlayManager.h> 29 29 #include <OgreOverlayElement.h> 30 #include <OgrePanelOverlayElement.h> 31 30 32 #include <OgreStringConverter.h> 31 33 #include <math.h> … … 47 49 } 48 50 49 void RadarOverlayElement::initRadarOverlayElement(){ 51 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){ 52 50 53 int dirX, dirY, dirZ; //flying direction 51 54 int ortX, ortY, ortZ; //orthogonal direction … … 68 71 dZ = 0; 69 72 70 alpha = acos(( (double)(dirX*dX+dirY*dY+dirZ*dZ))/(sqrt((double)(pow(dX,2)+pow(dY,2)+pow(dZ,2)))+sqrt((double)(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2)))));71 beta = acos(( (double)(ortX*dX+ortY*dY+ortZ*dZ))/(sqrt((double)(pow(dX,2)+pow(dY,2)+pow(dZ,2)))+sqrt((double)(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2)))));73 alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2)))); 74 beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2)))); 72 75 vecX = dirY*ortZ - dirZ*ortY; 73 76 vecY = dirZ*ortX - dirX*ortZ; … … 76 79 if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;} 77 80 else right=false; 81 82 setMetricsMode(Ogre::GMM_PIXELS); 83 setPosition(left,top); 84 setDimensions(dim,dim); 85 setMaterialName("Orxonox/MapBackGround"); 86 87 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 78 88 89 PanelOverlayElement* point = static_cast<PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "point")); 90 point->show(); 91 92 container->addChild(point); 93 94 if (right){ 95 point->setPosition(sin(beta)*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2); 96 point->setMaterialName("Orxonox/Red"); 97 point->setDimensions(5,5); 98 point->setMetricsMode(Ogre::GMM_PIXELS); 99 } 100 101 else { 102 point->setPosition(-sin(beta)*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2); 103 point->setMaterialName("Orxonox/Red"); 104 point->setDimensions(5,5); 105 point->setMetricsMode(Ogre::GMM_PIXELS); 106 } 79 107 108 109 110 111 } 80 112 } 81 113 82 114 115 -
code/branches/hud2/src/orxonox/hud/RadarOverlayElement.h
r1218 r1254 32 32 #include <string.h> 33 33 #include <OgreOverlayElement.h> 34 #include <OgrePanelOverlayElement.h> 35 34 36 #include <OgrePrerequisites.h> 35 37 #include "../OrxonoxPrereqs.h" … … 50 52 virtual void initialise(); 51 53 52 54 void initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container); 53 55 }; 54 56 }
Note: See TracChangeset
for help on using the changeset viewer.