Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2006, 5:25:15 PM (18 years ago)
Author:
snellen
Message:

aim.cc updated

File:
1 edited

Legend:

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

    r6637 r6723  
    7373  this->source = NULL;
    7474
    75   this->range = 0;
    76   this->angle = 0;
     75  this->range = 10000;
     76  this->angle = M_PI_4;
     77  this->group = OM_GROUP_01;
    7778  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7879  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    106107{
    107108  std::list<WorldEntity*>::iterator entity;
    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))
    113   for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
    114        entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
     109
     110  for (entity = State::getObjectManager()->getObjectList(group).begin();
     111       entity != State::getObjectManager()->getObjectList(group).end();
    115112       entity ++)
    116113  {
     
    119116    if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)
    120117    {
    121       if (this->getParent() != (*entity))
     118      //if (this->getParent() != (*entity))
    122119      {
    123120        this->anim->replay();
     
    127124    }
    128125  }
    129 //if no target found:
    130   this->setParent(PNode::getNullParent());
     126
     127   //if no target found:
     128   this->setParent(PNode::getNullParent());
     129
     130
     131
    131132}
    132133
     
    165166
    166167//  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
     168  diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
     169//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
     170   if(this->getParent() == PNode::getNullParent() ||
     171      diffVec.len() > range  ||
     172      ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
     173    {
    167174     this->searchTarget();
     175    }
     176
    168177//   float z = 0.0f;
    169178//   glReadPixels ((int)this->getAbsCoor2D().x,
     
    196205{
    197206
     207 if( this->getParent() != PNode::getNullParent() )
     208  {
    198209  glPushMatrix();
    199210  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
     
    212223  glEnd();
    213224  glPopMatrix();
    214 
    215 }
     225  }
     226
     227}
Note: See TracChangeset for help on using the changeset viewer.