Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.