Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 2, 2015, 4:08:52 PM (9 years ago)
Author:
meggiman
Message:

Started implementing GravityBombField

Location:
code/branches/weaponFS15/src/modules
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponFS15/src/modules/objects/ForceField.h

    r9939 r10341  
    160160            const std::string& getMode(void); //!< Get the mode of the ForceField.
    161161
     162            static const std::string modeTube_s;
     163                        static const std::string modeSphere_s;
     164                        static const std::string modeInvertedSphere_s;
     165                        static const std::string modeNewtonianGravity_s;
     166
     167                        static const std::string modeHomogen_s;
     168
    162169        private:
    163170            //! Strings to represent the modes.
    164             static const std::string modeTube_s;
    165             static const std::string modeSphere_s;
    166             static const std::string modeInvertedSphere_s;
    167             static const std::string modeNewtonianGravity_s;
    168171
    169             static const std::string modeHomogen_s;
    170172
    171173            float velocity_; //!< The velocity of the ForceField.
  • code/branches/weaponFS15/src/modules/weapons/projectiles/CMakeLists.txt

    r10336 r10341  
    88  SimpleRocket.cc
    99  GravityBomb.cc
     10  GravityBombField.cc
    1011)
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc

    r10336 r10341  
    1111        RegisterClass(GravityBomb);
    1212
    13         const float GravityBomb::FUEL_START = 10;
    14         const float GravityBomb::FORCE_SPHERE_START_RADIUS = 30;
    15         const float GravityBomb::FORCE_SPHERE_START_STRENGTH = 100;
     13        const float GravityBomb::INITIAL_VELOCITY = 20;
     14        const float GravityBomb::SLOW_DOWN_RATIO = 2;
    1615
    1716        GravityBomb::GravityBomb(Context* context):
    18                         BasicProjectile(),
    19                         MovableEntity(context),
    20                         RadarViewable(this,static_cast<WorldEntity*>(this))
     17                                BasicProjectile(),
     18                                MovableEntity(context),
     19                                RadarViewable(this,static_cast<WorldEntity*>(this))
    2120                {
    2221                        RegisterObject(GravityBomb);
    23                         this->lifetime_=FUEL_START;
    24                         this->forceSphereRadius_= FORCE_SPHERE_START_RADIUS;
    25                         this->forceStrength_ = FORCE_SPHERE_START_STRENGTH;
    2622
    27                         ForceField* field = new ForceField(context);
    28                         field->setMode("sphere");
    29                         field->setDiameter(this->forceSphereRadius_);
    30                         field->setVelocity(this->forceStrength_);
    31                         this->attach(field);
     23                        this->setMass(15.0);
     24                        if (GameMode::isMaster())
     25                        {
     26                                //Define movement of the bomb
     27                                this->setVelocity(this->getOrientation()*WorldEntity::FRONT*INITIAL_VELOCITY);
     28                                this->velocityAtLastTick_=INITIAL_VELOCITY;
     29                                this->setAcceleration(this->getOrientation()*WorldEntity::BACK*SLOW_DOWN_RATIO);
     30                                this->setCollisionType(WorldEntity::Dynamic);
     31                                this->enableCollisionCallback();
    3232
     33                                //Add Collision Shape
     34                                SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
     35                                collisionShape->setRadius(5.0);
     36                                this->attachCollisionShape(collisionShape);
     37
     38                                //Create Bomb Model
     39
     40
     41                        }
    3342                }
    3443
     
    3746        void GravityBomb::tick(float dt)
    3847        {
    39 
     48                        if(velocityAtLastTick_ < this->getVelocity().length())
     49                        {
     50                                setVelocity(Vector3::ZERO);
     51                                setAcceleration(Vector3::ZERO);
     52                                velocityAtLastTick_=0;
     53                                detonate();
     54                        }
     55                        velocityAtLastTick_=getVelocity().length();
    4056        }
    4157
    4258        bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    4359        {
     60                detonate();
     61                processCollision(otherObject, contactPoint,cs);
    4462                return true;
     63        }
     64
     65        void GravityBomb::detonate()
     66        {
     67                GravityBombField* field = new GravityBombField(this->getContext());
    4568        }
    4669}
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h

    r10336 r10341  
    4848#include "worldentities/MovableEntity.h"
    4949#include "core/CoreIncludes.h"
     50#include "objects/collisionshapes/SphereCollisionShape.h"
     51#include "../../../orxonox/worldentities/WorldEntity.h"
     52#include "GravityBombField.h"
    5053
    5154namespace orxonox
    5255{
    53 
    54         class ConeCollisionShape;
    5556
    5657        class _WeaponsExport GravityBomb : public BasicProjectile , public MovableEntity, public RadarViewable
     
    6263
    6364                        virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
     65                        void detonate();
    6466
    6567                private:
    66                 static const float FUEL_START;
    67                 static const float FORCE_SPHERE_START_RADIUS;
    68                 static const float FORCE_SPHERE_START_STRENGTH;
     68                static const float INITIAL_VELOCITY;
     69                static const float SLOW_DOWN_RATIO;
    6970
    70                 float fuel_;
    71                 float lifetime_;
    72                 float forceSphereRadius_;
    73                 float forceStrength_;
    74 
     71                float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it.
    7572
    7673        };
Note: See TracChangeset for help on using the changeset viewer.