Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6951 for code/branches


Ignore:
Timestamp:
May 21, 2010, 10:25:27 AM (14 years ago)
Author:
scheusso
Message:

merged rocket branch into presentation3 and cleaned up some things (mostly debug output and intendation)

Location:
code/branches/presentation3
Files:
11 edited
17 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3

  • code/branches/presentation3/data/levels/includes/weaponsettings3.oxi

    r6417 r6951  
    3939        </Weapon>
    4040        <Weapon>
    41           <RocketFire mode=2 muzzleoffset="0,0,0" />
     41          <SimpleRocketFire mode=2 muzzleoffset="0,0,0" />
    4242        </Weapon>
    4343      </WeaponPack>
  • code/branches/presentation3/data/levels/tutorial.oxw

    r5781 r6951  
    1616<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
    1717  <attached>
    18     <Model scale="10" mesh="drone.mesh"/>
     18    <Model scale="1" mesh="drone.mesh"/>
    1919  </attached>
    2020  <collisionShapes>
     
    2323</Drone>
    2424
     25<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
     26  <attached>
     27    <Model scale="1" mesh="rocket.mesh"/>
     28  </attached>
     29  <collisionShapes>
     30    <BoxCollisionShape position="0,0,0"      halfExtents="10, 10, 10" />
     31  </collisionShapes>
     32</Drone>
    2533
    2634    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
  • code/branches/presentation3/src/modules/weapons/CMakeLists.txt

    r5781 r6951  
    11SET_SOURCE_FILES(WEAPONS_SRC_FILES
    22  MuzzleFlash.cc
     3  RocketController.cc
    34)
    45
  • code/branches/presentation3/src/modules/weapons/RocketController.cc

    r6950 r6951  
    4343    RocketController::RocketController(BaseObject* creator) : Controller(creator)
    4444    {
    45                 RegisterObject(RocketController);
    46                 COUT(0)<< "RocketController constructed\n";
     45        RegisterObject(RocketController);
     46        COUT(5)<< "RocketController constructed\n";
    4747
    4848       
    49                 this->rocket = new SimpleRocket(this);
    50                 this->rocket->setController(this);
    51                 this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
    52                 this->haha=0;
     49        this->rocket = new SimpleRocket(this);
     50        this->rocket->setController(this);
     51        this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
     52        this->haha=0;
    5353    }
    5454
     
    6262    void RocketController::tick(float dt)
    6363    {
    64                 haha++;
     64        haha++;
    6565
    66                 //if (haha<30)this->rocket->setVelocity(rocket->getVelocity()*1.03);
    67                 if (this->target_) {
    68                         this->setTargetPosition();
    69                         this->moveToTargetPosition();
    70                 }
    71                 if (haha>500) rocket->setDestroy();;
    72        
    73         }
     66        //if (haha<30)this->rocket->setVelocity(rocket->getVelocity()*1.03);
     67        if (this->target_) {
     68            this->setTargetPosition();
     69            this->moveToTargetPosition();
     70        }
     71        if (haha>500) rocket->setDestroy();;
     72
     73    }
    7474
    7575
    76         RocketController::~RocketController() {
     76    RocketController::~RocketController()
     77    {
     78        COUT(5)<< "RocketController destroyed\n";
     79    }
    7780
    78                
    79                 COUT(0)<< "RocketController destroyed\n";
    80         }
    81 
    82         void RocketController::setTargetPosition() {
    83                 //this->targetPosition_=this->target_->getWorldPosition();
    84                 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity());
    85         }
    86         void RocketController::moveToTargetPosition() {
    87                 this->moveToPosition(this->targetPosition_);
    88         }
     81    void RocketController::setTargetPosition()
     82    {
     83        //this->targetPosition_=this->target_->getWorldPosition();
     84        this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity());
     85    }
     86    void RocketController::moveToTargetPosition()
     87    {
     88        this->moveToPosition(this->targetPosition_);
     89    }
    8990
    9091
    9192
    92         void RocketController::setTarget(WorldEntity* target) {
    93                 this->target_ = target;
    94                 COUT(0)<<"got target\n";
    95         }
     93    void RocketController::setTarget(WorldEntity* target)
     94    {
     95        this->target_ = target;
     96        COUT(0)<<"got target\n";
     97    }
    9698
    97         void RocketController::moveToPosition(const Vector3& target)
     99    void RocketController::moveToPosition(const Vector3& target)
    98100    {
    99        if (!this->getControllableEntity())
     101        if (!this->getControllableEntity())
    100102            return;
    101            float dx = target.x-this->getControllableEntity()->getPosition().x;
    102            float dy = target.y-this->getControllableEntity()->getPosition().y;
    103            COUT(0)<<"\n diff: ";
    104            COUT(0)<<target-this->getControllableEntity()->getPosition() << endl;
    105            //COUT(0)<<"\n 2D view: ";
    106           /* COUT(0)<<this->getControllableEntity()->getPosition().x;
    107            COUT(0)<<" ";
    108            COUT(0)<<this->getControllableEntity()->getPosition().y;
    109            COUT(0)<<" ";
    110            COUT(0)<<this->getControllableEntity()->getPosition().z;
    111            COUT(0)<<"\n";*/
     103        float dx = target.x-this->getControllableEntity()->getPosition().x;
     104        float dy = target.y-this->getControllableEntity()->getPosition().y;
     105        COUT(4)<<"\n diff: ";
     106        COUT(4)<<target-this->getControllableEntity()->getPosition() << endl;
     107        //COUT(0)<<"\n 2D view: ";
     108        /* COUT(0)<<this->getControllableEntity()->getPosition().x;
     109        COUT(0)<<" ";
     110        COUT(0)<<this->getControllableEntity()->getPosition().y;
     111        COUT(0)<<" ";
     112        COUT(0)<<this->getControllableEntity()->getPosition().z;
     113        COUT(0)<<"\n";*/
    112114        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
    113115        float distance = (target - this->getControllableEntity()->getPosition()).length();
    114                 //Vector3D diff =target-this->rocket->getPosition();
    115                 COUT(0) << "viewdirection: "<< coord << endl;
    116                 //COUT(0)<<"  ";
    117                 //COUT(0)<<coord.y;
     116        //Vector3D diff =target-this->rocket->getPosition();
     117        COUT(4) << "viewdirection: "<< coord << endl;
     118        //COUT(0)<<"  ";
     119        //COUT(0)<<coord.y;
    118120        this->getControllableEntity()->rotateYaw(-0.8f*sgn(coord.x)*coord.x*coord.x);
    119121        this->getControllableEntity()->rotatePitch(0.8f*sgn(coord.y)*coord.y*coord.y);
    120122//         this->getControllableEntity()->rotateYaw(10);
    121123//         this->getControllableEntity()->rotatePitch(0);
    122                 //this->getControllableEntity()->rotatePitch(rotation.getPitch().valueRadians());
    123                 //this->getControllableEntity()->rotateYaw(rotation.getYaw().valueRadians());
    124                 //this->getControllableEntity()->moveUpDown(coord.y);
    125                 //this->getControllableEntity()->moveRightLeft(coord.x);
    126                 //this->getControllableEntity()->rotatePitch(coord);
     124        //this->getControllableEntity()->rotatePitch(rotation.getPitch().valueRadians());
     125        //this->getControllableEntity()->rotateYaw(rotation.getYaw().valueRadians());
     126        //this->getControllableEntity()->moveUpDown(coord.y);
     127        //this->getControllableEntity()->moveRightLeft(coord.x);
     128        //this->getControllableEntity()->rotatePitch(coord);
    127129   //     if (this->target_ || distance > 10)
    128130   //     {
    129131   //         // Multiply with 0.8 to make them a bit slower
    130                         //this->getControllableEntity()->rotateYaw(coord.x );
     132            //this->getControllableEntity()->rotateYaw(coord.x );
    131133   //         this->getControllableEntity()->rotatePitch(coord.y);
    132                         //
    133134   //     }
    134135    }
  • code/branches/presentation3/src/modules/weapons/projectiles/CMakeLists.txt

    r6417 r6951  
    55  LightningGunProjectile.cc
    66  Rocket.cc
     7  SimpleRocket.cc
    78)
  • code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc

    r6950 r6951  
    5959        this->bDestroy_ = false;
    6060        this->lifetime_ = 100;
    61                 COUT(0)<< "simplerocket constructed\n";
     61        COUT(4) << "simplerocket constructed\n";
    6262
    6363
     
    9191
    9292    }
    93         void SimpleRocket::tick(float dt)
     93   
     94    void SimpleRocket::tick(float dt)
    9495    {
    9596        SUPER(SimpleRocket, tick, dt);
     
    102103                this->destroy();
    103104       
    104         }
     105    }
    105106
    106107    /**s
     
    110111    SimpleRocket::~SimpleRocket()
    111112    {
    112                 if (this->isInitialized()) {
    113                         this->getController()->destroy();
    114                 COUT(0)<< "simplerocket destroyed\n";
    115                 }
    116         }
     113        if (this->isInitialized())
     114        {
     115            this->getController()->destroy();
     116            COUT(4)<< "simplerocket destroyed\n";
     117        }
     118    }
    117119
    118120    /**
     
    165167
    166168            float dmg = this->damage_;
    167             if (this->owner_)
    168                 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
     169//             if (this->owner_)
     170//                 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
    169171
    170172            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
     
    182184        }
    183185    }
    184         void SimpleRocket::setDestroy() {
    185                 this->bDestroy_=true;
    186                 COUT(0)<<"trying to destroy";
    187         }
     186   
     187    void SimpleRocket::setDestroy()
     188    {
     189        this->bDestroy_=true;
     190        CCOUT(4)<<"trying to destroy";
     191    }
    188192
    189193    void SimpleRocket::fired(unsigned int firemode)
  • code/branches/presentation3/src/modules/weapons/weaponmodes/CMakeLists.txt

    r6417 r6951  
    66  LightningGun.cc
    77  RocketFire.cc
     8  SimpleRocketFire.cc
    89)
  • code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc

    r6950 r6951  
    6161    void SimpleRocketFire::fire()
    6262    {
    63                 RocketController* con = new RocketController(this);
    64                 SimpleRocket* rocket = con->getRocket();
    65                 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
    66 //              rocket->setOrientation(this->getMuzzleOrientation());
     63        RocketController* con = new RocketController(this);
     64        SimpleRocket* rocket = con->getRocket();
     65        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
     66//      rocket->setOrientation(this->getMuzzleOrientation());
    6767        rocket->setOrientation(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getWorldOrientation());
    68                 Vector3 pos = this->getMuzzlePosition();
     68        Vector3 pos = this->getMuzzlePosition();
    6969        rocket->setPosition(pos);
    70 //              rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT);
    71                 rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
    72                 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    73                 rocket->setDamage(this->damage_);
    74                 WorldEntity* pawnn=this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget();
    75                 if (pawnn) {
    76                 con->setTarget(pawnn);
    77                 }
     70//      rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT);
     71        rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
     72        rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     73        rocket->setDamage(this->damage_);
     74        WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
     75        if (pawnn)
     76        {
     77            con->setTarget(pawnn);
     78        }
    7879    }
    7980}
  • code/branches/presentation3/src/orxonox/controllers/AIController.cc

    r5929 r6951  
    5757
    5858        // search enemy
    59         random = rnd(maxrand);
     59      /*  random = rnd(maxrand);
    6060        if (random < 15 && (!this->target_))
    61             this->searchNewTarget();
     61            this->searchNewTarget();*/
    6262
    6363        // forget enemy
    64         random = rnd(maxrand);
    65         if (random < 5 && (this->target_))
    66             this->forgetTarget();
     64        //random = rnd(maxrand);
     65        //if (random < 5 && (this->target_))
     66        //    this->forgetTarget();
    6767
    6868        // next enemy
    69         random = rnd(maxrand);
     69  /*      random = rnd(maxrand);
    7070        if (random < 10 && (this->target_))
    71             this->searchNewTarget();
     71            this->searchNewTarget();*/
    7272
    7373        // fly somewhere
     
    8787
    8888        // shoot
    89         random = rnd(maxrand);
    90         if (random < 75 && (this->target_ && !this->bShooting_))
    91             this->bShooting_ = true;
     89        //random = rnd(maxrand);
     90        //if (random < 75 && (this->target_ && !this->bShooting_))
     91        //    this->bShooting_ = true;
    9292
    93         // stop shooting
    94         random = rnd(maxrand);
    95         if (random < 25 && (this->bShooting_))
    96             this->bShooting_ = false;
     93        //// stop shooting
     94        //random = rnd(maxrand);
     95        //if (random < 25 && (this->bShooting_))
     96        //    this->bShooting_ = false;
    9797    }
    9898
  • code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt

    r6417 r6951  
    88  WaypointController.cc
    99  WaypointPatrolController.cc
     10  DroneController.cc
    1011)
  • code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc

    r6598 r6951  
    364364        Ogre::RaySceneQueryResult& result = rsq->execute();
    365365        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
     366        WorldEntity* myWe = static_cast<WorldEntity*>(this->getControllableEntity());
    366367
    367368        Ogre::RaySceneQueryResult::iterator itr;
    368369        for (itr = result.begin(); itr != result.end(); ++itr)
    369370        {
    370             if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
     371//             CCOUT(0) << "testing object as target" << endl;
     372            if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" /*&& itr->distance > 500*/)
    371373            {
    372374                // Try to cast the user pointer
    373375                WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
     376               
     377                // make sure we don't shoot ourselves
     378                if( wePtr==myWe )
     379                    continue;
     380               
    374381                if (wePtr)
    375382                {
     
    379386                    while (parent)
    380387                    {
    381                         if (this->targetMask_.isExcluded(parent->getIdentifier()))
     388                        if (this->targetMask_.isExcluded(parent->getIdentifier()) || parent==myWe)
    382389                        {
    383390                            parent = parent->getParent();
     
    579586        }
    580587    }
     588       
     589
     590   
     591
     592
    581593}
  • code/branches/presentation3/src/orxonox/controllers/NewHumanController.h

    r6417 r6951  
    6767            virtual void doResumeControl();
    6868
     69
    6970        protected:
    7071            void updateTarget();
  • code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt

    r6417 r6951  
    1212  SpawnPoint.cc
    1313  TeamSpawnPoint.cc
     14  Drone.cc
    1415)
    1516
Note: See TracChangeset for help on using the changeset viewer.