Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10771 in orxonox.OLD


Ignore:
Timestamp:
Jun 27, 2007, 7:01:08 PM (17 years ago)
Author:
nicolasc
Message:

huge diff
cleaned the individual weapons, moved stuff to weapon.{cc,h}
and some minor fixes which popped up then and when

Location:
branches/presentation/src
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/lib/collision_detection/aabb_tree_node.cc

    r10698 r10771  
    882882
    883883  /* DRAW SEPARATING PLANE */
    884   if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL)
     884  if( (drawMode & DRAW_SEPARATING_PLANE) || (drawMode & DRAW_ALL))
    885885  {
    886886    if( !(drawMode & DRAW_SINGLE && depth != 0))
  • branches/presentation/src/lib/collision_detection/obb_tree_node.cc

    r10618 r10771  
    782782
    783783  /* DRAW POLYGONS */
    784   if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL || drawMode & DRAW_BV_BLENDED)
     784  if(( drawMode & DRAW_BV_POLYGON) || (drawMode & DRAW_ALL) || (drawMode & DRAW_BV_BLENDED))
    785785  {
    786786    if (top)
     
    932932
    933933  /* DRAW SEPARATING PLANE */
    934   if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL)
     934  if( (drawMode & DRAW_SEPARATING_PLANE) || drawMode & DRAW_ALL)
    935935  {
    936936    if( !(drawMode & DRAW_SINGLE && depth != 0))
  • branches/presentation/src/lib/graphics/importer/static_model.cc

    r10770 r10771  
    211211    }
    212212
    213 //     printf("adding MP\n");
     213
    214214     this->addMountPoint( zAxis, yAxis, center, groupName);
    215       // remove the group from the model list (mount points do not need to be drawn)
    216 //      std::vector<StaticModelData::Group>::iterator tmpIt =  groupIt;
    217 //      groupIt++;
     215     // remove the group from the model list (mount points do not need to be drawn)
     216     // remoing item iterates greoupIt!
    218217     this->data->getGroups().erase(groupIt);
    219218  }
  • branches/presentation/src/util/hud.cc

    r10766 r10771  
    846846        std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
    847847        Vector2D pos = Vector2D(overlayWidth, 0.4*this->resY);
    848         float largestWidgetSizeX = 0;
     848//      float largestWidgetSizeX = 0; //unused variable
    849849
    850850        for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
  • branches/presentation/src/world_entities/projectiles/projectile_weapon.cc

    r10749 r10771  
    147147}
    148148
    149 
     149/*
    150150void ProjectileWeapon::collidesWith (WorldEntity* target, const Vector& location)
    151151{
     
    154154  this->destroy(target);
    155155}
    156 
     156*/
    157157
    158158
  • branches/presentation/src/world_entities/projectiles/projectile_weapon.h

    r10618 r10771  
    5959    virtual void destroy (WorldEntity* killer);
    6060
    61     virtual void collidesWith (WorldEntity* target, const Vector& location);  //!< collision handler; used against SpaceShip as most target will be
     61//    virtual void collidesWith (WorldEntity* target, const Vector& location);  //!< collision handler; used against SpaceShip as most target will be
    6262
    6363
  • branches/presentation/src/world_entities/projectiles/test_bullet.cc

    r10737 r10771  
    3535  this->registerObject(this, TestBullet::_objectList);
    3636
    37   this->loadModel("models/projectiles/orx-rocket.obj", .3);
     37  this->loadModel("models/projectiles/orx-rocket.obj", .6); // FIXME model no longer avaiable
    3838
    3939  this->setMinEnergy(1);
     
    170170  this->getAbsDir().matrix (matrix);
    171171  glMultMatrixf((float*)matrix);
    172   glScalef(2.0, 2.0, 2.0);
     172//   glScalef(2.0, 2.0, 2.0); // no double rescale, changed size in modelloader
    173173  this->getModel()->draw();
    174174
  • branches/presentation/src/world_entities/weapons/disruptor.cc

    r10747 r10771  
    5555Disruptor::~Disruptor()
    5656{
    57   for (int i = 0; i < this->getBarrels(); i++)
    58   {
    59    delete [] this->shootAnim[i];
    60    delete [] this->objComp[i];
    61   }
    62   delete [] this->emissionPoint;
    63 
    64    delete [] this->shootAnim;
    65    delete [] this->objComp;
    66 
    6757}
    6858
     
    9989  this->setBarrels(1);
    10090  this->setSegs(1);
    101   this->activeBarrel = 0;
    10291
     92  this->setEmissionPoint(Vector(1.672, 0.0, 0.0) * this->getScaling());
    10393
    104 
    105   this->objComp = new PNode**[this->getBarrels()];
    106   this->emissionPoint = new PNode*[this->getBarrels()];
    107   this->shootAnim = new Animation3D**[this->getBarrels()];
    108   for (int i = 0; i < this->getBarrels(); i++)
    109   {
    110     this->objComp[i] = new PNode* [this->getSegs()];
    111     this->emissionPoint[i] = new PNode;
    112     this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapon
    113     this->emissionPoint[i]->setName("EmissionPoint");
    114     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    115     this->shootAnim[i] = new Animation3D* [this->getSegs()];
    116     for(int j = 0; j < this->getSegs(); j++)
    117     {
    118       this->objComp[i][j] = new PNode;
    119       this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
    120       this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
    121     }
    122   }
    123 
    124   this->emissionPoint[0]->setRelCoor(Vector(1.672, 0.0, 0.0) * this->getScaling());
    125 
    126 
    127   this->shootAnim[0][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    128   this->shootAnim[0][0]->addKeyFrame(Vector(-0.5, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL);
     94  this->getShootAnim(0, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
     95  this->getShootAnim(0, 0)->addKeyFrame(Vector(-0.5, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL);
    12996//   this->shootAnim[0][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    13097
     
    158125  pj->setVelocity((tmp.getNormalized())*130 + VECTOR_RAND(1));
    159126
    160   pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
     127  pj->setAbsCoor(this->getEmissionPoint());
    161128  pj->setAbsDir(this->getAbsDir());
    162129  pj->activate();
    163130
    164131
    165   this->shootAnim[0][0]->replay();
     132  this->getShootAnim(0, 0)->replay();
    166133}
    167134
     
    196163    // Barrel
    197164    glPushMatrix();
    198       glTranslatef(this->objComp[0][0]->getAbsCoor().x, this->objComp[0][0]->getAbsCoor().y, this->objComp[0][0]->getAbsCoor().z);
     165      glTranslatef(this->getObjCompx(0,0), this->getObjCompy(0,0), this->getObjCompz(0,0));
    199166      static_cast<StaticModel*>(this->getModel())->draw(0);
    200167    glPopMatrix();
     168
    201169  glPopMatrix();
    202170}
  • branches/presentation/src/world_entities/weapons/disruptor.h

    r10698 r10771  
    3434
    3535  private:
    36     PNode*** objComp;
    37     Animation3D*** shootAnim;
    38     PNode** emissionPoint;
    3936
    40     int activeBarrel;
    41 
    42 //     int leftRight;
    4337};
    4438
  • branches/presentation/src/world_entities/weapons/heavy_blaster.cc

    r10698 r10771  
    3030
    3131CREATE_FACTORY(HeavyBlaster);
    32 // ObjectListDefinition(HeavyBlaster);
    33 
    3432
    3533
     
    3735 * Standard constructor
    3836 */
    39 HeavyBlaster::HeavyBlaster (int leftRight)
     37HeavyBlaster::HeavyBlaster (int leftRight = W_RIGHT)
    4038 : Weapon()
    4139{
    42 //     this->registerObject(this, HeavyBlaster::_objectList);
    4340
    4441    this->init(leftRight);
     
    6158HeavyBlaster::~HeavyBlaster()
    6259{
    63   for (int i = 0; i < this->getBarrels(); i++)
    64   {
    65    delete [] this->shootAnim[i];
    66    delete [] this->objComp[i];
    67   }
    68   delete [] this->emissionPoint;
    69 
    70    delete [] this->shootAnim;
    71    delete [] this->objComp;
    72 /*
    73     for(int j = 0; j < this->getSegs(); j++)
    74     {
    75       delete this->shootAnim[i][j];
    76       delete this->objComp[i][j];
    77     }
    78     delete this->shootAnim[i];
    79     delete this->objComp[i];
    80     delete this->emissionPoint[i];
    81   }*/
    82 
    83 //  this->deconstr();
    84      // model will be deleted from WorldEntity-destructor
    8560}
    8661
     
    9469
    9570  this->leftRight = leftRight;
    96   //this->registerObject(this, HeavyBlaster::_objectList);
    97 
    98 //  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
    9971
    10072  this->loadModel("models/guns/frag_cannon2.obj", .4);
     
    10880  this->setEnergyMax(500);
    10981  this->increaseEnergy(500);
    110   //this->minCharge = 2;
    11182
    11283  this->setActionSound(WA_SHOOT, "sounds/guns/laser.wav");
     
    12091  this->setBarrels(3);
    12192  this->setSegs(2);
    122   this->activeBarrel = 0;
    123 
    124 
    125 
    126   this->objComp = new PNode**[this->getBarrels()];
    127   this->emissionPoint = new PNode*[this->getBarrels()];
    128   this->shootAnim = new Animation3D**[this->getBarrels()];
    129   for (int i = 0; i < this->getBarrels(); i++)
     93
     94
     95  if (this->leftRight == W_LEFT)
    13096  {
    131     this->objComp[i] = new PNode* [this->getSegs()];
    132     this->emissionPoint[i] = new PNode;
    133     this->emissionPoint[i]->setParent(this);      //Parenting emissionPoint to Weapons
    134     this->emissionPoint[i]->setName("EmissionPoint");
    135     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    136     this->shootAnim[i] = new Animation3D* [this->getSegs()];
    137     for(int j = 0; j < this->getSegs(); j++)
    138     {
    139       this->objComp[i][j] = new PNode;
    140       this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
    141       this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
    142     }
    143   }
    144 
    145   if (this->leftRight == W_RIGHT)
    146   {
    147     this->emissionPoint[0]->setRelCoor(Vector(1.1, 0.14, 0.06));
    148     this->emissionPoint[1]->setRelCoor(Vector(1.1, -.06, 0.14));
    149     this->emissionPoint[2]->setRelCoor(Vector(1.1, 0.06, -.14));
     97    this->setEmissionPoint(Vector(1.1, 0.14, -.06), 0);
     98    this->setEmissionPoint(Vector(1.1, -.06, -.14), 1);
     99    this->setEmissionPoint(Vector(1.1, 0.06, 0.14), 2);
    150100  }
    151101  else {
    152     this->emissionPoint[0]->setRelCoor(Vector(1.1, 0.14, -.06));
    153     this->emissionPoint[1]->setRelCoor(Vector(1.1, -.06, -.14));
    154     this->emissionPoint[2]->setRelCoor(Vector(1.1, 0.06, 0.14));
     102    this->setEmissionPoint(Vector(1.1, 0.14, 0.06), 0);
     103    this->setEmissionPoint(Vector(1.1, -.06, 0.14), 1);
     104    this->setEmissionPoint(Vector(1.1, 0.06, -.14), 2);
    155105  }
    156106
    157107
    158108  for (int i = 0; i < this->getBarrels(); i++){
    159     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
    160     this->shootAnim[i][0]->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 0.9, ANIM_LINEAR, ANIM_NULL);
    161     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
    162 
    163     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    164     this->shootAnim[i][1]->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.2, ANIM_LINEAR, ANIM_NULL);
    165     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL);
     109    this->getShootAnim(i, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     110    this->getShootAnim(i, 0)->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 0.9, ANIM_LINEAR, ANIM_NULL);
     111    this->getShootAnim(i, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
     112
     113    this->getShootAnim(i, 1)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
     114    this->getShootAnim(i, 1)->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.2, ANIM_LINEAR, ANIM_NULL);
     115    this->getShootAnim(i, 1)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL);
    166116  }
    167117
     
    192142  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1));
    193143
    194   pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
     144  pj->setAbsCoor(this->getEmissionPoint());
    195145  pj->setAbsDir(this->getAbsDir());
    196146  pj->activate();
     
    198148  // initiate animation
    199149  for (int i = 0; i < this->getSegs(); i++)
    200     this->shootAnim[this->activeBarrel][i]->replay();
    201 
    202   // switch barrel
    203   this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
     150    this->getShootAnim(this->getActiveBarrel(), i)->replay(); // FIXME needs clean up
     151
     152  this->cycleBarrel();
    204153}
    205154
     
    230179
    231180  if (this->leftRight == W_LEFT)
    232     glScalef(1.0, 1.0, -1.0);
    233 
    234   static_cast<StaticModel*>(this->getModel())->draw(6);
    235 
    236   glPushMatrix();
    237     glTranslatef (this->objComp[0][0]->getAbsCoor().x, this->objComp[0][0]->getAbsCoor().y, this->objComp[0][0]->getAbsCoor().z);
    238     static_cast<StaticModel*>(this->getModel())->draw(2);
    239   glPopMatrix();
    240 
    241   glPushMatrix();
    242     glTranslatef (this->objComp[1][0]->getAbsCoor().x, this->objComp[1][0]->getAbsCoor().y, this->objComp[1][0]->getAbsCoor().z);
    243     static_cast<StaticModel*>(this->getModel())->draw(3);
    244   glPopMatrix();
    245 
    246   glPushMatrix();
    247     glTranslatef (this->objComp[2][0]->getAbsCoor().x, this->objComp[2][0]->getAbsCoor().y, this->objComp[2][0]->getAbsCoor().z);
    248     static_cast<StaticModel*>(this->getModel())->draw(1);
    249   glPopMatrix();
    250 
    251   glPushMatrix();
    252     glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);
    253     static_cast<StaticModel*>(this->getModel())->draw(4);
    254   glPopMatrix();
    255 
    256   glPushMatrix();
    257     glTranslatef (this->objComp[1][1]->getAbsCoor().x, this->objComp[1][1]->getAbsCoor().y, this->objComp[1][1]->getAbsCoor().z);
    258     static_cast<StaticModel*>(this->getModel())->draw(5);
    259   glPopMatrix();
    260 
    261   glPushMatrix();
    262     glTranslatef (this->objComp[2][1]->getAbsCoor().x, this->objComp[2][1]->getAbsCoor().y, this->objComp[2][1]->getAbsCoor().z);
    263     static_cast<StaticModel*>(this->getModel())->draw(0);
    264   glPopMatrix();
     181    glScalef(1.0, 1.0, -1.0); //FIXME check weather this causes a slowdown...
     182
     183    static_cast<StaticModel*>(this->getModel())->draw(6);
     184
     185    glPushMatrix();
     186      glTranslatef (this->getObjCompx(0,0), this->getObjCompy(0,0), this->getObjCompz(0,0));
     187      static_cast<StaticModel*>(this->getModel())->draw(2);
     188    glPopMatrix();
     189
     190    glPushMatrix();
     191      glTranslatef (this->getObjCompx(1,0), this->getObjCompy(1,0), this->getObjCompz(1,0));
     192      static_cast<StaticModel*>(this->getModel())->draw(3);
     193    glPopMatrix();
     194
     195    glPushMatrix();
     196      glTranslatef (this->getObjCompx(2,0), this->getObjCompy(2,0), this->getObjCompz(2,0));
     197      static_cast<StaticModel*>(this->getModel())->draw(1);
     198    glPopMatrix();
     199
     200    glPushMatrix();
     201      glTranslatef (this->getObjCompx(0,1), this->getObjCompy(0,1), this->getObjCompz(0,1));
     202      static_cast<StaticModel*>(this->getModel())->draw(4);
     203    glPopMatrix();
     204
     205    glPushMatrix();
     206      glTranslatef (this->getObjCompx(1,1), this->getObjCompy(1,1), this->getObjCompz(1,1));
     207      static_cast<StaticModel*>(this->getModel())->draw(5);
     208    glPopMatrix();
     209
     210    glPushMatrix();
     211      glTranslatef (this->getObjCompx(2,1), this->getObjCompy(2,1), this->getObjCompz(2,1));
     212      static_cast<StaticModel*>(this->getModel())->draw(0);
     213    glPopMatrix();
    265214
    266215  glPopMatrix();
  • branches/presentation/src/world_entities/weapons/heavy_blaster.h

    r10516 r10771  
    22#define HEAVY_BLASTER_H
    33
    4 
    54#include "weapon.h"
    6 
    7 #define    W_LEFT        0
    8 #define    W_RIGHT       1
    95
    106/**
     
    3430
    3531  private:
    36     PNode*** objComp;
    37     Animation3D*** shootAnim;
    38     PNode** emissionPoint;
    39 
    40     int activeBarrel;
    4132
    4233    int leftRight;
  • branches/presentation/src/world_entities/weapons/light_blaster.cc

    r10698 r10771  
    5353{
    5454
    55   for (int i = 0; i < this->getBarrels(); i++)
    56   {
    57    //delete [] this->shootAnim[i];
    58    delete [] this->objComp[i];
    59   }
    60   delete [] this->emissionPoint;
    61    //delete [] this->shootAnim;
    62    delete [] this->objComp;
    63 
    6455}
    6556
     
    9384
    9485  this->setBarrels(3);
    95   this->setSegs(1);
    96   this->activeBarrel = 0;
     86  this->setSegs(1); //could be left out
    9787
    98   this->objComp = new PNode**[this->getBarrels()];
    99   this->emissionPoint = new PNode*[this->getBarrels()];
    100 //   this->shootAnim = new Animation3D**[this->getBarrels()];
    101   for (int i = 0; i < this->getBarrels(); i++)
    102   {
    103     this->objComp[i] = new PNode* [this->getSegs()];
    104     this->emissionPoint[i] = new PNode;
    105     this->emissionPoint[i]->setParent(this);
    106     this->emissionPoint[i]->setName("EmissionPoint");
    107     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    108     for(int j = 0; j < this->getSegs(); j++)
    109     {
    110       this->objComp[i][j] = new PNode;
    111 //       this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
    112 //       this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
    113     }
    114   }
    115 
    116   this->emissionPoint[0]->setRelCoor(Vector(2.2, 0.0, 0.1));
    117   this->emissionPoint[1]->setRelCoor(Vector(2.2, -0.07, -0.05));
    118   this->emissionPoint[2]->setRelCoor(Vector(2.2, 0.07, -0.05));
     88  this->setEmissionPoint(Vector(2.2, 0.0, 0.1), 0);
     89  this->setEmissionPoint(Vector(2.2, -0.07, -0.05), 1);
     90  this->setEmissionPoint(Vector(2.2, 0.07, -0.05), 2);
    11991
    12092//   Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this);
     
    148120  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*180);
    149121
    150   pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
     122  pj->setAbsCoor(this->getEmissionPoint());
    151123  pj->setAbsDir(this->getAbsDir());
    152124//   pj->toList(OM_GROUP_01_PROJ);
    153125  pj->activate();
    154126
    155 //   for (int i = 0; i < this->getSegs(); i++)
    156 //     this->shootAnim[this->activeBarrel][i]->replay();
    157 
    158   // switch barrel
    159   this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
     127  this->cycleBarrel();
    160128}
    161129
  • branches/presentation/src/world_entities/weapons/light_blaster.h

    r10516 r10771  
    3131
    3232  private:
    33     PNode*** objComp;
    34     Animation3D*** shootAnim;
    3533
    36     PNode** emissionPoint;
    37 
    38     int activeBarrel;
    3934};
    4035
  • branches/presentation/src/world_entities/weapons/medium_blaster.cc

    r10698 r10771  
    5454MediumBlaster::~MediumBlaster()
    5555{
    56       // model will be deleted from WorldEntity-destructor
    57   for (int i = 0; i < this->getBarrels(); i++)
    58   {
    59    delete [] this->shootAnim[i];
    60   }
    61   delete [] this->shootAnim;
    6256}
    6357
     
    7670
    7771  this->setStateDuration(WS_RELOADING, 0);
    78   this->setStateDuration(WS_ACTIVATING, .5); //.5);
    79   this->setStateDuration(WS_DEACTIVATING, 1); // 1);
     72  this->setStateDuration(WS_ACTIVATING, .5);
     73  this->setStateDuration(WS_DEACTIVATING, 1);
    8074
    8175  this->setEnergyMax(500);
     
    9488  this->setBarrels(1);
    9589  this->setSegs(2);
    96   this->activeBarrel = 0;
    9790
    98   this->objComp = new PNode**[this->getBarrels()];
    99   this->emissionPoint = new PNode*[this->getBarrels()];
    100   this->shootAnim = new Animation3D**[this->getBarrels()];
    101   for (int i = 0; i < this->getBarrels(); i++)
    102   {
    103     this->objComp[i] = new PNode* [this->getSegs()];
    104     this->emissionPoint[i] = new PNode;
    105     this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapon
    106     this->emissionPoint[i]->setName("EmissionPoint");
    107     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    108     this->shootAnim[i] = new Animation3D* [this->getSegs()];
    109     for(int j = 0; j < this->getSegs(); j++)
    110     {
    111       this->objComp[i][j] = new PNode;
    112       this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
    113       this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
    114     }
    115   }
    11691
    11792  for (int i = 0; i < this->getBarrels(); i++){
    118     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
    119     this->shootAnim[i][0]->addKeyFrame(Vector(-1.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
    120     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     93    this->getShootAnim(i, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
     94    this->getShootAnim(i, 0)->addKeyFrame(Vector(-1.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
     95    this->getShootAnim(i, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
    12196
    122     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
    123     this->shootAnim[i][1]->addKeyFrame(Vector(.5, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
    124     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     97    this->getShootAnim(i, 1)->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
     98    this->getShootAnim(i, 1)->addKeyFrame(Vector(.5, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
     99    this->getShootAnim(i, 1)->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
    125100  }
    126101
     
    131106  animation3->setInfinity(ANIM_INF_CONSTANT);
    132107
    133   this->emissionPoint[0]->setRelCoor(Vector(3.9, 0.0, 0.0) * this->getScaling());
     108  this->setEmissionPoint(Vector(3.9, 0.0, 0.0) * this->getScaling());
    134109
    135110  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
     
    159134
    160135  for (int i = 0; i < this->getSegs(); i++)
    161     this->shootAnim[this->activeBarrel][i]->replay();
     136    this->getShootAnim(this->getActiveBarrel(), i)->replay(); // FIXME needs clean up
    162137}
    163138
     
    187162
    188163  glPushMatrix();
    189     glTranslatef (this->objComp[0][0]->getAbsCoor().x, this->objComp[0][0]->getAbsCoor().y, this->objComp[0][0]->getAbsCoor().z);
     164    glTranslatef (this->getObjCompx(0,0), this->getObjCompy(0,0), this->getObjCompz(0,0));
    190165    static_cast<StaticModel*>(this->getModel())->draw(1);
    191166  glPopMatrix();
    192167
    193168  glPushMatrix();
    194     glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);
     169    glTranslatef (this->getObjCompx(0,1), this->getObjCompy(0,1), this->getObjCompz(0,1));
    195170    static_cast<StaticModel*>(this->getModel())->draw(2);
    196171  glPopMatrix();
  • branches/presentation/src/world_entities/weapons/medium_blaster.h

    r10698 r10771  
    3131
    3232  private:
    33     PNode*** objComp;
    34     Animation3D*** shootAnim;
    35     PNode** emissionPoint;
    36 
    37     int activeBarrel;
    3833
    3934};
  • branches/presentation/src/world_entities/weapons/nadion_laser.cc

    r10763 r10771  
    5454NadionLaser::~NadionLaser()
    5555{
    56   // model will be deleted from WorldEntity-destructor
    57   for (int i = 0; i < this->getBarrels(); i++)
    58   {
    59    delete [] this->shootAnim[i];
    60   }
    61   delete [] this->shootAnim;
    6256}
    6357
     
    9286
    9387
    94   this->setBarrels(1);
    95   this->setSegs(1);
    96   this->activeBarrel = 0;
     88  this->setBarrels(1); // could be left out
     89  this->setSegs(1);    // could be left out
    9790
    98   this->objComp = new PNode**[this->getBarrels()];
    99   this->emissionPoint = new PNode*[this->getBarrels()];
    100   this->shootAnim = new Animation3D**[this->getBarrels()];
    101   for (int i = 0; i < this->getBarrels(); i++)
    102   {
    103     this->objComp[i] = new PNode* [this->getSegs()];
    104     this->emissionPoint[i] = new PNode;
    105     this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapon
    106     this->emissionPoint[i]->setName("EmissionPoint");
    107     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    108     this->shootAnim[i] = new Animation3D* [this->getSegs()];
    109     for(int j = 0; j < this->getSegs(); j++)
    110     {
    111       this->objComp[i][j] = new PNode;
    112       this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
    113       this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
    114     }
    115   }
    116 
    117   this->emissionPoint[0]->setRelCoor(Vector(1.680, 0.0, 0.0) * this->getScaling());
     91  this->setEmissionPoint(Vector(1.680, 0.0, 0.0) * this->getScaling());
    11892
    11993  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
     
    143117
    144118  Vector dir = (this->getDefaultTarget()->getAbsCoor() - this->getAbsCoor()).getNormalized();
     119  //FIXME direction calculation is a mess, needs to be cleaned up
    145120  // HACK direction AbsDir calulation
    146121  Vector up = dir.cross(VECTOR_RAND(1));
  • branches/presentation/src/world_entities/weapons/nadion_laser.h

    r10698 r10771  
    2727
    2828  private:
    29     PNode*** objComp;
    30     Animation3D*** shootAnim;
    31     PNode** emissionPoint;
    32 
    33     int activeBarrel;
    3429
    3530};
  • branches/presentation/src/world_entities/weapons/rf_cannon.cc

    r10728 r10771  
    5555RFCannon::~RFCannon()
    5656{
    57   for (int i = 0; i < this->getBarrels(); i++)
    58     delete [] this->objComp[i];
    59 
    60   delete [] this->emissionPoint;
    61   delete [] this->objComp;
    6257}
    6358
     
    9186  this->setBarrels(4);
    9287  this->setSegs(1);
    93   this->activeBarrel = (rand() % 4);
     88  this->setActiveBarrel(rand() % 4);
    9489
    95   this->objComp = new PNode**[this->getBarrels()];
    96   this->emissionPoint = new PNode*[this->getBarrels()];
    97   for (int i = 0; i < this->getBarrels(); i++) {
    98     this->objComp[i] = new PNode* [this->getSegs()];
    99     this->emissionPoint[i] = new PNode;
    100     this->emissionPoint[i]->setParent(this);
    101     this->emissionPoint[i]->setName("EmissionPoint");
    102     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    103     for(int j = 0; j < this->getSegs(); j++) {
    104       this->objComp[i][j] = new PNode;
    105     }
    106   }
    10790
    108   this->emissionPoint[0]->setRelCoor(Vector(4.1, 0.0, 0.75) * this->getScaling());
    109   this->emissionPoint[1]->setRelCoor(Vector(4.1, 0.45, 0.0) * this->getScaling());
    110   this->emissionPoint[2]->setRelCoor(Vector(4.1, 0.0, -0.75) * this->getScaling());
    111   this->emissionPoint[3]->setRelCoor(Vector(4.1, -0.45, 0.0) * this->getScaling());
     91  this->setEmissionPoint(Vector(4.1, 0.0, 0.75) * this->getScaling(), 0);
     92  this->setEmissionPoint(Vector(4.1, 0.45, 0.0) * this->getScaling(), 1);
     93  this->setEmissionPoint(Vector(4.1, 0.0, -0.75) * this->getScaling(), 2);
     94  this->setEmissionPoint(Vector(4.1, -0.45, 0.0) * this->getScaling(), 3);
    11295
    11396  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
     
    140123  pj->setVelocity(this->getParent()->getVelocity() + (tmp.getNormalized())*190);
    141124
    142   pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
     125  pj->setAbsCoor(this->getEmissionPoint());
     126  //FIXME pj needs a absDir
    143127//   pj->setAbsDir(this->getAbsDir());
    144128//   pj->setAbsDir(Quaternion(tmp.getNormalized(), this->getParent()->getAbsDir().apply(Vector(0,1,0))));
     
    146130  pj->activate();
    147131
    148   this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
     132  this->cycleBarrel();
    149133}
    150134
  • branches/presentation/src/world_entities/weapons/rf_cannon.h

    r10698 r10771  
    2929
    3030  private:
    31     PNode*** objComp;
    32     Animation3D*** shootAnim;
    3331
    34     PNode** emissionPoint;
    35 
    36     int activeBarrel;
    3732};
    3833
  • branches/presentation/src/world_entities/weapons/test_gun.h

    r9869 r10771  
    3131 * @todo this will be reset with mirror X/Y/Z
    3232 */
    33 #define    W_LEFT        0
    34 #define    W_RIGHT       1
     33// #define    W_LEFT        0
     34// #define    W_RIGHT       1
    3535
    3636
  • branches/presentation/src/world_entities/weapons/weapon.cc

    r10698 r10771  
    6262  if (OrxSound::SoundSource::objectList().exists(this->soundSource))
    6363    delete this->soundSource;
     64
     65//   for (int i = 0; i < MAX_BARRELS; i++)
     66//   {
     67//    delete [] this->shootAnim[i];
     68//    delete [] this->objComp[i];
     69//   }
     70//   delete [] this->emissionPoint;
     71//   delete [] this->shootAnim;
     72//   delete [] this->objComp;
     73
    6474}
    6575
     
    121131  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource
    122132
    123   this->barrels = 1;
     133  this->barrels = 1;  // just to have an initial value
    124134  this->segs = 1;
     135  this->activeBarrel = 0;
    125136
    126137  this->preferedSide = -1;
    127138  this->preferedSlot = -1;
    128 
    129   this->shootAnim = new Animation3D**[this->getBarrels()];
    130   for (int i = 0; i < this->getBarrels(); i++)
    131     this->shootAnim[i] = new Animation3D* [this->getSegs()];
    132 
    133   this->emissionPoint = new PNode*[this->barrels];
    134   for(int i = 0; i < this->barrels; i++){
     139  this->side = -1;
     140
     141  //!< forward initialisation of animation and emissionpoints
     142  for (int i = 0; i < MAX_BARRELS; i++){
    135143    this->emissionPoint[i] = new PNode;
    136144    this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapons
    137145    this->emissionPoint[i]->setName("EmissionPoint");
    138146    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     147    for(int j = 0; j < MAX_SEGMENTS; j++)
     148    {
     149      this->objComp[i][j] = new PNode;
     150      this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
     151      this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
     152    }
    139153  }
    140154
     
    149163  this->maxCharge = 1.0;                           //< The maximum charge is also one unit.
    150164
    151   this->energy = 10;                               //< The secondary Buffer (before we have to reload)
     165  this->energy = 10.0;                               //< The secondary Buffer (before we have to reload)
    152166  this->energyMax = 10.0;                          //< How much energy can be carried
    153167  this->capability = WTYPE_ALL;                    //< The Weapon has all capabilities @see W_Capability.
     
    176190  LoadParam(root, "slot", this, Weapon, setPreferedSlot)
    177191  .describe("slot this weapon will be added");
    178 /*
    179   LoadParam(root, "emission-point", this, Weapon, setEmissionPoint)
    180   .describe("Sets the Point of emission of this weapon (1: EmmsionVector; 2: EmissionPoint)");*/
    181192
    182193  LoadParam(root, "state-duration", this, Weapon, setStateDuration)
     
    274285 * sets the emissionPoint's relative position from the Weapon
    275286 * @param point the Point relative to the mass-point of the Weapon
     287 * @param barrel (optional) define a specific barrel, default = 0
    276288 */
    277289void Weapon::setEmissionPoint(const Vector& point, int barrel)
     
    280292}
    281293
    282 void Weapon::setEmissionPoint(const Vector& point)
    283 {
    284   this->emissionPoint[0]->setRelCoor(point);
    285 }
     294// void Weapon::setEmissionPoint(const Vector& point)
     295// {
     296//   this->emissionPoint[0]->setRelCoor(point);
     297// }
    286298
    287299/**
  • branches/presentation/src/world_entities/weapons/weapon.h

    r10707 r10771  
    2020
    2121#include "sound_buffer.h"
     22
     23#define MAX_SEGMENTS 3
     24#define MAX_BARRELS 4
     25
     26#define    W_LEFT        0
     27#define    W_RIGHT       1
    2228
    2329// FORWARD DECLARATION
     
    129135    // EMISSION
    130136    /** keeping old functions*/
    131     void setEmissionPoint(const Vector& point, int barrel);
    132     void setEmissionPoint(const Vector& point);
     137    void setEmissionPoint(const Vector& point, int barrel = 0);
     138//     void setEmissionPoint(const Vector& point);
    133139    /** @see void setEmissionPoint(const Vector& point); */
    134     inline void setEmissionPoint(float x, float y, float z, int barrel) { this->setEmissionPoint(Vector(x, y, z), barrel); };
    135     inline void setEmissionPoint(float x, float y, float z) { this->setEmissionPoint(Vector(x, y, z)); };
     140    inline void setEmissionPoint(float x, float y, float z, int barrel = 0) { this->setEmissionPoint(Vector(x, y, z), barrel); };
     141//     inline void setEmissionPoint(float x, float y, float z) { this->setEmissionPoint(Vector(x, y, z)); };
    136142    /** @returns the absolute Position of the EmissionPoint */
    137143    inline const Vector& getEmissionPoint(int barrel) const { return this->emissionPoint[barrel]->getAbsCoor(); };
    138     inline const Vector& getEmissionPoint() const { return this->emissionPoint[0]->getAbsCoor(); };
     144    inline const Vector& getEmissionPoint() const { return this->emissionPoint[this->activeBarrel]->getAbsCoor(); };
    139145
    140146
     
    182188    inline void setBarrels(int barrels) { this->barrels = barrels; };
    183189    inline void setSegs(int segs) { this->segs = segs; };
    184 
    185 //     inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };
    186 //     inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };
     190    inline void setActiveBarrel(int ab) {this->activeBarrel = ab; };
     191    inline int getActiveBarrel() { return this->activeBarrel; };
     192    inline void cycleBarrel() { this->activeBarrel = (this->activeBarrel + 1) % this->barrels; };
     193
     194    Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };
     195//     void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };
    187196
    188197//     void init2();
    189     void deconstr();
     198//     void deconstr();
    190199
    191200    inline int getPreferedSide() { return this->preferedSide; }
     
    194203    inline void setEnergyWidgetInitialized(bool b) {this->isEnergyWidgetInitialized = b;};
    195204
     205    inline const Vector& getObjComp(int barrel, int seg) const { return this->objComp[barrel][seg]->getAbsCoor(); };
     206    inline const float getObjCompx(int barrel, int seg) const { return this->objComp[barrel][seg]->getAbsCoor().x; };
     207    inline const float getObjCompy(int barrel, int seg) const { return this->objComp[barrel][seg]->getAbsCoor().y; };
     208    inline const float getObjCompz(int barrel, int seg) const { return this->objComp[barrel][seg]->getAbsCoor().z; };
    196209
    197210  protected:
     
    264277    OrxSound::SoundBuffer  soundBuffers[WA_ACTION_COUNT];   //!< SoundBuffers for all actions @see WeaponAction.
    265278
    266     PNode**                emissionPoint;                   //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
     279    PNode*                 emissionPoint[MAX_BARRELS];                   //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
    267280
    268281    bool                   hideInactive;                    //!< Hides the Weapon if it is inactive
     
    272285    FastFactory*           projectileFactory;               //!< A factory, that produces and handles the projectiles.
    273286
    274     int                    barrels;                         //!< # of barrels
    275     int                    segs;                             //!< # of segments, one barrel has
    276     Animation3D***         shootAnim;
     287    int                    barrels;                         //!< # of barrels (max 4)
     288    int                    segs;                            //!< # of segments, one barrel has (max 3)
     289    int                    activeBarrel;
     290    Animation3D*           shootAnim[MAX_BARRELS][MAX_SEGMENTS];
     291    PNode*                 objComp[MAX_BARRELS][MAX_SEGMENTS];
    277292
    278293    int                    preferedSlot;                    //!< prefered slot to add
    279294    int                    preferedSide;                    //!< prefered side (left/right) to be added
     295    int                    side;                            //!< describes left/right orientation of the weapon.
    280296
    281297  };
  • branches/presentation/src/world_entities/world_entity.cc

    r10770 r10771  
    5454
    5555SHELL_COMMAND(model, WorldEntity, loadModel)
    56 ->describe("sets the Model of the WorldEntity")
    57 ->defaultValues("models/ships/fighter.obj", 1.0f);
     56  ->describe("sets the Model of the WorldEntity")
     57  ->defaultValues("models/ships/fighter.obj", 1.0f);
    5858
    5959SHELL_COMMAND(debugEntity, WorldEntity, debugWE);
Note: See TracChangeset for help on using the changeset viewer.