Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2006, 2:19:46 PM (18 years ago)
Author:
patrick
Message:

branches: removed spaceshipcontrol branche

File:
1 edited

Legend:

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

    r6512 r6693  
    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)
     105void Aim::searchTarget()
    104106{
    105107  std::list<WorldEntity*>::iterator entity;
    106 
     108  Vector diffVec(0.0, 0.0, 0.0);
     109  diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
     110
     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))
    107113  for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
    108114       entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
    109115       entity ++)
    110116  {
    111     if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range)
     117    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
     118
     119    if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)
    112120    {
    113121      if (this->getParent() != (*entity))
     
    119127    }
    120128  }
    121 }
    122 
     129//if no target found:
     130  this->setParent(PNode::getNullParent());
     131}
    123132
    124133
     
    155164
    156165
    157   if (this->source->getAbsCoor().x > this->getAbsCoor().x )
    158     this->searchTarget(1000);
     166//  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
     167     this->searchTarget();
    159168//   float z = 0.0f;
    160169//   glReadPixels ((int)this->getAbsCoor2D().x,
Note: See TracChangeset for help on using the changeset viewer.