Changeset 6065
- Timestamp:
- Nov 15, 2009, 1:15:42 PM (15 years ago)
- Location:
- code/branches/particles2
- Files:
-
- 3 deleted
- 6 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particles2/data/levels/empty_level.oxw
r6059 r6065 18 18 > 19 19 20 < Rocket position="-10, 3.5,800" velocity="0,0,-100">20 <!--Rocket position="-10, 3.5,800" velocity="0,0,-100"> 21 21 <attached> 22 22 <Model pitch=180 position="0,0,0" scale=1.5 mesh="rocket_test.mesh" > … … 29 29 </Model> 30 30 </attached> 31 </Rocket >31 </Rocket--> 32 32 33 33 -
code/branches/particles2/data/levels/includes/weaponsettings3.oxi
r5781 r6065 2 2 <WeaponSlot position="-15.0,-1.5,0" /> 3 3 <WeaponSlot position=" 15.0,-1.5,0" /> 4 <WeaponSlot position=" 0.0, 0.0,0" />4 <WeaponSlot position=" 0, 0,0" /> 5 5 </weaponslots> 6 6 <weaponsets> 7 7 <WeaponSet firemode=0 /> 8 8 <WeaponSet firemode=1 /> 9 <WeaponSet firemode=2 /> 9 10 </weaponsets> 10 11 <weapons> … … 13 14 <DefaultWeaponmodeLink firemode=0 weaponmode=0 /> 14 15 <DefaultWeaponmodeLink firemode=1 weaponmode=1 /> 16 <DefaultWeaponmodeLink firemode=2 weaponmode=2 /> 15 17 </links> 16 18 <Weapon> … … 36 38 <LightningGun mode=1 muzzleoffset="0,0,0" /> 37 39 </Weapon> 40 <Weapon> 41 <RocketFire mode=2 muzzleoffset="0,0,0" /> 42 </Weapon> 38 43 </WeaponPack> 39 44 <WeaponPack> -
code/branches/particles2/src/modules/weapons/projectiles/CMakeLists.txt
r5781 r6065 4 4 Projectile.cc 5 5 LightningGunProjectile.cc 6 Rocket.cc 6 7 ) -
code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
r6059 r6065 31 31 #include "core/XMLPort.h" 32 32 #include "BulletDynamics/Dynamics/btRigidBody.h" 33 #include "worldentities/pawns/Pawn.h" 34 #include "graphics/ParticleSpawner.h" 35 #include "graphics/Model.h" 36 #include "objects/collisionshapes/ConeCollisionShape.h" 33 37 34 38 namespace orxonox … … 43 47 Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator) 44 48 { 45 this->myController_ = 0;46 // put your code in here:47 49 RegisterObject(Rocket);// - register the Rocket class to the core 48 50 49 this->localLinearAcceleration_.setValue(0, 0, 0); 50 this->localAngularAcceleration_.setValue(0, 0, 0); 51 this->primaryThrust_ = 100; 52 this->auxilaryThrust_ = 100; 53 this->rotationThrust_ = 10; 51 this->setCollisionType(WorldEntity::Kinematic); 52 this->setVelocity(0,0,-100); 53 this->model_ = new Model(this); 54 this->model_->setMeshSource("can.mesh"); 55 this->attach(this->model_); 56 this->lifetime_ = 100; 54 57 55 this->setCollisionType(WorldEntity::Kinematic); 56 57 this->myController_ = new RocketController(static_cast<BaseObject*>(this)); //!< Creates a new controller and passes our this pointer to it as creator. 58 if (GameMode::isMaster()) 59 { 60 this->enableCollisionCallback(); 61 this->setCollisionResponse(false); 62 this->setCollisionType(Kinematic); 63 64 this->collisionShape_ = new ConeCollisionShape(this); 65 this->collisionShape_->setRadius(3); 66 this->collisionShape_->setHeight(500); 67 this->attachCollisionShape(this->collisionShape_); 68 69 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Rocket::destroyObject, this))); 70 } 58 71 } 59 72 … … 64 77 Rocket::~Rocket() 65 78 { 66 if( this->myController_ != NULL ) 67 this->myController_->destroy(); 79 if(this->isInitialized()) 80 { 81 this->collisionShape_->destroy(); 82 this->model_->destroy(); 83 } 68 84 } 69 85 … … 76 92 // this calls the XMLPort function of the parent class 77 93 SUPER(Rocket, XMLPort, xmlelement, mode); 78 79 // put your code in here: 80 XMLPortParam(Rocket, "primaryThrust", setPrimaryThrust, getPrimaryThrust, xmlelement, mode); 81 //XMLPortParam(Rocket, "auxilaryThrust", setAuxilaryThrust, getAuxilaryThrust, xmlelement, mode); 82 //XMLPortParam(Rocket, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode); 83 // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport 84 // make sure that the set- and get-functions exist. 85 // variables can be added by the following command 86 // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode) 87 94 } 95 96 void Rocket::setOwner(Pawn* owner) 97 { 98 this->owner_ = owner; 88 99 } 89 100 … … 98 109 SUPER(Rocket, tick, dt); 99 110 100 //if (this->hasLocalController()) 101 //{ 102 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 103 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 104 if (this->localLinearAcceleration_.z() > 0) 105 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 106 else 107 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 108 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 109 this->localLinearAcceleration_.setValue(0, 0, 0); 110 111 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 112 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 113 this->localAngularAcceleration_.setValue(0, 0, 0); 114 //} 111 this->setAngularVelocity(this->localAngularVelocity_); 115 112 } 116 113 117 /** 118 @brief 119 Moves the Rocket in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector. 120 @param value 121 The vector determining the amount of the movement. 122 */ 123 void Rocket::moveFrontBack(const Vector2& value) 114 bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 124 115 { 125 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x); 116 if (!this->bDestroy_ && GameMode::isMaster()) 117 { 118 if (otherObject == this->owner_) 119 return false; 120 121 this->bDestroy_ = true; 122 123 if (this->owner_) 124 { 125 { 126 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 127 effect->setPosition(this->getPosition()); 128 effect->setOrientation(this->getOrientation()); 129 effect->setDestroyAfterLife(true); 130 effect->setSource("Orxonox/explosion3"); 131 effect->setLifetime(2.0f); 132 } 133 { 134 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 135 effect->setPosition(this->getPosition()); 136 effect->setOrientation(this->getOrientation()); 137 effect->setDestroyAfterLife(true); 138 effect->setSource("Orxonox/smoke4"); 139 effect->setLifetime(3.0f); 140 } 141 } 142 143 float dmg = this->damage_; 144 if (this->owner_) 145 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false); 146 147 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 148 if (victim) 149 victim->damage(dmg, this->owner_); 150 } 151 return false; 126 152 } 127 128 /** 129 @brief 130 Moves the Rocket in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector. 131 @param value 132 The vector determining the amount of the movement. 133 */ 134 void Rocket::moveRightLeft(const Vector2& value) 153 154 void Rocket::destroyObject() 135 155 { 136 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x); 137 } 138 139 /** 140 @brief 141 Moves the Rocket in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector. 142 @param value 143 The vector determining the amount of the movement. 144 */ 145 void Rocket::moveUpDown(const Vector2& value) 146 { 147 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x); 156 if (GameMode::isMaster()) 157 this->destroy(); 148 158 } 149 159 … … 156 166 void Rocket::rotateYaw(const Vector2& value) 157 167 { 158 this->localAngular Acceleration_.setY(this->localAngularAcceleration_.y() - value.x);168 this->localAngularVelocity_.y = value.x; 159 169 } 160 170 … … 167 177 void Rocket::rotatePitch(const Vector2& value) 168 178 { 169 this->localAngular Acceleration_.setX(this->localAngularAcceleration_.x() + value.x);179 this->localAngularVelocity_.x = value.x; 170 180 } 171 181 … … 178 188 void Rocket::rotateRoll(const Vector2& value) 179 189 { 180 this->localAngular Acceleration_.setZ(this->localAngularAcceleration_.z() + value.x);190 this->localAngularVelocity_.z = value.x; 181 191 } 182 192 -
code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
r6059 r6065 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "worldentities/ControllableEntity.h" 34 #include "controllers/RocketController.h"35 34 36 35 namespace orxonox 37 36 { 37 class ConeCollisionShape; 38 38 39 39 /** … … 52 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Rocket through XML. 53 53 virtual void tick(float dt); //!< Defines which actions the Rocket has to take in each tick. 54 55 54 56 virtual void moveFrontBack(const Vector2& value); 57 virtual void moveRightLeft(const Vector2& value); 58 virtual void moveUpDown(const Vector2& value); 55 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 56 void destroyObject(); 57 58 virtual void moveFrontBack(const Vector2& value){} 59 virtual void moveRightLeft(const Vector2& value){} 60 virtual void moveUpDown(const Vector2& value){} 59 61 60 62 virtual void rotateYaw(const Vector2& value); … … 100 102 { this->rotateRoll(Vector2(value, 0)); } 101 103 102 /** 103 @brief Sets the primary thrust to the input amount. 104 @param thrust The amount of thrust. 105 */ 106 inline void setPrimaryThrust( float thrust ) 107 { this->primaryThrust_=thrust; } 108 // place your set-functions here. 109 // - hint: auxiliary thrust, rotation thrust. 110 111 /** 112 @brief Gets the primary thrust to the input amount. 113 @preturn The amount of thrust. 114 */ 115 inline float getPrimaryThrust() 116 { return this->primaryThrust_; } 117 // place your get-functions here. 104 void setOwner(Pawn* owner); 105 inline Pawn* getOwner() const 106 { return this->owner_; } 107 108 inline void setDamage(float damage) 109 { this->damage_ = damage; } 110 inline float getDamage() const 111 { return this->damage_; } 118 112 119 113 private: 120 RocketController *myController_; //!< The controller of the Rocket. 114 WeakPtr<Pawn> owner_; 115 Vector3 localAngularVelocity_; 116 float damage_; 117 bool bDestroy_; 121 118 122 btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Rocket the next tick. 123 btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Rocket the next tick. 124 float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward. 125 float auxilaryThrust_; //!< The amount of auxilary thrust. Used for all other movements (except for rotations). 126 float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only. 119 Model* model_; 120 ConeCollisionShape* collisionShape_; 121 Timer destroyTimer_; 122 float lifetime_; 127 123 }; 128 124 -
code/branches/particles2/src/modules/weapons/weaponmodes/CMakeLists.txt
r5781 r6065 5 5 HsW01.cc 6 6 LightningGun.cc 7 RocketFire.cc 7 8 ) -
code/branches/particles2/src/modules/weapons/weaponmodes/RocketFire.cc
r6059 r6065 27 27 */ 28 28 29 #include " FusionFire.h"29 #include "RocketFire.h" 30 30 31 31 #include "util/Math.h" 32 32 #include "core/CoreIncludes.h" 33 #include "weapons/projectiles/ BillboardProjectile.h"33 #include "weapons/projectiles/Rocket.h" 34 34 35 35 #include "weaponsystem/Weapon.h" … … 39 39 namespace orxonox 40 40 { 41 CreateFactory( FusionFire);41 CreateFactory(RocketFire); 42 42 43 FusionFire::FusionFire(BaseObject* creator) : WeaponMode(creator)43 RocketFire::RocketFire(BaseObject* creator) : WeaponMode(creator) 44 44 { 45 RegisterObject( FusionFire);45 RegisterObject(RocketFire); 46 46 47 this->reloadTime_ = 1.0;47 this->reloadTime_ = 0.20; 48 48 this->bParallelReload_ = false; 49 this->damage_ = 40;50 this->speed_ = 1250;49 this->damage_ = 100; 50 this->speed_ = 500; 51 51 52 this->setMunitionName(" FusionMunition");52 this->setMunitionName("RocketMunition"); 53 53 } 54 54 55 void FusionFire::fire()55 void RocketFire::fire() 56 56 { 57 BillboardProjectile* projectile = new BillboardProjectile(this);57 Rocket* rocket = new Rocket(this); 58 58 59 projectile->setOrientation(this->getMuzzleOrientation());60 projectile->setPosition(this->getMuzzlePosition());61 projectile->setVelocity(this->getMuzzleDirection() * this->speed_);62 projectile->scale(5);59 rocket->setOrientation(this->getMuzzleOrientation()); 60 rocket->setPosition(this->getMuzzlePosition()); 61 rocket->setVelocity(this->getMuzzleDirection() * this->speed_); 62 rocket->scale(2); 63 63 64 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 65 projectile->setDamage(this->getDamage()); 66 projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f)); 64 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 65 rocket->setDamage(this->getDamage()); 67 66 } 68 67 } -
code/branches/particles2/src/modules/weapons/weaponmodes/RocketFire.h
r6059 r6065 27 27 */ 28 28 29 #ifndef _ FusionFire_H__30 #define _ FusionFire_H__29 #ifndef _RocketFire_H__ 30 #define _RocketFire_H__ 31 31 32 32 #include "weapons/WeaponsPrereqs.h" … … 35 35 namespace orxonox 36 36 { 37 class _WeaponsExport FusionFire : public WeaponMode37 class _WeaponsExport RocketFire : public WeaponMode 38 38 { 39 39 public: 40 FusionFire(BaseObject* creator);41 virtual ~ FusionFire() {}40 RocketFire(BaseObject* creator); 41 virtual ~RocketFire() {} 42 42 43 43 virtual void fire(); … … 48 48 } 49 49 50 #endif /* _ FusionFire_H__ */50 #endif /* _RocketFire_H__ */ -
code/branches/particles2/src/orxonox/controllers/CMakeLists.txt
r6059 r6065 7 7 WaypointController.cc 8 8 WaypointPatrolController.cc 9 RocketController.cc10 9 ) -
code/branches/particles2/src/orxonox/worldentities/CMakeLists.txt
r6059 r6065 5 5 MobileEntity.cc 6 6 ControllableEntity.cc 7 Rocket.cc8 7 9 8 BigExplosion.cc
Note: See TracChangeset
for help on using the changeset viewer.