Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10152 in orxonox.OLD


Ignore:
Timestamp:
Dec 27, 2006, 12:03:36 PM (17 years ago)
Author:
nicolasc
Message:

finished animation on heavy blaster, started light blaster
code needs some cleanup

Location:
branches/playability/src/world_entities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10139 r10152  
    161161  //wpLeft2->setParent( this);
    162162 
    163   Weapon* wpRight3 = new HeavyBlaster ();
     163  Weapon* wpRight3 = new HeavyBlaster (1);
    164164  wpRight3->setName( "HeavyBlaster");
    165165  //wpRight3->setParent( this);
    166   Weapon* wpLeft3 = new HeavyBlaster ();
     166  Weapon* wpLeft3 = new HeavyBlaster (0);
    167167  wpLeft3->setName( "HeavyBlaster");
    168168  //wpLeft3->setParent( this);
     
    182182  this->weaponMan.addWeapon( wpRight3, 2, 5);
    183183
     184  this->weaponMan.addWeapon( wpLeft1, 3, 0);
     185  this->weaponMan.addWeapon( wpRight1, 3, 1);
     186
     187  this->weaponMan.addWeapon( wpLeft2, 3, 2);
     188  this->weaponMan.addWeapon( wpRight2, 3, 3);
     189
     190  this->weaponMan.addWeapon( wpLeft3, 3, 4);
     191  this->weaponMan.addWeapon( wpRight3, 3, 5);
     192
    184193  this->secWeaponMan.addWeapon( cannon, 0, 0);
    185194
    186195 
    187   this->weaponMan.changeWeaponConfig(2);
     196  this->weaponMan.changeWeaponConfig(3);
    188197  this->secWeaponMan.changeWeaponConfig(0);
    189198
     
    274283  this->weaponMan.setSlotCount(6);
    275284
    276   this->weaponMan.setSlotPosition(0, Vector(-2.6, 0, -3.0));
     285  this->weaponMan.setSlotPosition(0, Vector(0.0, 0, -3.0));
    277286  this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    278287
    279   this->weaponMan.setSlotPosition(1, Vector(-2.6, 0, 3.0));
     288  this->weaponMan.setSlotPosition(1, Vector(0.0, 0, 3.0));
    280289  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    281290
  • branches/playability/src/world_entities/weapons/heavy_blaster.cc

    r10140 r10152  
    1515 * Standard constructor
    1616 */
    17 HeavyBlaster::HeavyBlaster ()
     17HeavyBlaster::HeavyBlaster (int leftRight)
    1818 : Weapon()
    1919{
    20     this->init();
     20    this->init(leftRight);
    2121}
    2222
     
    2424 : Weapon()
    2525{
    26     this->init();
     26    // TODO add leftRight to params
     27    this->init(0);
    2728    if (root != NULL)
    2829      this->loadParams(root);
     
    3435HeavyBlaster::~HeavyBlaster()
    3536{
    36       // model will be deleted from WorldEntity-destructor
     37  this->deconstr();
     38     // model will be deleted from WorldEntity-destructor
    3739}
    3840
     
    4244}
    4345
    44 void HeavyBlaster::init()
    45 {
     46void HeavyBlaster::init(int leftRight)
     47{
     48
     49  this->leftRight = leftRight;
    4650  //this->registerObject(this, HeavyBlaster::_objectList);
    4751
     
    7074  this->setBarrels(3);
    7175  this->setSegs(2);
    72 
    73   this->objComp1 = new PNode;
    74   this->objComp2 = new PNode;
    75   this->objComp3 = new PNode;
    76   this->objComp4 = new PNode;
    77   this->objComp5 = new PNode;
    78   this->objComp6 = new PNode;
    79 
    80   Animation3D* animB0Shoot = this->getAnimation(WS_SHOOTING0, this->objComp1);
     76  this->activeBarrel = 0;
     77//   this->init2();
     78
     79
     80
     81  this->objComp = new PNode**[this->getBarrels()];
     82  this->emissionPoint = new PNode*[this->getBarrels()];
     83  this->shootAnim = new Animation3D**[this->getBarrels()];
     84  for (int i = 0; i < this->getBarrels(); i++)
     85  {
     86    this->objComp[i] = new PNode* [this->getSegs()];
     87    this->emissionPoint[i] = new PNode;
     88    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     89    this->emissionPoint[i]->setName("EmissionPoint");
     90    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     91    this->shootAnim[i] = new Animation3D* [this->getSegs()];
     92    for(int j = 0; j < this->getSegs(); j++)
     93    {
     94      this->objComp[i][j] = new PNode;
     95      this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
     96      this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
     97    }
     98  }
     99
     100    this->emissionPoint[0]->setRelCoor(Vector(1.1, 0.14, 0.06));
     101    this->emissionPoint[1]->setRelCoor(Vector(1.1, -.06, 0.14));
     102    this->emissionPoint[2]->setRelCoor(Vector(1.1, 0.06, -.14));
     103
     104
     105//   Animation3D* animB0Shoot = this->getAnimation(WS_SHOOTING0, this->objComp[0][0]);
    81106//   Animation3D* animB1Shoot = this->getAnimation(WS_SHOOTING1, this->objComp2);
    82107//   Animation3D* animB2Shoot = this->getAnimation(WS_SHOOTING2, this->objComp3);
    83 //   Animation3D* animT0Shoot = this->getAnimation(WS_SHOOTING3, this->objComp4);
     108//   Animation3D* animT0Shoot = this->getAnimation(WS_SHOOTING3, this->objComp[0][1]);
    84109//   Animation3D* animT1Shoot = this->getAnimation(WS_SHOOTING4, this->objComp5);
    85110//   Animation3D* animT2Shoot = this->getAnimation(WS_SHOOTING5, this->objComp6);
    86111
    87   animB0Shoot->setInfinity(ANIM_INF_CONSTANT);
     112
     113//   this->shootAnim[0][0]->setInfinity(ANIM_INF_CONSTANT);
    88114//   animB1Shoot->setInfinity(ANIM_INF_CONSTANT);
    89115//   animB2Shoot->setInfinity(ANIM_INF_CONSTANT);
     
    92118//   animT2Shoot->setInfinity(ANIM_INF_CONSTANT);
    93119
    94   animB0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    95   animB0Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    96   animB0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    97 /*
    98   animT0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    99   animT0Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    100   animT0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);*/
    101 /*
    102   animB1Shoot->addKeyFrame(Vector(0.1, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    103   animB1Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    104   animB1Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
    105 
    106   animT1Shoot->addKeyFrame(Vector(0.04, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    107   animT1Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    108   animT1Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
    109 
    110   animB2Shoot->addKeyFrame(Vector(0.1, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    111   animB2Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    112   animB2Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
    113 
    114   animT2Shoot->addKeyFrame(Vector(0.04, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    115   animT2Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    116   animT2Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);*/
     120  for (int i = 0; i < this->getBarrels(); i++){
     121    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
     122    this->shootAnim[i][0]->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 1.0, ANIM_LINEAR, ANIM_NULL);
     123    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.4, ANIM_LINEAR, ANIM_NULL);
     124
     125    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
     126    this->shootAnim[i][1]->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.0, ANIM_LINEAR, ANIM_NULL);
     127    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.4, ANIM_LINEAR, ANIM_NULL);
     128  }
    117129
    118130  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
     
    122134  animation3->setInfinity(ANIM_INF_CONSTANT);
    123135
    124   this->setEmissionPoint(3.8, 1.2, 0, 0);
     136//   this->setEmissionPoint(3.8, 1.2, 0, 0);
    125137
    126138  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
     
    140152  // set the owner
    141153  pj->setOwner(this->getOwner());
    142 
    143154  pj->setParent(PNode::getNullParent());
    144155
     
    147158  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1));
    148159
    149   pj->setAbsCoor(this->getEmissionPoint(0));
     160  pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
     161//   pj->setAbsCoor(this->getEmissionPoint(0));
    150162  pj->setAbsDir(this->getAbsDir());
    151   pj->toList(OM_GROUP_01_PROJ);
     163//   pj->toList(OM_GROUP_01_PROJ);
    152164  pj->activate();
     165
     166  // initiate animation
     167  for (int i = 0; i < this->getSegs(); i++)
     168    this->shootAnim[this->activeBarrel][i]->replay();
     169
     170  // switch barrel
     171  this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
    153172}
    154173
     
    167186}
    168187
     188
    169189void HeavyBlaster::draw() const
    170190{
     
    175195                this->getAbsCoor ().z);
    176196
     197  if (this->leftRight == W_LEFT)
     198    glScalef(1.0, 1.0, -1.0);
     199
    177200  static_cast<StaticModel*>(this->getModel())->draw(6);
    178201
    179202  glPushMatrix();
    180     glTranslatef (this->objComp1->getAbsCoor().x, this->objComp1->getAbsCoor().y, this->objComp1->getAbsCoor().z);
     203    glTranslatef (this->objComp[0][0]->getAbsCoor().x, this->objComp[0][0]->getAbsCoor().y, this->objComp[0][0]->getAbsCoor().z);
    181204    static_cast<StaticModel*>(this->getModel())->draw(1);
    182     static_cast<StaticModel*>(this->getModel())->draw(2);
    183     static_cast<StaticModel*>(this->getModel())->draw(0);
    184 
    185     glPushMatrix();
    186       glTranslatef (this->objComp4->getAbsCoor().x, this->objComp4->getAbsCoor().y, this->objComp4->getAbsCoor().z);
    187       static_cast<StaticModel*>(this->getModel())->draw(4);
    188       static_cast<StaticModel*>(this->getModel())->draw(5);
    189       static_cast<StaticModel*>(this->getModel())->draw(3);
    190     glPopMatrix();
    191   glPopMatrix();
    192 /*
    193   glPushMatrix();
    194   glTranslatef (this->objComp2->getAbsCoor().x, this->objComp2->getAbsCoor().y, this->objComp2->getAbsCoor().z);
     205  glPopMatrix();
     206
     207  glPushMatrix();
     208  glTranslatef (this->objComp[1][0]->getAbsCoor().x, this->objComp[1][0]->getAbsCoor().y, this->objComp[1][0]->getAbsCoor().z);
    195209  static_cast<StaticModel*>(this->getModel())->draw(2);
    196210  glPopMatrix();
    197211
    198212  glPushMatrix();
    199   glTranslatef (this->objComp3->getAbsCoor().x, this->objComp3->getAbsCoor().y, this->objComp3->getAbsCoor().z);
     213  glTranslatef (this->objComp[2][0]->getAbsCoor().x, this->objComp[2][0]->getAbsCoor().y, this->objComp[2][0]->getAbsCoor().z);
    200214  static_cast<StaticModel*>(this->getModel())->draw(0);
    201   glPopMatrix();*/
    202 
    203 //   glPushMatrix();
    204 //   glTranslatef (this->objComp4->getAbsCoor().x, this->objComp4->getAbsCoor().y, this->objComp4->getAbsCoor().z);
    205 //   static_cast<StaticModel*>(this->getModel())->draw(4);
    206 //   static_cast<StaticModel*>(this->getModel())->draw(5);
    207 //   static_cast<StaticModel*>(this->getModel())->draw(3);
    208 //   glPopMatrix();
    209 /*
    210   glPushMatrix();
    211   glTranslatef (this->objComp5->getAbsCoor().x, this->objComp5->getAbsCoor().y, this->objComp5->getAbsCoor().z);
     215  glPopMatrix();
     216
     217  glPushMatrix();
     218  glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);
     219    static_cast<StaticModel*>(this->getModel())->draw(4);
     220  glPopMatrix();
     221
     222  glPushMatrix();
     223  glTranslatef (this->objComp[1][1]->getAbsCoor().x, this->objComp[1][1]->getAbsCoor().y, this->objComp[1][1]->getAbsCoor().z);
    212224  static_cast<StaticModel*>(this->getModel())->draw(5);
    213225  glPopMatrix();
    214226
    215227  glPushMatrix();
    216   glTranslatef (this->objComp6->getAbsCoor().x, this->objComp6->getAbsCoor().y, this->objComp6->getAbsCoor().z);
     228  glTranslatef (this->objComp[2][1]->getAbsCoor().x, this->objComp[2][1]->getAbsCoor().y, this->objComp[2][1]->getAbsCoor().z);
    217229  static_cast<StaticModel*>(this->getModel())->draw(3);
    218   glPopMatrix();*/
    219 
    220   glPopMatrix();
    221 }
     230  glPopMatrix();
     231
     232  glPopMatrix();
     233}
  • branches/playability/src/world_entities/weapons/heavy_blaster.h

    r10133 r10152  
    44
    55#include "weapon.h"
     6
     7#define    W_LEFT        0
     8#define    W_RIGHT       1
    69
    710/**
     
    1417  //ObjectListDeclaration(HeavyBlaster);
    1518  public:
    16     HeavyBlaster();
     19    HeavyBlaster(int leftRight);
    1720    HeavyBlaster (const TiXmlElement* root);
    1821    virtual ~HeavyBlaster();
    1922
    20     void init();
     23    void init(int leftRight);
    2124    virtual void loadParams(const TiXmlElement* root);
    2225
     
    2932
    3033  private:
    31     PNode* objComp1;
    32     PNode* objComp2;
    33     PNode* objComp3;
    34     PNode* objComp4;
    35     PNode* objComp5;
    36     PNode* objComp6;
     34    PNode*** objComp;
     35    Animation3D*** shootAnim;
     36    PNode** emissionPoint;
     37
     38    int activeBarrel;
     39
     40    int leftRight;
    3741};
    3842
  • branches/playability/src/world_entities/weapons/light_blaster.cc

    r10109 r10152  
    4545{
    4646
    47   this->loadModel("models/guns/plasmadriver_#.obj", 1.0);
     47  this->loadModel("models/guns/gattling.obj", 0.333);
    4848 
    4949
     
    6666  this->prepareProjectiles(100);
    6767
     68  this->setBarrels(3);
     69  this->setSegs(1);
     70  this->activeBarrel = 0;
     71
     72  this->objComp = new PNode**[this->getBarrels()];
     73  this->emissionPoint = new PNode*[this->getBarrels()];
     74  this->shootAnim = new Animation3D**[this->getBarrels()];
     75  for (int i = 0; i < this->getBarrels(); i++)
     76  {
     77    this->objComp[i] = new PNode* [this->getSegs()];
     78    this->emissionPoint[i] = new PNode;
     79    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     80    this->emissionPoint[i]->setName("EmissionPoint");
     81    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     82    this->shootAnim[i] = new Animation3D* [this->getSegs()];
     83    for(int j = 0; j < this->getSegs(); j++)
     84    {
     85      this->objComp[i][j] = new PNode;
     86      this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
     87      this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
     88    }
     89  }
     90
     91  for (int i = 0; i < this->getBarrels(); i++ )
     92    this->emissionPoint[i]->setRelCoor(Vector(1.19, 0.0, 0.1));
     93
     94//   Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this);
    6895  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
    6996  Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
    7097
     98//   animation1->setInfinity(ANIM_INF_CONSTANT);
    7199  animation2->setInfinity(ANIM_INF_CONSTANT);
    72100  animation3->setInfinity(ANIM_INF_CONSTANT);
    73101
    74   this->setEmissionPoint(3.8, 1.2, 0);
     102//   this->setEmissionPoint(3.8, 1.2, 0);
     103
     104  for (int i = 0; i < this->getBarrels(); i++){
     105    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(0, 0, 0), 0.05, ANIM_NULL, ANIM_LINEAR);
     106    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(120, 0, 0), 0.0, ANIM_NULL, ANIM_LINEAR);
     107  }
     108
    75109
    76110  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
     
    96130  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*180);
    97131
    98   pj->setAbsCoor(this->getEmissionPoint());
     132  pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
    99133  pj->setAbsDir(this->getAbsDir());
    100   pj->toList(OM_GROUP_01_PROJ);
     134//   pj->toList(OM_GROUP_01_PROJ);
    101135  pj->activate();
     136
     137  for (int i = 0; i < this->getSegs(); i++)
     138    this->shootAnim[this->activeBarrel][i]->replay();
     139
     140  // switch barrel
     141  this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
    102142}
    103143
     
    118158void LightBlaster::draw() const
    119159{
     160  glMatrixMode(GL_MODELVIEW);
     161  glPushMatrix();
     162    glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
     163    Vector tmpRot = this->getAbsDir().getSpacialAxis();
     164    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     165    static_cast<StaticModel*>(this->getModel())->draw();
     166  glPopMatrix();
    120167}
  • branches/playability/src/world_entities/weapons/light_blaster.h

    r9975 r10152  
    2828    virtual void draw() const;
    2929
     30  private:
     31    PNode*** objComp;
     32    Animation3D*** shootAnim;
     33
     34    PNode** emissionPoint;
     35
     36    int activeBarrel;
    3037};
    3138
  • branches/playability/src/world_entities/weapons/weapon.cc

    r10140 r10152  
    124124  this->segs = 1;
    125125
     126  this->shootAnim = new Animation3D**[this->getBarrels()];
     127  for (int i = 0; i < this->getBarrels(); i++)
     128    this->shootAnim[i] = new Animation3D* [this->getSegs()];
     129
    126130  this->emissionPoint = new PNode*[this->barrels];
    127131  for(int i = 0; i < this->barrels; i++){
     
    150154  // set this object to be synchronized over network
    151155  //this->setSynchronized(true);
     156}
     157
     158/**
     159 * needed, if there are more than one barrel or segments
     160 */
     161void Weapon::init2()
     162{
     163  if (this->barrels == 1 && this->segs == 1)
     164    return;
     165
     166  delete this->emissionPoint[0];
     167  delete this->emissionPoint;
     168  delete this->shootAnim[0];
     169  delete this->shootAnim;
     170
     171  this->shootAnim = new Animation3D**[this->barrels];
     172  this->emissionPoint = new PNode*[this->barrels];
     173  for(int i = 0; i < this->barrels; i++){
     174    this->emissionPoint[i] = new PNode;
     175    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     176    this->emissionPoint[i]->setName("EmissionPoint");
     177    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     178    this->shootAnim[i] = new Animation3D* [this->segs];
     179  }
     180}
     181
     182/**
     183 * deconstructor for init2
     184 */
     185void Weapon::deconstr()
     186{
     187  for(int i = 0; i < this->barrels; i++) {
     188    delete this->emissionPoint[i];
     189    for (int j = 0; j < this->segs; j++)
     190      delete this->shootAnim[i][j];
     191    delete this->shootAnim[i];
     192  }
     193
     194  delete this->emissionPoint;
     195  delete this->shootAnim;
    152196}
    153197
     
    327371}
    328372
    329 Animation3D* Weapon::getAnimation(ShootingStates state, PNode* node)
    330 {
    331   if (state >= WS_SS_MAX) // if the state is not known
     373Animation3D* Weapon::getAnimation(int barrel, int seg, PNode* node)
     374{
     375  if (barrel >= this->getBarrels() || seg >= this->getSegs()) // if the state is not known
    332376    return NULL;
    333377
    334   if (unlikely(this->animation[state] == NULL)) // if the animation does not exist yet create it.
     378  if (unlikely(this->shootAnim[barrel][seg] == NULL)) // if the animation does not exist yet create it.
    335379  {
    336380    if (likely(node != NULL))
    337       return this->animation[state] = new Animation3D(node);
     381      return this->shootAnim[barrel][seg] = new Animation3D(node);
    338382    else
    339383    {
     
    343387  }
    344388  else
    345     return this->animation[state];
     389    return this->shootAnim[barrel][seg];
    346390}
    347391
  • branches/playability/src/world_entities/weapons/weapon.h

    r10140 r10152  
    5555  WS_STATE_COUNT  =     8     //!< This must match the count of enumerations-members.
    5656} WeaponState;
    57 
    58 typedef enum
    59 {
    60   WS_SHOOTING0    = 0x00000001, //!< Fireing 1st Barrel
    61   WS_SHOOTING1    = 0x00000002, //!< Fireing 2nd Barrel
    62   WS_SHOOTING2    = 0x00000004, //!< Fireing 3rd Barrel
    63   WS_SHOOTING3    = 0x00000008, //!< Fireing 4st Barrel
    64   WS_SHOOTING4    = 0x00000010, //!< Fireing 5st Barrel
    65   WS_SHOOTING5    = 0x00000020, //!< Fireing 6st Barrel
    66   WS_SHOOTING6    = 0x00000040, //!< Fireing 7st Barrel
    67   WS_SHOOTING7    = 0x00000080, //!< Fireing 8st Barrel
    68 
    69   WS_SS_MAX       = 0x000000ff
    70 }ShootingStates;
    7157
    7258//! an enumerator defining capabilities of a WeaponSlot
     
    177163
    178164    Animation3D* getAnimation(WeaponState state, PNode* node = NULL);
    179     Animation3D* getAnimation(ShootingStates state, PNode* node = NULL);
     165    Animation3D* getAnimation(int barrel, int seg, PNode* node);
    180166    Animation3D* copyAnimation(WeaponState from, WeaponState to);
    181167
     
    190176    void debug() const;
    191177
    192    
     178    inline int getBarrels() {return this->barrels; };
     179    inline int getSegs() { return this->segs; };
     180    inline void setBarrels(int barrels) { this->barrels = barrels; };
     181    inline void setSegs(int segs) { this->segs = segs; };
     182
     183    inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };
     184    inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };
     185
     186    void init2();
     187    void deconstr();
    193188
    194189  protected:
     
    208203
    209204
    210     inline int getBarrels() {return this->barrels; };
    211     inline int getSeg() {return this->segs; };
    212     inline void setBarrels(int barrels) { this->barrels = barrels; };
    213     inline void setSegs(int segs) { this->segs = segs; };
    214205
    215206  private:
     
    268259    int                    barrels;                         //!< # of barrels
    269260    int                    segs;                             //!< # of segments, one barrel has
     261    Animation3D***         shootAnim;
     262
    270263  };
    271264
Note: See TracChangeset for help on using the changeset viewer.