Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 27, 2006, 12:03:36 PM (19 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/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}
Note: See TracChangeset for help on using the changeset viewer.