Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8993 in orxonox.OLD


Ignore:
Timestamp:
Jul 2, 2006, 5:30:14 AM (18 years ago)
Author:
bensch
Message:

radar should provide the right data now

Location:
trunk/src/world_entities/elements
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/elements/glgui_radar.cc

    r8992 r8993  
    1717
    1818#include "glgui_radar.h"
     19#include "world_entity.h"
    1920
    2021namespace OrxGui
     
    2425   */
    2526  GLGuiRadar::GLGuiRadar ()
    26   {
    27   }
     27  {}
    2828
    2929
     
    3232   */
    3333  GLGuiRadar::~GLGuiRadar ()
     34  {}
     35
     36  void GLGuiRadar::init()
    3437  {
     38    this->_updateInterval = 1.0f;
     39    this->_timePassed = 0.0f;
     40    this->_range = 100.0f;
     41    this->_centerNode = NULL;
    3542  }
    3643
     44  void GLGuiRadar::setCenterNode(const PNode* center)
     45  {
     46    this->_centerNode = center;
     47  }
     48
     49  void GLGuiRadar::addEntityList(const std::list<WorldEntity*>* entityList, const Color& color)
     50  {
     51    GLGuiRadar::DotList dotList;
     52    dotList.dotColor = color;
     53    dotList.entityList = entityList;
     54
     55    this->_dotLists.push_back(dotList);
     56  }
     57
     58  void GLGuiRadar::removeEntityList(const std::list<WorldEntity*>* entityList)
     59  {
     60    std::vector<DotList>::iterator it;
     61    for (it = this->_dotLists.begin(); it != this->_dotLists.end(); ++it)
     62      if ((*it).entityList == entityList)
     63      {
     64        this->_dotLists.erase(it);
     65        break;
     66      }
     67  }
    3768
    3869
     
    4576  void GLGuiRadar::tick(float dt)
    4677  {
     78    _timePassed+=dt;
    4779
     80    if (_timePassed > _updateInterval)
     81    {
     82      _timePassed-=_updateInterval;
     83      this->updateRadar();
     84    }
     85
     86  }
     87
     88  void GLGuiRadar::updateRadar()
     89  {
     90    if (_centerNode == NULL)
     91    {
     92      for (unsigned int i = 0; i < this->_dotLists.size(); ++i)
     93        this->_dotLists[i].positions.clear();
     94      return;
     95    }
     96
     97    std::list<WorldEntity*>::const_iterator it;
     98    for (unsigned int i = 0; i < this->_dotLists.size(); ++i)
     99    {
     100      this->_dotLists[i].positions.clear();
     101
     102      for (it = _dotLists[i].entityList->begin(); it != _dotLists[i].entityList->end(); ++it)
     103      {
     104        if (_centerNode->distance(*it) < this->_range)
     105        {
     106          this->_dotLists[i].positions.push_back(Vector2D(50, 50) + Vector2D(_centerNode->getAbsCoor().x - (*it)->getAbsCoor().x, _centerNode->getAbsCoor().y - (*it)->getAbsCoor().y)/_range * 50);
     107        }
     108
     109      }
     110
     111    }
    48112  }
    49113
     
    51115  void GLGuiRadar::draw() const
    52116  {
    53 
    54 
     117    for (unsigned int i = 0; i < this->_dotLists.size(); ++i)
     118    {
     119      for (unsigned int j = 0; j < this->_dotLists[i].positions.size(); ++j)
     120      {
     121      }
     122    }
    55123  }
    56124
     
    63131
    64132  void GLGuiRadar::showing()
    65   {
    66   }
     133  {}
    67134
    68135  void GLGuiRadar::hiding()
    69   {
    70   }
    71 }
     136{}}
  • trunk/src/world_entities/elements/glgui_radar.h

    r8992 r8993  
    99#include "glgui_widget.h"
    1010
     11class PNode;
    1112class WorldEntity;
    1213
     
    2728    virtual ~GLGuiRadar();
    2829
     30    void addEntityList(const std::list<WorldEntity*>* entityList, const Color& color);
     31    void removeEntityList(const std::list<WorldEntity*>* entityList);
     32
    2933    void setRange(float range);
    3034
     35    void setCenterNode(const PNode* center);
    3136    void setUpdateInterval(float updateInterval) { this->_updateInterval = updateInterval; };
    3237    void setAttenuation(Attenuation attenuation);
    3338
     39
    3440    float range() const { return this->_range; }
    3541
     42    void updateRadar();
    3643
    3744    void tick(float dt);
     
    4451
    4552  private:
     53    void init();
     54
     55  private:
    4656    typedef struct
    4757    {
    4858      Color                           dotColor;
    49       const std::list<WorldEntity*>&  entityList;
    50       std::vector<Vector2D>           position;
     59      const std::list<WorldEntity*>*  entityList;
     60      std::vector<Vector2D>           positions;
    5161    }
    5262    DotList;
    5363
    54     std::vector<DotList>        _dotLists;
     64    const PNode*                      _centerNode;
     65    std::vector<DotList>              _dotLists;
    5566
    56     Attenuation                 _attenuation;
    57     float                       _range;
     67    Attenuation                       _attenuation;
     68    float                             _range;
    5869
    5970
    60     float                       _updateInterval;
    61     float                       _timePassed;
     71    float                             _updateInterval;
     72    float                             _timePassed;
    6273  };
    6374}
Note: See TracChangeset for help on using the changeset viewer.