Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4964 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jul 28, 2005, 3:52:29 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Turret now turns into the dirrection of the Target, projectiles are aligned into this direction too.

Location:
orxonox/trunk/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/player.cc

    r4963 r4964  
    8989  this->weaponMan->addWeapon(wpLeft, 1, 0);
    9090  this->weaponMan->addWeapon(wpRight,1 ,1);
    91   this->weaponMan->addWeapon(turret, 3, 1);
     91  this->weaponMan->addWeapon(turret, 3, 2);
    9292
    9393  this->weaponMan->changeWeaponConfig(0);
     
    110110
    111111  this->weaponMan = new WeaponManager(this);
     112  this->weaponMan->setSlotCount(3);
    112113  this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0));
    113114  this->weaponMan->setSlotPosition(1, Vector(-2.6, .1, 3.0));
    114 
     115  this->weaponMan->setSlotPosition(2, Vector(-1.5, .5, 0));
    115116}
    116117
  • orxonox/trunk/src/world_entities/weapons/turret.cc

    r4963 r4964  
    4343
    4444  this->model = (Model*)ResourceManager::getInstance()->load("models/turret1.obj", OBJ, RP_CAMPAIGN);
    45   this->leftRight = leftRight;
    4645
    47 /*  this->objectComponent1 = new PNode();
    48   Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this->objectComponent1);
    49   Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
    50   Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
    51   //parent->addChild(this->objectComponent1, PNODE_ALL);
    52   this->addChild(this->objectComponent1, PNODE_ALL);
     46  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
     47  Animation3D* animation2 = this->getAnimation(WS_DEACTIVATING, this);
     48
     49  animation1->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     50  animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     51  animation2->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     52  animation2->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    5353
    5454  animation1->setInfinity(ANIM_INF_CONSTANT);
    5555  animation2->setInfinity(ANIM_INF_CONSTANT);
    56   animation3->setInfinity(ANIM_INF_CONSTANT);
    57   if( this->leftRight == W_LEFT)
    58     {
    59       this->setEmissionPoint(1.0, 0.0, -0.35);
    60 
    61       animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    62       animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    63       animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    64 
    65       animation2->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    66       animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    67 
    68       animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    69       animation3->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    70     }
    71   else if( this->leftRight == W_RIGHT)
    72     {
    73       this->setEmissionPoint(1.0, 0.0, 0.5);
    74 
    75       this->objectComponent1->setRelCoor(Vector(0,0,0.35));
    76       animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    77       animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    78       animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    79 
    80       animation2->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    81       animation2->addKeyFrame(Vector(.0, .0, .0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    82 
    83       animation3->addKeyFrame(Vector(.0, .0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    84       animation3->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    85     }*/
    86 
    87   //  ObjectManager::getInstance()->cache(CL_TEST_BULLET, 100, p);
    88   //ObjectManager::getInstance()->debug();
    8956
    9057  this->setStateDuration(WS_SHOOTING, .4);
    91   this->setStateDuration(WS_RELOADING, 1);
     58  this->setStateDuration(WS_RELOADING, 2);
    9259  this->setStateDuration(WS_ACTIVATING, .4);
    9360  this->setStateDuration(WS_DEACTIVATING, .4);
     
    10067
    10168  this->setProjectile(CL_TEST_BULLET);
     69
     70  this->setEmissionPoint(1.684, 0.472, 0);
    10271  //this->getProjectileFactory()->prepare(100);
    10372}
     
    11281}
    11382
    114 
    115 /**
    116  *  this activates the weapon
    117 
    118    This is needed, since there can be more than one weapon on a ship. the
    119    activation can be connected with an animation. for example the weapon is
    120    been armed out.
    121 */
    12283void Turret::activate()
    12384{
    12485}
    12586
    126 
    127 /**
    128  *  this deactivates the weapon
    129 
    130    This is needed, since there can be more than one weapon on a ship. the
    131    activation can be connected with an animation. for example the weapon is
    132    been armed out.
    133 */
    13487void Turret::deactivate()
    13588{
    13689}
    13790
     91void Turret::tick(float dt)
     92{
     93  Vector direction = this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();
     94  direction.normalize();
     95  Quaternion quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
     96
     97  this->setRelDir(quat);
     98}
    13899
    139100/**
     
    141102
    142103   this is called from the player.cc, when fire-button is been pushed
    143    @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
    144104*/
    145105void Turret::fire()
     
    152112  {
    153113    pj->setVelocity(this->getVelocity()+(target->getAbsCoor() - this->getAbsCoor())*.5);//this->getVelocity());
     114    pj->setAbsDir(this->getAbsDir());
    154115  }
    155116  else
  • orxonox/trunk/src/world_entities/weapons/turret.h

    r4963 r4964  
    1818    virtual void deactivate();
    1919
     20    virtual void tick(float dt);
    2021    virtual void fire();
    2122    virtual void destroy();
     
    2425
    2526  private:
    26     PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
    27 
    28     int leftRight;   // this will become an enum
    2927  };
    3028#endif /* _TURRET_H */
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4959 r4964  
    5454    void loadWeapons(const TiXmlElement* root);
    5555
     56    void setSlotCount(unsigned int slotCount);
    5657    // setting up the WeaponManager with the following functions
    5758    void setSlotPosition(int slot, const Vector& position);
     
    8586
    8687  private:
    87     void setSlotCount(unsigned int slotCount);
    88 
    8988    int getNextFreeSlot(int configID);
    9089
Note: See TracChangeset for help on using the changeset viewer.