Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3886 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Apr 18, 2005, 11:59:13 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: cleaned up the weapon/test_gun class. now it makes more sense.

Location:
orxonox/trunk/src/world_entities
Files:
3 edited

Legend:

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

    r3881 r3886  
    5353
    5454
    55   this->dummy1 = new WorldEntity(); // a world entity that is not drawed: use this for the weapon
    56   this->animation = new Animation3D(dummy1);
    57 
    58   parent->addChild(this->dummy1, PNODE_ALL);
    59 
    60   this->animation->setInfinity(ANIM_INF_CONSTANT);
     55  //this->dummy1 = new WorldEntity(); // a world entity that is not drawed: use this for the weapon
     56  this->objectComponent1 = new PNode();
     57  this->animation1 = new Animation3D(this->objectComponent1);
     58
     59  parent->addChild(this->objectComponent1, PNODE_ALL);
     60
     61  this->animation1->setInfinity(ANIM_INF_CONSTANT);
    6162  // ANIM_LINEAR was ANIM_NEG_EXP
    62   if( this->leftRight == 0)
     63  if( this->leftRight == W_LEFT)
    6364    {
    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);
     65      this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
     66      this->animation1->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR);
     67      this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR);
    6768    }
    68   else if( this->leftRight == 1)
     69  else if( this->leftRight == W_RIGHT)
    6970    {
    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);
     71      this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
     72      this->animation1->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR);
     73      this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);
    7374    }
    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   */
    8875}
    8976
     
    143130  this->localTime = 0;
    144131 
    145   this->animation->replay();
     132  this->animation1->replay();
    146133}
    147134
     
    190177void TestGun::draw ()
    191178{
    192  
    193   /* draw gun body 1 */
     179  /* draw gun body */
    194180  glMatrixMode(GL_MODELVIEW);
    195181  glPushMatrix();
    196182  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 
     183  glTranslatef (this->getAbsCoor ().x,
     184                this->getAbsCoor ().y,
     185                this->getAbsCoor ().z); 
     186  this->getAbsDir ().matrix (matrix);
     187  glMultMatrixf((float*)matrix);
     188  if( this->leftRight == W_RIGHT)
     189    glScalef(1.0, 1.0, -1.0);
     190  this->model->draw(1);
    220191  glPopMatrix();
    221192
    222 
    223   /* draw gun coil 1 */
     193  /* draw objectComponent1: gun coil - animated stuff */
    224194  glMatrixMode(GL_MODELVIEW);
    225195  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);
     196  glTranslatef (this->objectComponent1->getAbsCoor ().x,
     197                this->objectComponent1->getAbsCoor ().y,
     198                this->objectComponent1->getAbsCoor ().z);
     199  this->objectComponent1->getAbsDir ().matrix (matrix);
    232200  glMultMatrixf((float*)matrix);
    233201  this->model->draw(0);
  • orxonox/trunk/src/world_entities/test_gun.h

    r3881 r3886  
    5454  Animation3D* animation;
    5555  Vector* projOffset;
    56   WorldEntity* dummy1;
    5756  int leftRight;   // this will become an enum
    5857
  • orxonox/trunk/src/world_entities/weapon.h

    r3881 r3886  
    3838class Projectile;
    3939class Weapon;
     40class Animation3D;
    4041
    4142typedef enum {
     
    6667#define W_CONFIG2 2
    6768#define W_CONFIG3 3
     69
     70//! a weapon can be left or right sided
     71#define W_LEFT 0
     72#define W_RIGHT 1
    6873
    6974//! this is a weapon Configuration: it has up to 8 slots
     
    155160 protected:
    156161  tList<WorldEntity>* worldEntities;
    157   float localTime;
    158   float idleTime;
    159   float slowDownFactor;
     162  float localTime;                 //<! this is the local time. important for shooting attributes like frequency
     163  float idleTime;                  //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
     164  float slowDownFactor;            //<! if the shooting frequency is a linear function of time...
     165
     166  PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
     167  PNode* objectComponent2;
     168  PNode* objectComponent3;
     169
     170  Animation3D* animation1;
     171  Animation3D* animation2;
     172  Animation3D* animation3;
     173
     174  Vector* projectileOffset;
     175  int leftRight;   // this will become an enum
    160176
    161177 private:
    162   bool enabled;
    163   Projectile* projectile;
     178  bool enabled;                    //<! states if the weapon is enabled or not
     179  Projectile* projectile;          //<! the projectile used for this weapon
    164180  //WeaponSound sound;
    165181};
Note: See TracChangeset for help on using the changeset viewer.