Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

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