Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2005, 9:29:41 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/physics: merged with trunk - with command svn merge -r 3866:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/world_entities/test_gun.cc

    r3855 r3953  
    4040   creates a new weapon
    4141*/
    42 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction, int leftRight)
     42TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight)
    4343  :  Weapon (parent, coordinate, direction)
    4444{
     
    4747  this->leftRight = leftRight;
    4848
    49   if( this->leftRight == 0)
    50     this->projOffset = new Vector(1.0, 0.0, -0.35);
    51   else if( this->leftRight == 1)
    52     this->projOffset = new Vector(1.0, 0.0, 0.5);
     49  this->objectComponent1 = new PNode();
     50  this->animation1 = new Animation3D(this->objectComponent1);
     51  parent->addChild(this->objectComponent1, PNODE_ALL);
    5352
     53  this->animation1->setInfinity(ANIM_INF_CONSTANT);
     54  // ANIM_LINEAR was ANIM_NEG_EXP
     55  if( this->leftRight == W_LEFT)
     56    {
     57      this->projectileOffset = Vector(1.0, 0.0, -0.35);
    5458
    55   this->dummy1 = new WorldEntity(); // a world entity that is not drawed: use this for the weapon
    56   this->animation = new Animation3D(dummy1);
     59      this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
     60      this->animation1->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR);
     61      this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
     62    }
     63  else if( this->leftRight == W_RIGHT)
     64    {
     65      this->projectileOffset = Vector(1.0, 0.0, 0.5);
    5766
    58   parent->addChild(this->dummy1, PNODE_ALL);
    59 
    60   this->animation->setInfinity(ANIM_INF_CONSTANT);
    61   // ANIM_LINEAR was ANIM_NEG_EXP
    62   if( this->leftRight == 0)
    63     {
    64       this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
    65       this->animation->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR);
    66       this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
     67      this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
     68      this->animation1->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR);
     69      this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
    6770    }
    68   else if( this->leftRight == 1)
    69     {
    70       this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
    71       this->animation->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR);
    72       this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
    73     }
    74   /*
    75   if( this->leftRight == 0)
    76     {
    77       this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.0, ANIM_NEG_EXP);
    78       this->animation->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.1, ANIM_NEG_EXP);
    79       this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.5, ANIM_NEG_EXP);
    80     }
    81   else if( this->leftRight == 1)
    82     {
    83       this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.0, ANIM_NEG_EXP);
    84       this->animation->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.1, ANIM_NEG_EXP);
    85       this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.5, ANIM_NEG_EXP);
    86     }
    87   */
    8871}
    8972
     
    127110void TestGun::fire()
    128111{
    129   if( this->localTime < this->idleTime)
     112  if( !this->hasWeaponIdleTimeElapsed())
    130113    {
    131114      this->weaponIdle();
    132115      return;
    133116    }
     117
    134118  Projectile* pj = new TestBullet(this);
    135 
    136   pj->setAbsCoor(this->getAbsCoor() + *this->projOffset);
     119  pj->setAbsCoor(this->getAbsCoor() + this->projectileOffset);
    137120  pj->setAbsDir(this->getAbsDir());
    138 
    139121  pj->setFlightDirection(this->getAbsDir());
    140122  pj->setSpeed(this->getSpeed());
    141 
    142123  this->worldEntities->add(pj);
    143124  this->localTime = 0;
    144125 
    145   this->animation->replay();
     126  this->animation1->replay();
    146127}
    147128
     
    190171void TestGun::draw ()
    191172{
    192  
    193   /* draw gun body 1 */
     173  /* draw gun body */
    194174  glMatrixMode(GL_MODELVIEW);
    195175  glPushMatrix();
    196176  float matrix[4][4];
    197  
    198   if( this->leftRight == 0)
    199     {
    200       glTranslatef (this->getAbsCoor ().x,
    201                     this->getAbsCoor ().y,
    202                     this->getAbsCoor ().z);
    203      
    204       this->getAbsDir ().matrix (matrix);
    205       glMultMatrixf((float*)matrix);
    206       this->model->draw(1);
    207     }
    208   else if( this->leftRight == 1)
    209     {
    210       glTranslatef (this->getAbsCoor ().x,
    211                     this->getAbsCoor ().y,
    212                     this->getAbsCoor ().z);
    213      
    214       this->getAbsDir ().matrix (matrix);
    215       glMultMatrixf((float*)matrix);
    216       glScalef(1.0, 1.0, -1.0);
    217       this->model->draw(1);
    218     }
    219 
     177  glTranslatef (this->getAbsCoor ().x,
     178                this->getAbsCoor ().y,
     179                this->getAbsCoor ().z); 
     180  this->getAbsDir ().matrix (matrix);
     181  glMultMatrixf((float*)matrix);
     182  if( this->leftRight == W_RIGHT)
     183    glScalef(1.0, 1.0, -1.0);
     184  this->model->draw(1);
    220185  glPopMatrix();
    221186
    222 
    223   /* draw gun coil 1 */
     187  /* draw objectComponent1: gun coil - animated stuff */
    224188  glMatrixMode(GL_MODELVIEW);
    225189  glPushMatrix();
    226  
    227   glTranslatef (this->dummy1->getAbsCoor ().x,
    228                 this->dummy1->getAbsCoor ().y,
    229                 this->dummy1->getAbsCoor ().z);
    230 
    231   this->dummy1->getAbsDir ().matrix (matrix);
     190  glTranslatef (this->objectComponent1->getAbsCoor ().x,
     191                this->objectComponent1->getAbsCoor ().y,
     192                this->objectComponent1->getAbsCoor ().z);
     193  this->objectComponent1->getAbsDir ().matrix (matrix);
    232194  glMultMatrixf((float*)matrix);
    233195  this->model->draw(0);
Note: See TracChangeset for help on using the changeset viewer.