Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6614 in orxonox.OLD for branches/spaceshipcontrol


Ignore:
Timestamp:
Jan 19, 2006, 8:01:08 AM (19 years ago)
Author:
snellen
Message:

aim.cc updated

Location:
branches/spaceshipcontrol/src/world_entities/weapons
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/weapons/aim.cc

    r6606 r6614  
    7373  this->source = NULL;
    7474
     75  this->range = 0;
     76  this->angle = 0;
    7577  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7678  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    101103}
    102104
    103 void Aim::searchTarget(float range, float angle)
     105void Aim::searchTarget()
    104106{
    105107  std::list<WorldEntity*>::iterator entity;
     
    107109  diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
    108110
    109 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 
    110   if( this == PNode::getNullParent() || diffVec.len() > range  || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle && (this->source->getAbsDirX()).dot(diffVec) > 0))
     111//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
     112  if( this == PNode::getNullParent() || diffVec.len() > range  || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    111113  for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
    112114       entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
     
    115117    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
    116118
    117     if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle && (this->source->getAbsDirX()).dot(diffVec) > 0)
     119    if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)
    118120    {
    119121      if (this->getParent() != (*entity))
     
    130132
    131133
    132 
    133134/**
    134135 * @brief sets the size of the Aim.
     
    164165
    165166//  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
    166 //    this->searchTarget(1000,M_PI_2);
     167     this->searchTarget();
    167168//   float z = 0.0f;
    168169//   glReadPixels ((int)this->getAbsCoor2D().x,
  • branches/spaceshipcontrol/src/world_entities/weapons/aim.h

    r6606 r6614  
    3838  inline PNode* getTarget(PNode* target) { return this->getParent(); };
    3939
    40   void searchTarget(float range, float angle);
     40  void searchTarget();
     41
     42  void setRange(float range){this->range = range;};
     43  void setAngle(float angle){this->angle = angle;};
    4144
    4245  void setSize(float size);
     
    5356   tAnimation<Aim>* anim;
    5457
     58   float            range;                //!<
     59   float            angle;                //!<
     60
    5561   PNode*           source;               //!< Where this Shot has come from.
    5662
  • branches/spaceshipcontrol/src/world_entities/weapons/aiming_turret.cc

    r6606 r6614  
    9898  this->target = new Aim(this);
    9999  this->target->setVisibility(false);
     100  this->target->setRange(100);
     101  this->target->setAngle(M_PI);
    100102}
    101103
     
    130132  this->setAbsDirSoft(quat, 5);
    131133
    132   this->target->searchTarget(100,M_PI_2);
     134  this->target->tick(dt);
    133135}
    134136
     
    146148  pj->setAbsDir(this->getAbsDir());
    147149  pj->activate();
    148   this->target->searchTarget(100,M_PI_2);
     150  this->target->searchTarget();
    149151}
    150152
  • branches/spaceshipcontrol/src/world_entities/weapons/targeting_turret.cc

    r6606 r6614  
    9292  this->target = new Aim(this);
    9393  this->target->setVisibility(false);
     94  this->target->setRange(100);
     95  this->target->setAngle(M_PI_4/2);
    9496  this->lockedTime = 0;
    9597  this->neededLockTime = 2;
     
    150152  pj->setAbsDir(this->getAbsDir());
    151153  pj->activate();
    152   this->target->searchTarget(100,M_PI_2);
     154  this->target->searchTarget();
    153155}
    154156
Note: See TracChangeset for help on using the changeset viewer.