Changeset 1564 for code/trunk/src/orxonox/objects
- Timestamp:
- Jun 8, 2008, 5:46:52 AM (17 years ago)
- Location:
- code/trunk/src/orxonox/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/SpaceShip.cc
r1563 r1564 152 152 153 153 if (!this->myShip_) 154 HUD::getSingleton().removeRadarObject(this ->getNode());154 HUD::getSingleton().removeRadarObject(this); 155 155 } 156 156 } … … 161 161 myShip_=true; 162 162 else 163 HUD::getSingleton().addRadarObject(this ->getNode(), this->getProjectileColour());163 HUD::getSingleton().addRadarObject(this, this->getProjectileColour()); 164 164 } 165 165 if(Model::create()) … … 508 508 this->mouseXRotation_ = Radian(0); 509 509 this->mouseYRotation_ = Radian(0); 510 this->bLMousePressed_ = false;511 510 }/*else 512 511 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/ 512 513 this->bLMousePressed_ = false; 513 514 } 514 515 -
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1563 r1564 226 226 this->moveToTargetPosition(dt); 227 227 228 if (this->bShooting_ && this->isCloseAtTarget(2500) && this->isLookingAtTarget(Ogre::Math::PI / 10))228 if (this->bShooting_ && this->isCloseAtTarget(2500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0)) 229 229 this->doFire(); 230 230 … … 234 234 void SpaceShipAI::moveToTargetPosition(float dt) 235 235 { 236 Vector3 proj = Ogre::Plane(this->getDir(), this->getPosition()).projectVector(this->targetPosition_ - this->getPosition()); 237 float angle = acos((this->getOrth().dotProduct(proj)) / (this->getOrth().length()*proj.length())); 238 239 if ((this->getDir().crossProduct(this->getOrth())).dotProduct(this->targetPosition_ - this->getPosition()) > 0) 240 this->setMoveYaw(sgn(sin(angle))); 241 else 242 this->setMoveYaw(-sgn(sin(angle))); 243 this->setMovePitch(sgn(cos(angle))); 236 Vector2 coord = get2DViewdirection(this->getPosition(), this->getDir(), this->getOrth(), this->targetPosition_); 237 this->setMoveYaw(0.8 * sgn(coord.x)); 238 this->setMovePitch(0.8 * sgn(coord.y)); 244 239 245 240 if ((this->targetPosition_ - this->getPosition()).length() > 300) 246 this->setMoveLongitudinal( 1);241 this->setMoveLongitudinal(0.8); 247 242 248 243 if (this->isCloseAtTarget(300) && this->target_) 249 244 { 250 245 if (this->getVelocity().length() > this->target_->getVelocity().length()) 251 this->setMoveLongitudinal(- 1);246 this->setMoveLongitudinal(-0.5); 252 247 } 253 248 } … … 319 314 bool SpaceShipAI::isLookingAtTarget(float angle) 320 315 { 321 Vector3 dist = this->targetPosition_ - this->getPosition(); 322 return (acos((this->getDir().dotProduct(dist)) / (dist.length() * this->getDir().length())) < angle); 316 return (getAngle(this->getPosition(), this->getDir(), this->targetPosition_) < angle); 323 317 } 324 318
Note: See TracChangeset
for help on using the changeset viewer.