- Timestamp:
- May 16, 2008, 5:57:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note: See TracChangeset
for help on using the changeset viewer.