Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6834 for code/branches


Ignore:
Timestamp:
May 3, 2010, 1:40:16 PM (15 years ago)
Author:
gnadler
Message:

Success:
Now rocket spawns somewhere around the ship and the orientation is more or less correct. The controller does nothing but change some pitch/roll (to be sure it does something).
I modified the rocketfire particle to produce rocketfire2.particle which is slightly smaller and matches the smaller rocket.

Location:
code/branches/rocket
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/rocket/data/levels/includes/weaponsettings3.oxi

    r6814 r6834  
    3939        </Weapon>
    4040        <Weapon>
    41           <SimpleRocketFire mode=2 muzzleoffset="0,0,0" />
     41          <SimpleRocketFire mode=2 muzzleoffset="10,10,10" />
    4242        </Weapon>
    4343      </WeaponPack>
  • code/branches/rocket/src/modules/weapons/RocketController.cc

    r6817 r6834  
    3232#include "weapons/projectiles/SimpleRocket.h"
    3333#include "util/Debug.h"
    34 
     34#include "weapons/weaponmodes/SimpleRocketFire.h"
    3535
    3636namespace orxonox
     
    4545
    4646        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));
    4949                this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
    50 
    5150    }
    5251
     
    6261
    6362        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);
    6866
    6967    }
  • code/branches/rocket/src/modules/weapons/RocketController.h

    r6814 r6834  
    3535#include "tools/interfaces/Tickable.h"
    3636#include "weapons/projectiles/SimpleRocket.h"
     37#include "weapons/weaponmodes/SimpleRocketFire.h"
    3738
    3839namespace orxonox
     
    5152           
    5253            virtual void tick(float dt);
     54                        SimpleRocket* getRocket(){return rocket;};
    5355        protected:
    5456
    5557
    5658        private:
     59                        SimpleRocket* rocket;
    5760
    5861    };
  • code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc

    r6827 r6834  
    6060        this->lifetime_ = 100;
    6161                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
    7163
    7264        //if (GameMode::isMaster())
    7365        //{
    74          /*   this->setCollisionType(WorldEntity::Kinematic);
    75             this->setVelocity(0,0,-100);*/
     66           this->setCollisionType(WorldEntity::Kinematic);
     67            this->setVelocity(0,0,100);
    7668
    7769            Model* model = new Model(this);
    7870            model->setMeshSource("rocket.mesh");
    79             //model->scale(0.7f);
     71            model->scale(0.7f);
    8072            this->attach(model);
    81            /* ParticleEmitter* fire = new ParticleEmitter(this);
     73
     74            ParticleEmitter* fire = new ParticleEmitter(this);
    8275            this->attach(fire);
    8376            fire->setOrientation(this->getOrientation());
    84             fire->setSource("Orxonox/Rocketfire");
     77            fire->setSource("Orxonox/rocketfire2");
    8578
    8679            this->enableCollisionCallback();
     
    9184            collisionShape->setRadius(3);
    9285            collisionShape->setHeight(500);
    93             this->attachCollisionShape(collisionShape);*/
     86            this->attachCollisionShape(collisionShape);
    9487
    9588            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this)));
     
    127120    }
    128121
    129     /**
    130     @brief
    131         Defines which actions the SimpleRocket has to take in each tick.
    132     @param dt
    133         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     }
    149122
    150123    bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
  • code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h

    r6778 r6834  
    5353
    5454            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.
    5655
    5756            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
  • code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc

    r6827 r6834  
    4545    {
    4646        RegisterObject(SimpleRocketFire);
     47               
    4748
    4849      /*  this->reloadTime_ = 0.20f;
     
    6162    void SimpleRocketFire::fire()
    6263    {
    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());
    6575
    66 
    67         this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
     76        /* this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
    6877        rocket->setOrientation(this->getMuzzleOrientation());
    6978        rocket->setPosition(this->getMuzzlePosition());
    70         rocket->scale(10);
     79                rocket->scale(10);
    7180        rocket->setVelocity(this->getMuzzleDirection() * this->speed_);
    7281        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                */
    7685    }
    7786}
Note: See TracChangeset for help on using the changeset viewer.