Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6637 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Jan 21, 2006, 1:27:29 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the SpaceShipControl branche back to the trunk

merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/spaceshipcontrol . -r6482:HEAD

minor conflicts, and added file hover.cc/h to the Makefile.

Location:
trunk/src/world_entities/weapons
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/aim.cc

    r6512 r6637  
    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,
  • trunk/src/world_entities/weapons/aim.h

    r6512 r6637  
    3838  inline PNode* getTarget(PNode* target) { return this->getParent(); };
    3939
    40   void searchTarget(float range);
     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
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r6512 r6637  
    9898  this->target = new Aim(this);
    9999  this->target->setVisibility(false);
     100  this->target->setRange(100);
     101  this->target->setAngle(M_PI);
    100102}
    101103
     
    146148  pj->setAbsDir(this->getAbsDir());
    147149  pj->activate();
    148   this->target->searchTarget(100);
     150  this->target->searchTarget();
    149151}
    150152
  • trunk/src/world_entities/weapons/targeting_turret.cc

    r6512 r6637  
    9292  this->target = new Aim(this);
    9393  this->target->setVisibility(false);
    94 
     94  this->target->setRange(100);
     95  this->target->setAngle(M_PI_4/2);
     96  this->lockedTime = 0;
     97  this->neededLockTime = 2;
     98  this->lockedTarget->setParent(PNode::getNullParent());
    9599  this->loadModel("models/guns/turret2.obj");
    96100
     
    119123void TargetingTurret::tick(float dt)
    120124{
     125  if( lockedTime >= neededLockTime )
     126   {
     127    lockedTarget = this->target->getParent();
     128    lockedTime = 0;
     129   }
    121130
    122131  this->target->tick(dt);
     132
     133  if(this->target->getParent() == PNode::getNullParent())
     134   lockedTime = 0;
     135  else
     136   lockedTime += dt;
     137
    123138}
    124139
     
    137152  pj->setAbsDir(this->getAbsDir());
    138153  pj->activate();
    139   this->target->searchTarget(100);
     154  this->target->searchTarget();
    140155}
    141156
  • trunk/src/world_entities/weapons/targeting_turret.h

    r6512 r6637  
    3232
    3333  private:
    34     Aim*          target;
    35   };
     34    Aim*           target;
     35    PNode*         lockedTarget;
     36    float          lockedTime;
     37    float          neededLockTime;
     38  };
    3639
    3740#endif /* _TARGETING_TURRET_H */
Note: See TracChangeset for help on using the changeset viewer.