Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9656 in orxonox.OLD for trunk/src/world_entities/weapons/aim.cc


Ignore:
Timestamp:
Aug 4, 2006, 11:01:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy bache back with no conflicts

File:
1 edited

Legend:

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

    r9406 r9656  
    5050Aim::~Aim ()
    5151{
    52   if (this->material)
    53     delete this->material;
    54 
    5552/*  if (this->text != NULL)
    5653    delete this->text;*/
     
    7067
    7168  this->setBindNode(this);
    72   this->material = new Material;
    7369  this->source = NULL;
    7470
    75   this->range = 10000;
     71  this->range = 1000;
    7672  this->angle = M_PI_4;
    77   this->group = OM_GROUP_01;
     73  this->targetGroup = OM_GROUP_01;
    7874  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7975  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    10399  LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed)
    104100      .describe("the Speed with which the Aim should rotate");
     101
     102  LoadParam(root, "target-group", this, Aim, setTargetGroupS);
    105103}
    106104
     
    108106{
    109107  ObjectManager::EntityList::iterator entity;
    110 
    111   for (entity = State::getObjectManager()->getObjectList(group).begin();
    112        entity != State::getObjectManager()->getObjectList(group).end();
     108  //printf("%d\n", this->targetGroup);
     109  for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin();
     110       entity != State::getObjectManager()->getObjectList(this->targetGroup).end();
    113111       entity ++)
    114112  {
    115113    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
    116114
    117     if ( diffVec.len() < range &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) )  < angle)
     115    if ( diffVec.len() < range )//&&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) )  < angle)
    118116    {
    119117      //if (this->getParent() != (*entity))
    120118      {
     119        printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName());
    121120        this->anim->replay();
    122121        this->setParentSoft(*entity, 5);
     
    128127   //if no target found:
    129128   this->setParent(PNode::getNullParent());
    130 
    131 
    132 
    133 }
    134 
     129}
     130
     131void Aim::setTargetGroupS(const std::string& groupName)
     132{
     133  OM_LIST id = ObjectManager::StringToOMList(groupName);
     134  if (id != OM_NULL)
     135    this->setTargetGroup(id);
     136  else
     137    PRINTF(2)("List %s not found for targetting\n", groupName.c_str());
     138}
    135139
    136140/**
     
    149153void Aim::setTexture(const std::string& textureFile)
    150154{
    151   this->material->setDiffuseMap(textureFile);
     155  this->material.setDiffuseMap(textureFile);
    152156}
    153157
     
    170174//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
    171175   if(this->getParent() == PNode::getNullParent() ||
    172       diffVec.len() > range ||
    173      ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
     176      diffVec.len() > range )// ||
     177     //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    174178    {
    175179     this->setParentSoft(PNode::getNullParent(),5);
     
    213217
    214218  glRotatef(this->getAbsDir2D(), 0,0,1);
    215   this->material->select();
     219  this->material.select();
    216220  glBegin(GL_TRIANGLE_STRIP);
    217221  glTexCoord2f(0, 0);
Note: See TracChangeset for help on using the changeset viewer.