Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4893 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons


Ignore:
Timestamp:
Jul 19, 2005, 5:16:07 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: animations can now be stored inside of the Weapon-base-class

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

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/test_gun.cc

    r4890 r4893  
    5353
    5454  this->objectComponent1 = new PNode();
    55   this->animation1 = new Animation3D(this->objectComponent1);
    56   this->animation2 = new Animation3D(this);
    57   this->animation3 = new Animation3D(this);
     55  Animation3D* animation1 = this->createAnimation(WS_SHOOTING, this->objectComponent1);
     56  Animation3D* animation2 = this->createAnimation(WS_ACTIVATING, this);
     57  Animation3D* animation3 = this->createAnimation(WS_DEACTIVATING, this);
    5858  //parent->addChild(this->objectComponent1, PNODE_ALL);
    5959  this->addChild(this->objectComponent1, PNODE_ALL);
    6060
    61   this->animation1->setInfinity(ANIM_INF_CONSTANT);
    62   this->animation2->setInfinity(ANIM_INF_CONSTANT);
    63   this->animation3->setInfinity(ANIM_INF_CONSTANT);
     61  animation1->setInfinity(ANIM_INF_CONSTANT);
     62  animation2->setInfinity(ANIM_INF_CONSTANT);
     63  animation3->setInfinity(ANIM_INF_CONSTANT);
    6464  if( this->leftRight == W_LEFT)
    6565    {
    6666      this->projectileOffset = Vector(1.0, 0.0, -0.35);
    6767
    68       this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    69       this->animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    70       this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    71 
    72       this->animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    73       this->animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    74 
    75       this->animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    76       this->animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     68      animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     69      animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     70      animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
     71
     72      animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     73      animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     74
     75      animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     76      animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    7777    }
    7878  else if( this->leftRight == W_RIGHT)
     
    8181
    8282      this->objectComponent1->setRelCoor(Vector(0,0,0.35));
    83       this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    84       this->animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    85       this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    86 
    87       this->animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    88       this->animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    89 
    90       this->animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    91       this->animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     83      animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     84      animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     85      animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
     86
     87      animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     88      animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     89
     90      animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     91      animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    9292    }
    9393/*
     
    128128void TestGun::activate()
    129129{
    130   this->animation2->replay();
    131130}
    132131
     
    141140void TestGun::deactivate()
    142141{
    143   this->animation3->replay();
    144142}
    145143
     
    153151void TestGun::fire()
    154152{
    155   this->energyLoaded -= this->minCharge;
    156153  Projectile* pj =  new TestBullet(this);//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));
    157154//  weaponSource->play();
     
    161158  pj->setVelocity(this->getVelocity());
    162159  State::getWorldEntityList()->add(pj);
    163 
    164   this->animation1->replay();
    165160}
    166161
  • orxonox/trunk/src/world_entities/weapons/test_gun.h

    r4885 r4893  
    4949
    5050  private:
    51     Animation3D* animation1;
    52     Animation3D* animation2;
    53     Animation3D* animation3;
    54 
    5551    PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
    5652    PNode* objectComponent2;
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4892 r4893  
    126126}
    127127
     128
     129/**
     130 * creates an Animation3D for a certain State.
     131 * @param state what state should the Animation be created for
     132 * @param node the node this Animation should apply to.
     133 * @returns The created animation.Animation(), NULL on error.
     134 *
     135 * This function does only generate the Animation Object, and if set it will
     136 * automatically be executed, when a certain State is reached.
     137 * What this does not do, is set keyframes, you have to operate on the returned animation.
     138 */
     139Animation3D* Weapon::createAnimation(WeaponState state, PNode* node)
     140{
     141  if (state >= WS_STATE_COUNT || node == NULL)
     142    return NULL;
     143
     144  if (unlikely(this->animation[state] != NULL))
     145  {
     146    delete this->animation[state];
     147    this->animation[state] = NULL;
     148  }
     149  return this->animation[state] = new Animation3D(node);
     150}
     151
     152
    128153/////////////////
    129154//  EXECUTION  //
     
    219244  {
    220245        // play Sound
    221     if (this->soundBuffers[WA_ACTIVATE] != NULL)
     246    if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))
    222247      this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
     248    if (likely(this->animation[WS_ACTIVATING] != NULL))
     249      this->animation[WS_ACTIVATING]->replay();
    223250        // activate
    224251    PRINTF(5)("Activating the Weapon %s\n", this->getName());
     
    243270    if (this->soundBuffers[WA_DEACTIVATE] != NULL)
    244271      this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
     272    if (likely(this->animation[WS_DEACTIVATING] != NULL))
     273      this->animation[WS_DEACTIVATING]->replay();
    245274        // deactivate
    246275    this->deactivate();
     
    263292    if (this->soundBuffers[WA_CHARGE] != NULL)
    264293      this->soundSource->play(this->soundBuffers[WA_CHARGE]);
     294    if (likely(this->animation[WS_CHARGING] != NULL))
     295      this->animation[WS_CHARGING]->replay();
     296
    265297        // charge
    266298    this->charge();
     
    289321    if (this->soundBuffers[WA_SHOOT] != NULL)
    290322      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
     323    if (likely(this->animation[WS_SHOOTING] != NULL))
     324      this->animation[WS_SHOOTING]->replay();
    291325          // fire
    292326    this->fire();
     
    321355  if (this->soundBuffers[WA_RELOAD] != NULL)
    322356    this->soundSource->play(this->soundBuffers[WA_RELOAD]);
     357  if (likely(this->animation[WS_RELOADING] != NULL))
     358    this->animation[WS_RELOADING]->replay();
    323359
    324360  if (chargeSize > this->energy)
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4892 r4893  
    112112    void setActionSound(const char* action, const char* soundFile) { this->setActionSound(charToAction(action), soundFile); };
    113113
    114 
     114    Animation3D* createAnimation(WeaponState state, PNode* node);
    115115
    116116    // FLOW
Note: See TracChangeset for help on using the changeset viewer.