Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3632 in orxonox.OLD for orxonox/trunk/src/world_entities


Ignore:
Timestamp:
Mar 22, 2005, 12:36:39 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: bullets now tick() but they shoot all over the place… some problems with the gundirection calculation :)

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

Legend:

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

    r3631 r3632  
    3434  //this->model = new OBJModel("");
    3535  this->projectileModel = new Primitive(P_SPHERE);
     36  this->flightDirection = NULL;
     37  this->speed = 1.0f;
    3638}
    3739
     
    5153
    5254/**
     55   \brief this sets the flight direction of the projectile
     56   \param directin in which to flight
     57
     58   this function will calculate a vector out of this to be used in the
     59   tick function
     60*/
     61void Projectile::setFlightDirection(Quaternion* flightDirection)
     62{
     63  if( this->flightDirection == NULL)
     64    this->flightDirection = new Vector();
     65  Vector v(1, 0, 0);
     66  *this->flightDirection = flightDirection->apply(v);
     67}
     68
     69
     70/**
    5371   \brief signal tick, time dependent things will be handled here
    5472   \param time since last tick
    5573*/
    5674void Projectile::tick (float time)
    57 {}
     75{
     76  *this->flightDirection = *this->flightDirection * speed;
     77  this->shiftCoor(this->flightDirection);
     78}
    5879
    5980/**
  • orxonox/trunk/src/world_entities/projectile.h

    r3618 r3632  
    1010
    1111class Primitive;
     12class Vector;
    1213
    1314class Projectile : public WorldEntity
     
    1920  virtual ~Projectile ();
    2021
     22  void setFlightDirection(Quaternion* flightDirection);
     23
    2124  virtual void hit (WorldEntity* weapon, Vector* loc);
    2225  virtual void destroy ();
     
    2730 private:
    2831  //physical attriutes like: force, speed, acceleration etc.
    29   Primitive* projectileModel;
    30 
     32  Primitive* projectileModel;          //!< this serves temporary as a plasma bullet
     33  float speed;                         //!< this is the speed of the projectile
     34  Vector* flightDirection;             //!< direction in which the shoot flights
    3135};
    3236
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3631 r3632  
    8383{
    8484  printf("TestGun::fire() - firing weapon now ---------------------------\n");
    85   WorldEntity* pj = new Projectile();
    86   pj->setAbsCoor( &this->getAbsCoor());
    87   pj->setAbsDir( &this->getAbsDir());
     85  Projectile* pj = new Projectile();
     86  Vector* v = new Vector();
     87  *v = this->getAbsCoor();
     88  pj->setAbsCoor(v);
     89  Quaternion* q = new Quaternion();
     90  *q = this->getAbsDir();
     91  pj->setAbsDir(q);
     92
     93  pj->setFlightDirection(q);
     94
    8895  this->worldEntities->add(pj);
    8996}
Note: See TracChangeset for help on using the changeset viewer.