Changeset 6905
- Timestamp:
- May 15, 2010, 6:12:13 PM (15 years ago)
- Location:
- code/branches/rocket/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket/src/modules/weapons/RocketController.cc
r6904 r6905 63 63 { 64 64 haha++; 65 65 66 66 67 SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity()); 68 if (haha<30)rocket->setVelocity(rocket->getVelocity()*1.03); 67 69 if (this->target_) { 68 rocket->rotatePitch(0.5); 69 rocket->rotateYaw(0.5); 70 this->setTargetPosition(); 71 this->moveToTargetPosition(); 72 70 73 } 71 rocket->setVelocity(rocket->getVelocity()*1.03); 74 75 if (haha>500) rocket->setDestroy();; 72 76 73 77 } … … 80 84 } 81 85 86 void RocketController::setTargetPosition() { 87 this->targetPosition_=this->target_->getPosition(); 88 //this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getPosition(), this->target_->getVelocity()); 89 } 90 void RocketController::moveToTargetPosition() { 91 this->moveToPosition(this->targetPosition_); 92 } 82 93 83 void RocketController::setTarget(Pawn* target) { 94 95 96 void RocketController::setTarget(WorldEntity* target) { 84 97 this->target_ = target; 98 COUT(0)<<"got target\n"; 85 99 } 100 101 void RocketController::moveToPosition(const Vector3& target) 102 { 103 if (!this->getControllableEntity()) 104 return; 105 106 COUT(0)<<"moving"; 107 108 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 109 float distance = (target - this->getControllableEntity()->getPosition()).length(); 110 111 if (this->target_ || distance > 10) 112 { 113 // Multiply with 0.8 to make them a bit slower 114 this->getControllableEntity()->rotateYaw(-0.2f * sgn(coord.x) * coord.x*coord.x); 115 this->getControllableEntity()->rotatePitch(0.2f * sgn(coord.y) * coord.y*coord.y); 116 117 } 118 } 86 119 87 120 -
code/branches/rocket/src/modules/weapons/RocketController.h
r6903 r6905 53 53 virtual void tick(float dt); 54 54 SimpleRocket* getRocket(){return this->rocket;}; 55 void setTarget( Pawn* target);55 void setTarget(WorldEntity* target); 56 56 protected: 57 57 void moveToPosition(const Vector3& target); 58 void setTargetPosition(); 59 void moveToTargetPosition(); 58 60 59 61 private: 60 62 SimpleRocket* rocket; 63 Vector3 targetPosition_; 61 64 WeakPtr<PlayerInfo> player_; 62 65 int haha; 63 WeakPtr< Pawn> target_;66 WeakPtr<WorldEntity> target_; 64 67 65 68 -
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
r6902 r6905 180 180 } 181 181 } 182 void SimpleRocket::setDestroy() { 183 this->bDestroy_=true; 184 COUT(0)<<"trying to destroy"; 185 } 182 186 183 187 void SimpleRocket::fired(unsigned int firemode) -
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
r6900 r6905 64 64 virtual void rotatePitch(const Vector2& value); 65 65 virtual void rotateRoll(const Vector2& value); 66 void setDestroy(); 66 67 67 68 /** … … 95 96 */ 96 97 inline void rotatePitch(float value) 97 { this->rotatePitch(Vector2(value, 0)); } 98 { COUT(0)<<"rotated rocket yaw"; 99 this->rotatePitch(Vector2(value, 0)); } 98 100 /** 99 101 @brief Rotates the SimpleRocket around the z-axis by the specifed amount. … … 101 103 */ 102 104 inline void rotateRoll(float value) 103 { this->rotateRoll(Vector2(value, 0)); } 105 { 106 COUT(0)<<"rotated rocket roll"; 107 this->rotateRoll(Vector2(value, 0)); } 104 108 105 109 void setOwner(Pawn* owner); -
code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r6900 r6905 69 69 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 70 70 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 71 rocket->setDamage(this->damage_); 72 WorldEntity* pawnn=(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget()); 73 if (pawnn) { 74 con->setTarget(pawnn); 75 } 71 76 } 72 77 } -
code/branches/rocket/src/orxonox/controllers/DroneController.cc
r6903 r6905 49 49 assert(dynamic_cast<Drone*>(creator)!=0); 50 50 this->setControllableEntity(dynamic_cast<Drone*>(creator)); 51 this->counter=0; 51 52 } 52 53 … … 63 64 void DroneController::tick(float dt) 64 65 { 66 this->counter++; 65 67 // Place your code here: 66 68 // - steering commands … … 70 72 // - rotatePitch, rotateYaw, rotateRoll 71 73 // - apply the to myDrone (e.g. myDrone->rotateYaw(..) ) 72 73 myDrone-> rotateYaw(0.2);74 myDrone->rotatePitch(0.08); 75 myDrone->moveFrontBack(1); 74 76 75 77 } -
code/branches/rocket/src/orxonox/controllers/DroneController.h
r6778 r6905 54 54 55 55 private: 56 int counter; 56 57 }; 57 58 } -
code/branches/rocket/src/orxonox/controllers/NewHumanController.cc
r6903 r6905 574 574 } 575 575 } 576 577 Pawn* NewHumanController::getRocketTarget() {578 579 580 Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());581 582 Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5f, static_cast<float>(this->currentPitch_)/2*-1+.5f);583 584 rsq->setRay(mouseRay);585 rsq->setSortByDistance(true);586 587 /*588 Distance of objects:589 ignore everything under 200 maybe even take 1000 as min distance to shoot at590 591 shots are regularly traced and are entities!!!!!!!!! this is the biggest problem592 they vanish only after a distance of 10'000593 */594 595 596 Ogre::RaySceneQueryResult& result = rsq->execute();597 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());598 599 Ogre::RaySceneQueryResult::iterator itr;600 for (itr = result.begin(); itr != result.end(); ++itr)601 {602 if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)603 {604 // Try to cast the user pointer605 WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));606 if (wePtr)607 {608 // go through all parents of object and look whether they are sightable or not609 bool isSightable = false;610 WorldEntity* parent = wePtr->getParent();611 while (parent)612 {613 if (this->targetMask_.isExcluded(parent->getIdentifier()))614 {615 parent = parent->getParent();616 continue;617 }618 else619 {620 isSightable = true;621 break;622 }623 }624 if (!isSightable)625 continue;626 }627 628 return dynamic_cast<Pawn*> (wePtr);629 }630 }631 }632 576 633 577 -
code/branches/rocket/src/orxonox/controllers/NewHumanController.h
r6903 r6905 67 67 virtual void doResumeControl(); 68 68 69 Pawn* getRocketTarget();70 71 69 72 70 protected: -
code/branches/rocket/src/orxonox/worldentities/Drone.cc
r6778 r6905 49 49 this->myController_ = 0; 50 50 51 this->localLinearAcceleration_.setValue( 0, 0, 0);51 this->localLinearAcceleration_.setValue(1, 1, 1); 52 52 this->localAngularAcceleration_.setValue(0, 0, 0); 53 53 this->primaryThrust_ = 100;
Note: See TracChangeset
for help on using the changeset viewer.