Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2007, 9:53:07 AM (18 years ago)
Author:
nicolasc
Message:

some additional weapons, started weapons cleanup

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/vs-enhencements/src/world_entities/weapons/disruptor.cc

    r10645 r10648  
    1515*/
    1616
    17 #include "heavy_blaster.h"
     17#include "disruptor.h"
    1818#include "world_entities/projectiles/projectile.h"
    1919
     
    2929#include "elements/glgui_energywidgetvertical.h"
    3030
    31 CREATE_FACTORY(HeavyBlaster);
    32 // ObjectListDefinition(HeavyBlaster);
     31CREATE_FACTORY(Disruptor);
     32// ObjectListDefinition(Disruptor);
    3333
    3434
     
    3737 * Standard constructor
    3838 */
    39 HeavyBlaster::HeavyBlaster (int leftRight)
     39Disruptor::Disruptor ()
    4040 : Weapon()
    4141{
    42 //     this->registerObject(this, HeavyBlaster::_objectList);
    43 
    44     this->init(leftRight);
    45 }
    46 
    47 HeavyBlaster::HeavyBlaster (const TiXmlElement* root = NULL)
     42//     this->registerObject(this, Disruptor::_objectList);
     43
     44    this->init();
     45}
     46
     47Disruptor::Disruptor (const TiXmlElement* root = NULL)
    4848 : Weapon()
    4949{
    50 //     this->registerObject(this, HeavyBlaster::_objectList);
     50//     this->registerObject(this, Disruptor::_objectList);
    5151
    5252    // TODO add leftRight to params
    53     this->init(0);
     53    this->init();
    5454    if (root != NULL)
    5555      this->loadParams(root);
     
    5959 * Default destructor
    6060 */
    61 HeavyBlaster::~HeavyBlaster()
     61Disruptor::~Disruptor()
    6262{
    6363  for (int i = 0; i < this->getBarrels(); i++)
     
    8585}
    8686
    87 void HeavyBlaster::loadParams(const TiXmlElement* root)
     87void Disruptor::loadParams(const TiXmlElement* root)
    8888{
    8989  Weapon::loadParams(root);
    9090}
    9191
    92 void HeavyBlaster::init(int leftRight)
    93 {
    94 
    95   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);
    99 
    100   this->loadModel("models/guns/frag_cannon2.obj", .4);
    101 
    102 
    103   this->setStateDuration(WS_SHOOTING, 0.5);   // 2 Schuss pro Sekunde
     92void Disruptor::init()
     93{
     94
     95  this->setScaling(.5);
     96
     97  this->loadModel("models/guns/disruptor.obj", this->getScaling());
     98
     99
     100  this->setStateDuration(WS_SHOOTING, 0.3333);  // 3 Shots per Second
    104101  this->setStateDuration(WS_RELOADING, 0);
    105102  this->setStateDuration(WS_ACTIVATING, .5);
     
    118115  this->prepareProjectiles(5);
    119116
    120   this->setBarrels(3);
    121   this->setSegs(2);
     117  this->setBarrels(1);
     118  this->setSegs(1);
    122119  this->activeBarrel = 0;
    123120
     
    131128    this->objComp[i] = new PNode* [this->getSegs()];
    132129    this->emissionPoint[i] = new PNode;
    133     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
     130    this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapon
    134131    this->emissionPoint[i]->setName("EmissionPoint");
    135132    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     
    143140  }
    144141
    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));
    150   }
    151   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));
    155   }
    156 
    157 
    158   for (int i = 0; i < this->getBarrels(); i++){
    159     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.05, 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.55, ANIM_LINEAR, ANIM_NULL);
    162 
    163     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.05, 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.25, ANIM_LINEAR, ANIM_NULL);
    166   }
     142  this->emissionPoint[0]->setRelCoor(Vector(1.672, 0.0, 0.0) * this->getScaling());
     143
    167144
    168145  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
     
    180157
    181158
    182 void HeavyBlaster::fire()
     159void Disruptor::fire()
    183160{
    184161  Projectile* pj =  this->getProjectile();
     
    197174
    198175  // initiate animation
    199   for (int i = 0; i < this->getSegs(); i++)
    200     this->shootAnim[this->activeBarrel][i]->replay();
     176//   for (int i = 0; i < this->getSegs(); i++)
     177//     this->shootAnim[this->activeBarrel][i]->replay();
    201178
    202179  // switch barrel
    203   this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
     180//   this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();
    204181}
    205182
     
    207184 *  this activates the weapon
    208185*/
    209 void HeavyBlaster::activate()
     186void Disruptor::activate()
    210187{
    211188}
     
    214191 *  this deactivates the weapon
    215192*/
    216 void HeavyBlaster::deactivate()
    217 {
    218 }
    219 
    220 
    221 void HeavyBlaster::draw() const
     193void Disruptor::deactivate()
     194{
     195}
     196
     197
     198void Disruptor::draw() const
    222199{
    223200  glMatrixMode(GL_MODELVIEW);
     
    229206    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    230207
    231   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);
     208  static_cast<StaticModel*>(this->getModel())->draw();
     209
    239210  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();
    265 
    266   glPopMatrix();
    267 }
    268 
    269 void HeavyBlaster::tick(float dt)
     211}
     212
     213void Disruptor::tick(float dt)
    270214{
    271215  if (!Weapon::tickW(dt))
Note: See TracChangeset for help on using the changeset viewer.