Changeset 6834
- Timestamp:
- May 3, 2010, 1:40:16 PM (15 years ago)
- Location:
- code/branches/rocket
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket/data/levels/includes/weaponsettings3.oxi
r6814 r6834 39 39 </Weapon> 40 40 <Weapon> 41 <SimpleRocketFire mode=2 muzzleoffset=" 0,0,0" />41 <SimpleRocketFire mode=2 muzzleoffset="10,10,10" /> 42 42 </Weapon> 43 43 </WeaponPack> -
code/branches/rocket/src/modules/weapons/RocketController.cc
r6817 r6834 32 32 #include "weapons/projectiles/SimpleRocket.h" 33 33 #include "util/Debug.h" 34 34 #include "weapons/weaponmodes/SimpleRocketFire.h" 35 35 36 36 namespace orxonox … … 45 45 46 46 RegisterObject(RocketController); 47 SimpleRocket*rocket = new SimpleRocket(this);48 rocket->setController(this);47 this->rocket = new SimpleRocket(this); 48 this->rocket->setController(dynamic_cast<RocketController*>(this)); 49 49 this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket)); 50 51 50 } 52 51 … … 62 61 63 62 SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity()); 64 65 66 rocket->rotateYaw(0.2); 67 //rocket->moveFrontBack(2); 63 double rd = rand(); 64 if (rd > 0.5) rocket->rotateRoll(5); 65 else rocket->rotatePitch(5); 68 66 69 67 } -
code/branches/rocket/src/modules/weapons/RocketController.h
r6814 r6834 35 35 #include "tools/interfaces/Tickable.h" 36 36 #include "weapons/projectiles/SimpleRocket.h" 37 #include "weapons/weaponmodes/SimpleRocketFire.h" 37 38 38 39 namespace orxonox … … 51 52 52 53 virtual void tick(float dt); 54 SimpleRocket* getRocket(){return rocket;}; 53 55 protected: 54 56 55 57 56 58 private: 59 SimpleRocket* rocket; 57 60 58 61 }; -
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
r6827 r6834 60 60 this->lifetime_ = 100; 61 61 COUT(0)<< "simplerocket constructed\n"; 62 //this->camera_ = null; 63 //RocketController* myRController = new RocketController(this); 64 //this->setController(creator); 65 //myRController->setRocket(this, myRController); 66 67 //this->getController()->setControllableEntity(this); 68 //myController->setControllableEntity(this); 69 //this->getController()->setControllableEntity(this); 70 //this->controllableEntity_->setController(this->controller_); 62 71 63 72 64 //if (GameMode::isMaster()) 73 65 //{ 74 /*this->setCollisionType(WorldEntity::Kinematic);75 this->setVelocity(0,0, -100);*/66 this->setCollisionType(WorldEntity::Kinematic); 67 this->setVelocity(0,0,100); 76 68 77 69 Model* model = new Model(this); 78 70 model->setMeshSource("rocket.mesh"); 79 //model->scale(0.7f);71 model->scale(0.7f); 80 72 this->attach(model); 81 /* ParticleEmitter* fire = new ParticleEmitter(this); 73 74 ParticleEmitter* fire = new ParticleEmitter(this); 82 75 this->attach(fire); 83 76 fire->setOrientation(this->getOrientation()); 84 fire->setSource("Orxonox/ Rocketfire");77 fire->setSource("Orxonox/rocketfire2"); 85 78 86 79 this->enableCollisionCallback(); … … 91 84 collisionShape->setRadius(3); 92 85 collisionShape->setHeight(500); 93 this->attachCollisionShape(collisionShape); */86 this->attachCollisionShape(collisionShape); 94 87 95 88 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this))); … … 127 120 } 128 121 129 /**130 @brief131 Defines which actions the SimpleRocket has to take in each tick.132 @param dt133 The length of the tick.134 */135 void SimpleRocket::tick(float dt)136 {137 SUPER(SimpleRocket, tick, dt);138 139 if( this->hasLocalController() )140 {141 this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);142 this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );143 this->localAngularVelocity_ = 0;144 145 if( this->bDestroy_ )146 this->destroy();147 }148 }149 122 150 123 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) -
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
r6778 r6834 53 53 54 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a SimpleRocket through XML. 55 virtual void tick(float dt); //!< Defines which actions the SimpleRocket has to take in each tick.56 55 57 56 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); -
code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r6827 r6834 45 45 { 46 46 RegisterObject(SimpleRocketFire); 47 47 48 48 49 /* this->reloadTime_ = 0.20f; … … 61 62 void SimpleRocketFire::fire() 62 63 { 63 SimpleRocket* rocket = new SimpleRocket(this); 64 RocketController* con = new RocketController(this); 64 //SimpleRocket* rocket = new SimpleRocket(this); 65 RocketController* con = new RocketController(this); 66 SimpleRocket* rocket = con->getRocket(); 67 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 68 rocket->setOrientation(this->getMuzzleOrientation()); 69 rocket->setPosition(this->getMuzzlePosition()); 70 rocket->setVelocity(this->getMuzzleDirection() * rocket->getVelocity()); 71 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 72 //con->getRocket()->setPosition(this->getMuzzlePosition()); 73 //con->setControllableEntity(dynamic_cast<ControllableEntity*>(rocket)); 74 //con->getControllableEntity()->setPosition(this->getMuzzlePosition()); 65 75 66 67 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 76 /* this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 68 77 rocket->setOrientation(this->getMuzzleOrientation()); 69 78 rocket->setPosition(this->getMuzzlePosition()); 70 rocket->scale(10);79 rocket->scale(10); 71 80 rocket->setVelocity(this->getMuzzleDirection() * this->speed_); 72 81 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 73 rocket->setDamage(this->getDamage()); 74 //rocket->scale(2);75 82 rocket->setDamage(this->getDamage()); 83 rocket->scale(2); 84 */ 76 85 } 77 86 }
Note: See TracChangeset
for help on using the changeset viewer.