Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 18, 2006, 7:32:59 PM (18 years ago)
Author:
snellen
Message:

aim.cc, targeting_turret.cc and aiming turret.cc updated

File:
1 edited

Legend:

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

    r6305 r6606  
    101101}
    102102
    103 void Aim::searchTarget(float range)
     103void Aim::searchTarget(float range, float angle)
    104104{
    105105  std::list<WorldEntity*>::iterator entity;
    106 
     106  Vector diffVec(0.0, 0.0, 0.0);
     107  diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
     108
     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))
    107111  for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
    108112       entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
    109113       entity ++)
    110114  {
    111     if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range)
     115    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
     116
     117    if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle && (this->source->getAbsDirX()).dot(diffVec) > 0)
    112118    {
    113119      if (this->getParent() != (*entity))
     
    119125    }
    120126  }
     127//if no target found:
     128  this->setParent(PNode::getNullParent());
    121129}
    122130
     
    155163
    156164
    157   if (this->source->getAbsCoor().x > this->getAbsCoor().x )
    158     this->searchTarget(1000);
     165//  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
     166//    this->searchTarget(1000,M_PI_2);
    159167//   float z = 0.0f;
    160168//   glReadPixels ((int)this->getAbsCoor2D().x,
Note: See TracChangeset for help on using the changeset viewer.