Changeset 1310 for code/branches/hud3/src/orxonox/hud
- Timestamp:
- May 16, 2008, 5:57:05 PM (17 years ago)
- Location:
- code/branches/hud3/src/orxonox/hud
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/HUD.cc
r1302 r1310 65 65 66 66 energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter")); 67 energyCounter->show();67 //energyCounter->show(); 68 68 69 69 … … 133 133 */ 134 134 135 energyCounterPanel->setLeft(-50); 136 energyCounterPanel->setTop(10); 137 energyCounterPanel->setWidth(100); 138 energyCounterPanel->setHeight(20); 139 energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER); 140 energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS); 135 energyCounterPanel->setLeft(0.0); 136 energyCounterPanel->setTop(0.0); 137 energyCounterPanel->setWidth(1.0); 138 energyCounterPanel->setHeight(1.0); 139 energyCounterPanel->setMetricsMode(Ogre::GMM_RELATIVE); 141 140 142 energyCounter->initSmartBarOverlayElement( -100,0,200,20,BarOverlayElement::LEFT);141 energyCounter->initSmartBarOverlayElement(10,10,200,20,BarOverlayElement::LEFT); 143 142 energyCounter->reset(80); 144 143 145 radar->initRadarOverlayElement( 10,10,200,energyCounterPanel);144 radar->initRadarOverlayElement(0.5, 0.8, 0.2, energyCounterPanel); 146 145 147 146 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1308 r1310 41 41 #include <OgreStringConverter.h> 42 42 #include "RadarOverlayElement.h" 43 #include "GraphicsEngine.h" 43 44 44 45 namespace orxonox … … 56 57 } 57 58 58 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){ 59 dim_ = dim; 60 left_ = left; 61 top_ = top; 62 count_ = 100; 59 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, Real dim, Ogre::OverlayContainer* container){ 60 61 windowW = GraphicsEngine::getSingleton().getWindowWidth(); 62 windowH = GraphicsEngine::getSingleton().getWindowHeight(); 63 dim_ = dim*windowH; //conver relative data to absolute 64 left_ = left*windowW-dim_/2; // ... 65 top_ = top*windowH-dim_/2; // ... 66 count_ = 0; 63 67 container_ = container; 64 68 … … 69 73 initialOrth_ = Vector3(0.0, 0.0, 1.0); 70 74 currentOrth_ = initialOrth_; 71 75 72 76 setMetricsMode(Ogre::GMM_PIXELS); 73 setPosition(left,top); 77 setMaterialName("Orxonox/Radar"); 78 setPosition(left_, top_); 74 79 setDimensions(dim_,dim_); 75 setMaterialName("Orxonox/Radar");76 80 77 81 om = &Ogre::OverlayManager::getSingleton(); … … 95 99 96 100 void RadarOverlayElement::update() { 97 if(count_++ >= 100) { // for testing purposes98 count_ = 0;99 COUT(3) << "pos: " << shipPos_ << std::endl;100 COUT(3) << "dir: " << currentDir_ << std::endl;101 COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl;102 }103 101 shipPos_ = SpaceShip::instance_s->getPosition(); 104 102 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 105 103 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 106 104 107 105 radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 108 106 phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length())); 109 vec_ = currentDir_.crossProduct(currentOrth_); 110 if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true; 107 if((currentDir_.crossProduct(currentOrth_)).dotProduct(targetPos_ - shipPos_) > 0) right_ = true; 111 108 else right_=false; 112 109 113 110 if (right_){ 114 point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 111 point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 115 112 } 116 113 else { -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
r1308 r1310 49 49 Ogre::OverlayContainer* container_; 50 50 Ogre::OverlayManager* om; //pointer to the one and only overlay manager 51 Vector3 initialDir_; // initial direction of ship52 Vector3 currentDir_; //current direction of ship53 Vector3 initialOrth_; 51 Vector3 initialDir_; // direction of nose 52 Vector3 currentDir_; 53 Vector3 initialOrth_; // direction of normal 54 54 Vector3 currentOrth_; 55 55 Vector3 targetPos_; //position of target 56 56 Vector3 shipPos_; //position of ship 57 Vector3 vec_; //vector product dir X ort 58 double radius_; //defines the radius in the radar59 double phi_; //defines the angle in the radar60 float left_, top_ ;57 58 double radius_; //defines the radius on the radar 59 double phi_; //defines the angle on the radar 60 float left_, top_, dim_; 61 61 bool right_; //checks whether the object is on the right side (since cos is not bijective) 62 62 int count_; 63 int dim_;63 int windowW, windowH; 64 64 65 65 public: … … 69 69 virtual void initialise(); 70 70 void update(); 71 void initRadarOverlayElement(Real left, Real top, intdim, Ogre::OverlayContainer* container);71 void initRadarOverlayElement(Real left, Real top, Real dim, Ogre::OverlayContainer* container); 72 72 void setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ); 73 73 int newShip(int X, int Y, int Z);
Note: See TracChangeset
for help on using the changeset viewer.