Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3755 in orxonox.OLD for orxonox/trunk/src/world_entities/test_gun.cc


Ignore:
Timestamp:
Apr 8, 2005, 12:46:33 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: now got two weapons firing syncronized

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3752 r3755  
    4040   creates a new weapon
    4141*/
    42 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction)
     42TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction, int leftRight)
    4343  :  Weapon (parent, coordinate, direction)
    4444{
    4545  this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    4646  this->idleTime = 0.2f;
     47  this->leftRight = leftRight;
    4748
    4849  this->animator = SimpleAnimation::getInstance();
    49   this->dummy = new WorldEntity(); /* a world entity that is not drawed: use this for the weapon */
    50   parent->addChild(this->dummy, PNODE_ALL);
    51   //this->dummy->setRelCoor(new Vector(-2.6, 0.1, 3.0));
     50  this->dummy1 = new WorldEntity(); /* a world entity that is not drawed: use this for the weapon */
     51  parent->addChild(this->dummy1, PNODE_ALL);
     52
    5253 
    5354  this->animator->animatorBegin();
    54   this->animator->selectObject(this->dummy);
     55  this->animator->selectObject(this->dummy1);
    5556  this->animator->setAnimationMode(SINGLE);
    56   this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.0, NEG_EXP);
    57   this->animator->addKeyFrame(new Vector(-3.0, 0.1, 3.0), new Quaternion(), 0.1, NEG_EXP);
    58   this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.5, NEG_EXP);
     57  if( this->leftRight == 0)
     58    {
     59      this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.0, NEG_EXP);
     60      this->animator->addKeyFrame(new Vector(-3.0, 0.1, 3.0), new Quaternion(), 0.1, NEG_EXP);
     61      this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.5, NEG_EXP);
     62    }
     63  else if( this->leftRight == 1)
     64    {
     65      this->animator->addKeyFrame(new Vector(-2.6, 0.1, -2.5), new Quaternion(), 0.0, NEG_EXP);
     66      this->animator->addKeyFrame(new Vector(-3.0, 0.1, -2.5), new Quaternion(), 0.1, NEG_EXP);
     67      this->animator->addKeyFrame(new Vector(-2.6, 0.1, -2.5), new Quaternion(), 0.5, NEG_EXP);
     68    }
    5969  this->animator->animatorEnd();
    6070 
     
    117127 
    118128  this->animator->animatorBegin();
    119   this->animator->selectObject(this->dummy);
     129  this->animator->selectObject(this->dummy1);
    120130  this->animator->start();
    121131  this->animator->animatorEnd();
     
    167177{
    168178 
     179  /* draw gun body 1 */
    169180  glMatrixMode(GL_MODELVIEW);
    170181  glPushMatrix();
    171182  float matrix[4][4];
    172183 
    173  
    174   glTranslatef (this->getAbsCoor ().x,
    175                 this->getAbsCoor ().y,
    176                 this->getAbsCoor ().z);
    177  
    178   this->getAbsDir ().matrix (matrix);
    179   glMultMatrixf((float*)matrix);
    180   this->model->draw(1);
     184  if( this->leftRight == 0)
     185    {
     186      glTranslatef (this->getAbsCoor ().x,
     187                    this->getAbsCoor ().y,
     188                    this->getAbsCoor ().z);
     189     
     190      this->getAbsDir ().matrix (matrix);
     191      glMultMatrixf((float*)matrix);
     192      this->model->draw(1);
     193    }
     194  else if( this->leftRight == 1)
     195    {
     196      glTranslatef (this->getAbsCoor ().x,
     197                    this->getAbsCoor ().y,
     198                    this->getAbsCoor ().z);
     199     
     200      this->getAbsDir ().matrix (matrix);
     201      glMultMatrixf((float*)matrix);
     202      glScalef(1.0, 1.0, -1.0);
     203      this->model->draw(1);
     204    }
     205
    181206  glPopMatrix();
    182  
    183 
     207
     208
     209  /* draw gun coil 1 */
    184210  glMatrixMode(GL_MODELVIEW);
    185211  glPushMatrix();
    186212 
    187   glTranslatef (this->dummy->getAbsCoor ().x,
    188                 this->dummy->getAbsCoor ().y,
    189                 this->dummy->getAbsCoor ().z);
    190 
    191   this->dummy->getAbsDir ().matrix (matrix);
     213  glTranslatef (this->dummy1->getAbsCoor ().x,
     214                this->dummy1->getAbsCoor ().y,
     215                this->dummy1->getAbsCoor ().z);
     216
     217  this->dummy1->getAbsDir ().matrix (matrix);
    192218  glMultMatrixf((float*)matrix);
    193219  this->model->draw(0);
    194220  glPopMatrix();
    195 
    196 }
    197 
     221}
     222
Note: See TracChangeset for help on using the changeset viewer.