Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6849 for code/branches


Ignore:
Timestamp:
May 3, 2010, 5:03:05 PM (15 years ago)
Author:
scurcio
Message:

update hudnavigation /addObject, removeObject

Location:
code/branches/hudelements/src/modules/overlays/hud
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.cc

    r6796 r6849  
    3030
    3131#include <string>
    32 #include <vector>
    33 #include <map>
    3432#include <OgreCamera.h>
    3533#include <OgreOverlayManager.h>
    3634#include <OgreTextAreaOverlayElement.h>
    3735#include <OgrePanelOverlayElement.h>
    38 
    3936#include "util/Math.h"
    4037#include "util/Convert.h"
     
    4744#include "controllers/HumanController.h"
    4845#include "worldentities/pawns/Pawn.h"
     46#include "worldentities/WorldEntity.h"
    4947
    5048namespace orxonox
     
    139137    void HUDNavigation::tick(float dt)
    140138    {
    141 
    142        
    143139        SUPER(HUDNavigation, tick, dt);
    144140
     
    291287    }
    292288   
    293 //     map <WorldEntity*, pair <Ogre::PanelOverlayElement*, Ogre::TextAreaOverlayElement*> > ActiveObjectList;
     289    void HUDNavigation::addObject(RadarViewable* object)
     290    {
     291        if (object == dynamic_cast<RadarViewable*>(this->getOwner()))
     292            return;
     293       
     294        assert(object);
     295         
     296        // Make sure the object hasn't been added yet
     297        assert( this->activeObjectList_.find(object) == this->activeObjectList_.end() );
     298
     299        // Create everything needed to display the object on the radar and add it to the map
     300       
     301         // create nav marker
     302        Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     303            .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
     304           
     305        panel->setMaterialName("Orxonox/NavArrows");
     306         
     307        Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
     308             .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
     309       
     310        activeObjectList_[object] = std::make_pair (panel, text) ;     
     311        activeObjectList_[object].first->show();
     312        activeObjectList_[object].second->show();
     313        }
    294314   
    295 //     void updateActiveObjectMap(){
    296 //       --> iteration durch die betsehende map über alle keys (Worldentity*)
    297 //           --> check: 'existiert noch' 'sizeChanged' 'angleChanged' 'positionChanged'
    298 //               --> update des aktuellen Objects (Panel & Text)
    299 //               --> lücke schliessen in der map (aufrücken nach links)
    300 //       --> neue objekte suchen
    301 //               -- map.add neue objekte hinzufügen (pair <panel, text> einfügen.
    302 //     }       
    303    
     315        void HUDNavigation::removeObject(RadarViewable* viewable){
     316          assert(activeObjectList_.find(viewable)!=activeObjectList_.end());
     317          activeObjectList_.erase(viewable);
     318        }
     319//     
     320//         void HUDNavigation::objectChanged(RadarViewable* viewable){}
     321//         float HUDNavigation::getRadarSensitivity(){}
     322//         void HUDNavigation::radarTick(float dt){}
     323//     
    304324
    305325
  • code/branches/hudelements/src/modules/overlays/hud/HUDNavigation.h

    r6796 r6849  
    3030#define _HUDNavigation_H__
    3131
     32#include <utility>
     33#include <map>
    3234#include "overlays/OverlaysPrereqs.h"
    3335
     36#include "interfaces/RadarListener.h"
    3437#include "util/OgreForwardRefs.h"
    3538#include "tools/interfaces/Tickable.h"
     
    4144namespace orxonox
    4245{
    43 class WorldEntity;
    44     class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable
     46    class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener
    4547    {
    4648    public:
     
    5052        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    5153        virtual void tick(float dt);
    52        
    53         virtual map <WorldEntity*, pair <Ogre::PanelOverlayElement*, Ogre::TextAreaOverlayElement*> > ActiveObjectList;
    54        
     54        virtual void addObject(RadarViewable* object);
     55         
     56        virtual void removeObject(RadarViewable* viewable);
     57         virtual void objectChanged(RadarViewable* viewable){}
     58         inline float getRadarSensitivity() const{}
     59         inline void radarTick(float dt) {}
    5560
    5661    private:
     
    6368
    6469        // XMLPort accessors
    65         void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); }
     70        void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); } 
    6671        float getNavMarkerSize() const    { return this->navMarkerSize_; }
    6772
     
    9499        bool wasOutOfView_;                         //!< Performance booster variable: setMaterial is not cheap
    95100       
     101        std::map<RadarViewable*, std::pair<Ogre::PanelOverlayElement*, Ogre::TextAreaOverlayElement*> > activeObjectList_;
    96102       
    97103    };
     104   
    98105}
    99106
  • code/branches/hudelements/src/modules/overlays/hud/HUDRadar.cc

    r6727 r6849  
    4545namespace orxonox
    4646{
    47     CreateFactory(HUDRadar);
     47    CreateFactory(HUDRadar); 
    4848
    4949    HUDRadar::HUDRadar(BaseObject* creator)
Note: See TracChangeset for help on using the changeset viewer.