Changeset 1566 for code/trunk/src/orxonox
- Timestamp:
- Jun 8, 2008, 5:04:18 PM (17 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/hud/Navigation.cc
r1564 r1566 36 36 // TODO: remove the SpaceShip and CameraHandler dependencies 37 37 #include "objects/SpaceShip.h" 38 #include "objects/Projectile.h" 38 39 #include "objects/CameraHandler.h" 39 40 #include "RadarObject.h" … … 87 88 navMarker_->hide(); 88 89 aimMarker_->hide(); 90 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 91 aimMarker_->setDimensions(20, 20); 92 aimMarker_->setUV(0.0, 0.0, 1.0, 1.0); 89 93 container_->addChild(navMarker_); 90 94 container_->addChild(aimMarker_); … … 106 110 navText_->setCaption(Ogre::StringConverter::toString(dist)); 107 111 108 Vector3 pos = focus_->getPosition();109 112 Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_; 110 113 // transform to screen coordinates 111 pos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * pos; 114 Vector3 pos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * focus_->getPosition(); 115 Vector3 aimpos = navCam->getProjectionMatrix() * navCam->getViewMatrix() * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), Projectile::getSpeed(), focus_->getPosition(), focus_->getOrientedVelocity()); 112 116 113 117 float xPosRel = 0.5*pos.x+0.5; 114 118 float yPosRel = 1-(0.5*pos.y+0.5); 119 float xAimPosRel = 0.5*aimpos.x+0.5; 120 float yAimPosRel = 1-(0.5*aimpos.y+0.5); 115 121 int xPos = (int) (xPosRel*windowW); 116 122 int yPos = (int) (yPosRel*windowH); 123 int xAimPos = (int) (xAimPosRel*windowW); 124 int yAimPos = (int) (yAimPosRel*windowH); 117 125 int xFromCenter = xPos-windowW/2; 118 126 int yFromCenter = yPos-windowH/2; … … 133 141 navMarker_->setMaterialName("Orxonox/NavArrows"); 134 142 navMarker_->setDimensions(16,16); 143 aimMarker_->hide(); 135 144 float phiUpperCorner = atan((float)(windowW)/(float)(windowH)); 136 145 // from the angle we find out on which edge to draw the marker … … 210 219 // object is in view 211 220 navMarker_->setMaterialName("Orxonox/NavTDC"); 212 navMarker_->setDimensions( 24,24);221 navMarker_->setDimensions(35, 35); 213 222 navMarker_->setUV(0.0, 0.0, 1.0, 1.0); 214 223 navMarker_->setPosition(xPos-navMarker_->getWidth()/2, yPos-navMarker_->getHeight()/2); 224 225 aimMarker_->show(); 226 aimMarker_->setPosition(xAimPos-aimMarker_->getWidth()/2, yAimPos-aimMarker_->getHeight()/2); 227 215 228 navText_->setPosition(xPos+navMarker_->getWidth()/2, yPos+navMarker_->getHeight()/2); 216 229 } … … 259 272 if(focus_ == NULL){ 260 273 navMarker_->hide(); 274 aimMarker_->hide(); 261 275 navText_->hide(); 262 276 } -
code/trunk/src/orxonox/hud/RadarObject.cc
r1564 r1566 120 120 } 121 121 122 const Vector3& RadarObject::getVelocity() const122 Vector3 RadarObject::getOrientedVelocity() const 123 123 { 124 return this->object_->get Velocity();124 return this->object_->getOrientation() * this->object_->getVelocity(); 125 125 } 126 126 } -
code/trunk/src/orxonox/hud/RadarObject.h
r1564 r1566 54 54 55 55 const Vector3& getPosition() const; 56 const Vector3& getVelocity() const;56 Vector3 getOrientedVelocity() const; 57 57 58 58 inline WorldEntity* getObject() const -
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1564 r1566 238 238 this->setMovePitch(0.8 * sgn(coord.y)); 239 239 240 if ((this->targetPosition_ - this->getPosition()).length() > 300)240 if ((this->targetPosition_ - this->getPosition()).length() > 500) 241 241 this->setMoveLongitudinal(0.8); 242 242 … … 287 287 return; 288 288 289 Vector3 enemymovement = this->target_->getVelocity(); 290 Vector3 distance_normalised = this->target_->getPosition() - this->getPosition(); 291 distance_normalised.normalise(); 292 293 float scalarprod = enemymovement.dotProduct(distance_normalised); 294 float aimoffset = scalarprod*scalarprod + Projectile::getSpeed() * Projectile::getSpeed() - this->target_->getVelocity().squaredLength(); 295 296 if (aimoffset < 0) 297 { 298 this->bHasTargetPosition_ = false; 299 return; 300 } 301 aimoffset = -scalarprod + sqrt(aimoffset); 302 this->targetPosition_ = this->getPosition() + enemymovement + distance_normalised * aimoffset; 303 this->bHasTargetPosition_ = true; 289 this->targetPosition_ = getPredictedPosition(this->getPosition(), Projectile::getSpeed(), this->target_->getPosition(), this->target_->getOrientation() * this->target_->getVelocity()); 290 this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO); 304 291 } 305 292
Note: See TracChangeset
for help on using the changeset viewer.