Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3683 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Mar 30, 2005, 9:37:52 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: projectile speed issue: fixed some strange behaveour. still got the problem, that the the projectile have variable relative speeds to the player…

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/debug.h

    r3672 r3683  
    6363#define DEBUG_MODULE_COMMAND_NODE       0
    6464#define DEBUG_MODULE_GRAPHICS           0
    65 #define DEBUG_MODULE_LOAD               4
     65#define DEBUG_MODULE_LOAD               1
    6666
    6767#define DEBUG_MODULE_IMPORTER           0
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3675 r3683  
    258258
    259259/**
     260   \brief shift coordinate (abs and rel)
     261   \param shift vector
     262
     263   this function shifts the current coordinates about the vector shift. this is
     264   usefull because from some place else you can:
     265   PNode* someNode = ...;
     266   Vector objectMovement = calculateShift();
     267   someNode->shiftCoor(objectMovement);
     268
     269   elsewhere you would have to:
     270   PNode* someNode = ...;
     271   Vector objectMovement = calculateShift();
     272   Vector currentCoor = someNode->getRelCoor();
     273   Vector newCoor = currentCoor + objectMovement;
     274   someNode->setRelCoor(newCoor);
     275   
     276   yea right... shorter...
     277
     278*/
     279void PNode::shiftCoor (Vector shift)
     280{
     281  if( this->bAbsCoorChanged)
     282    {
     283      *this->absCoordinate = *this->absCoordinate + shift;
     284    }
     285  else
     286    {
     287      *this->relCoordinate = *this->relCoordinate + shift;
     288      this->bRelCoorChanged = true;
     289    }
     290}
     291
     292
     293
     294/**
    260295   \brief get relative direction
    261296   \returns relative direction to its parent
     
    353388*/
    354389void PNode::shiftDir (Quaternion* shift)
     390{}
     391
     392
     393/**
     394   \brief shift coordinate (abs and rel)
     395   \param shift vector
     396
     397   this function shifts the current coordinates about the vector shift. this is
     398   usefull because from some place else you can:
     399   PNode* someNode = ...;
     400   Quaternion objectMovement = calculateShift();
     401   someNode->shiftCoor(objectMovement);
     402
     403   elsewhere you would have to:
     404   PNode* someNode = ...;
     405   Quaternion objectMovement = calculateShift();
     406   Quaternion currentCoor = someNode->getRelCoor();
     407   Quaternion newCoor = currentCoor + objectMovement;
     408   someNode->setRelCoor(newCoor);
     409   
     410   yea right... shorter...
     411
     412   \todo implement this
     413*/
     414void PNode::shiftDir (Quaternion shift)
    355415{}
    356416
  • orxonox/trunk/src/lib/coord/p_node.h

    r3675 r3683  
    6464  void setAbsCoor (Vector absCoord);
    6565  void shiftCoor (Vector* shift);
     66  void shiftCoor (Vector shift);
    6667  //void shiftCoor (Vector shift);
    6768
     
    7374  void setAbsDir (Quaternion absDir);
    7475  void shiftDir (Quaternion* shift);
     76  void shiftDir (Quaternion shift);
    7577
    7678  float getSpeed();
  • orxonox/trunk/src/world_entities/player.cc

    r3675 r3683  
    5252  acceleration = 10.0;
    5353  //weapons:
    54   Weapon* wp = new TestGun(this, new Vector(), new Quaternion);
     54  Weapon* wp = new TestGun(this, new Vector(), new Quaternion());
    5555  this->weapons->add(wp);
    5656  this->activeWeapon = wp; 
  • orxonox/trunk/src/world_entities/projectile.cc

    r3678 r3683  
    2020
    2121#include "world_entity.h"
     22#include "weapon.h"
    2223#include "null_parent.h"
    2324#include "model.h"
     
    3031   \brief standard constructor
    3132*/
    32 Projectile::Projectile () : WorldEntity()
     33Projectile::Projectile (Weapon* weapon) : WorldEntity()
    3334{
    3435  this->model = (Model*)ResourceManager::getInstance()->load("sphere", PRIM, RP_LEVEL);
     36  this->weapon = weapon;
    3537  this->flightDirection = NULL;
    3638  this->currentLifeTime = 0.0f;
     
    6668  Vector v(1, 0, 0);
    6769  *this->flightDirection = flightDirection->apply(v);
     70  this->flightDirection->normalize();
    6871}
    6972
     
    8689void Projectile::setSpeed(float speed)
    8790{
    88   this->speed = speed;
     91  this->speed = speed * 5;
    8992  printf("Projectile::setting speed to: %f\n", this->speed);
    9093}
     
    9699void Projectile::tick (float time)
    97100{
     101  this->speed = this->weapon->getSpeed() * 5; 
     102  this->shiftCoor(*this->flightDirection * this->speed * time);
     103  printf("current speed is: %f\n", this->speed);
     104
    98105  this->currentLifeTime += time;
    99   if( this->ttl < this->currentLifeTime)
    100     {
    101       *this->flightDirection = *this->flightDirection * this->speed * time;
    102       this->shiftCoor(this->flightDirection);
    103       this->flightDirection->debug();
    104       return;
    105     }
    106   this->finalize();
    107   //NullParent* np = NullParent::getInstance();
    108   /* garbage colelction */
    109   // \fix: there is no gc in this class, its all been done by GarbageCollector
     106  if( this->ttl > this->currentLifeTime)
     107    this->finalize();
    110108}
    111109
  • orxonox/trunk/src/world_entities/projectile.h

    r3676 r3683  
    1010
    1111class Vector;
     12class Weapon;
    1213
    1314class Projectile : public WorldEntity
     
    1617
    1718 public:
    18   Projectile ();
     19  Projectile (Weapon* weapon);
    1920  virtual ~Projectile ();
    2021
     
    3536  float ttl;                           //!< time to life, after this time, the projectile will garbage collect itself
    3637  Vector* flightDirection;             //!< direction in which the shoot flights
     38  Weapon* weapon;                      //!< weapon the shoot belongs to
    3739 
    3840};
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3677 r3683  
    4141TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction)
    4242  :  Weapon (parent, coordinate, direction)
    43 {}
     43{
     44}
    4445
    4546
     
    8384{
    8485  //printf("TestGun::fire() - firing weapon now ---------------------------\n");
    85   Projectile* pj = new Projectile();
     86  Projectile* pj = new Projectile(this);
    8687
    8788  Vector* v = new Vector();
     
    9394
    9495  pj->setFlightDirection(q);
    95   //pj->setSpeed(this->getSpeed() * 0.025);
     96  pj->setSpeed(this->getSpeed());
    9697
    9798
Note: See TracChangeset for help on using the changeset viewer.