- Timestamp:
- May 20, 2008, 1:38:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1329 r1335 53 53 } 54 54 55 void RadarOverlayElement::initialise(){56 PanelOverlayElement::initialise();57 }58 59 55 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){ 60 count_ = 0; 56 om = &Ogre::OverlayManager::getSingleton(); 61 57 dimRel_ = dimRel; 62 58 leftRel_ = leftRel; … … 65 61 66 62 shipPos_ = Vector3(0.0, 0.0, 0.0); 67 targetPos_ = Vector3(1337.0, 0.0, 0.0);68 63 initialDir_ = Vector3(1.0, 0.0, 0.0); 69 64 currentDir_ = initialDir_; … … 74 69 setMaterialName("Orxonox/Radar"); 75 70 resize(); 76 77 om = &Ogre::OverlayManager::getSingleton(); 78 point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point")); 79 point->show(); 80 container->addChild(this); 81 container->addChild(point); 82 point->setMaterialName("Orxonox/RedDot"); 83 point->setDimensions(5,5); 84 point->setMetricsMode(Ogre::GMM_PIXELS); 85 71 72 container_->addChild(this); 86 73 } 87 74 … … 102 89 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 103 90 104 radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 105 phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length())); 106 if((currentDir_.crossProduct(currentOrth_)).dotProduct(targetPos_ - shipPos_) > 0) right_ = true; 107 else right_=false; 91 if(tomato_ == NULL) return; 92 93 tomato_->radius_ = acos((currentDir_.dotProduct(tomato_->pos_ - shipPos_))/ 94 ((tomato_->pos_ - shipPos_).length()*currentDir_.length())); 95 tomato_->phi_ = acos((currentOrth_.dotProduct(tomato_->pos_ - shipPos_))/ 96 ((tomato_->pos_ - shipPos_).length()*currentOrth_.length())); 97 if((currentDir_.crossProduct(currentOrth_)).dotProduct(tomato_->pos_ - shipPos_) > 0) 98 tomato_->right_ = true; 99 else tomato_->right_=false; 108 100 109 if (right_){ 110 point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 101 if (tomato_->right_){ 102 tomato_->panel_->setPosition(sin(tomato_->phi_)*tomato_->radius_/ 103 3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2); 111 104 } 112 105 else { 113 point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 106 tomato_->panel_->setPosition(-sin(tomato_->phi_)*tomato_->radius_/ 107 3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2); 114 108 } 115 109 } 116 110 111 void RadarOverlayElement::addObject(Vector3 pos){ 112 tomato_ = new RadarObject(container_); 113 tomato_->pos_ = pos; 114 } 115 116 //// RadarObject //// 117 118 int RadarObject::count = 0; 119 120 RadarObject::RadarObject(Ogre::OverlayContainer* container){ 121 container_ = container; 122 pos_ = Vector3(0.0, 0.0, 0.0); 123 init(); 124 } 125 126 RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){ 127 container_ = container; 128 pos_ = pos; 129 init(); 130 } 131 132 RadarObject::~RadarObject(){} 133 134 void RadarObject::init(){ 135 om = &Ogre::OverlayManager::getSingleton(); 136 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 137 "Object"+Ogre::StringConverter::toString(count++))); 138 panel_->setMaterialName("Orxonox/RedDot"); 139 panel_->setDimensions(5,5); 140 panel_->setMetricsMode(Ogre::GMM_PIXELS); 141 panel_->show(); 142 container_->addChild(panel_); 143 } 117 144 } 118 145 119 120 146 /* my local clipboard... 147 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 148 COUT(3) << tomato_->radius_ << " " << tomato_->phi_ << std::endl; 149 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 150 */
Note: See TracChangeset
for help on using the changeset viewer.