- Timestamp:
- May 16, 2008, 11:27:09 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1302 r1308 60 60 left_ = left; 61 61 top_ = top; 62 count_ = 0;62 count_ = 100; 63 63 container_ = container; 64 64 65 65 shipPos_ = Vector3(0.0, 0.0, 0.0); 66 targetPos_ = Vector3(42.0, 42.0, 0.0);67 initialDir_ = Vector3( 0.0, 0.0, 1.0);66 targetPos_ = Vector3(42.0, 0.0, 0.0); 67 initialDir_ = Vector3(1.0, 0.0, 0.0); 68 68 currentDir_ = initialDir_; 69 initialOrth_ = Vector3(0.0, 1.0, 0.0);69 initialOrth_ = Vector3(0.0, 0.0, 1.0); 70 70 currentOrth_ = initialOrth_; 71 72 alpha_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 73 beta_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length())); 74 vec_ = currentDir_.crossProduct(currentOrth_); 75 76 if(vec_.dotProduct(targetPos_ - shipPos_) > 0) 77 right_ = true; 78 else 79 right_=false; 80 71 81 72 setMetricsMode(Ogre::GMM_PIXELS); 82 73 setPosition(left,top); … … 88 79 point->show(); 89 80 container->addChild(point); 81 point->setMaterialName("Orxonox/RedPoint"); 82 point->setDimensions(5,5); 83 point->setMetricsMode(Ogre::GMM_PIXELS); 90 84 91 if (right_){92 point->setPosition(sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);93 point->setMaterialName("Orxonox/RedPoint");94 point->setDimensions(5,5);95 point->setMetricsMode(Ogre::GMM_PIXELS);96 }97 98 else {99 point->setPosition(-sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);100 point->setMaterialName("Orxonox/RedPoint");101 point->setDimensions(5,5);102 point->setMetricsMode(Ogre::GMM_PIXELS);103 }104 85 } 105 86 … … 114 95 115 96 void RadarOverlayElement::update() { 97 if(count_++ >= 100) { // for testing purposes 98 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 } 116 103 shipPos_ = SpaceShip::instance_s->getPosition(); 117 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 104 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 105 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 106 107 radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 108 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; 111 else right_=false; 112 113 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); 115 } 116 else { 117 point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 118 } 118 119 } 119 120
Note: See TracChangeset
for help on using the changeset viewer.