Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 20, 2008, 1:47:41 AM (16 years ago)
Author:
landauf
Message:

added MovableEntity with network optimization for constant velocity and rotation

added new Timer feature to destroy a Timer right after it called the function

Location:
code/branches/objecthierarchy/src/orxonox
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/CMakeLists.txt

    r1959 r1968  
    4545  objects/worldentities/WorldEntity.cc
    4646  objects/worldentities/PositionableEntity.cc
     47  objects/worldentities/MovableEntity.cc
    4748#  objects/Backlight.cc
    4849  objects/Camera.cc
  • code/branches/objecthierarchy/src/orxonox/objects/Backlight.h

    r1907 r1968  
    3333
    3434#include "WorldEntity.h"
    35 #include "tools/Timer.h"
    3635#include "tools/BillboardSet.h"
    3736
  • code/branches/objecthierarchy/src/orxonox/objects/infos/LevelInfo.cc

    r1949 r1968  
    8989    void LevelInfo::setGametype(const std::string& gametype)
    9090    {
    91         std::cout << "0: " << gametype << std::endl;
    9291        Identifier* identifier = ClassByString(gametype);
    9392        if (identifier)
    9493        {
    95             std::cout << "1: " << identifier->getName() << std::endl;
    9694            this->gametype_ = gametype;
    9795            this->gametypeIdentifier_ = identifier;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.h

    r1950 r1968  
    4343            void registerVariables();
    4444
     45            using WorldEntity::setPosition;
     46            using WorldEntity::translate;
     47            using WorldEntity::setOrientation;
     48            using WorldEntity::rotate;
     49            using WorldEntity::lookAt;
     50            using WorldEntity::setDirection;
     51
    4552            inline void setPosition(const Vector3& position)
    4653                { this->node_->setPosition(position); }
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc

    r1953 r1968  
    9090        COUT(0) << "Chat: " << text << std::endl;
    9191
    92         Timer<ChatOverlay>* timer = new Timer<ChatOverlay>;
    93         ExecutorMember<ChatOverlay>* executor = createExecutor(createFunctor(&ChatOverlay::dropMessage));
    94         executor->setDefaultValues(timer);
    95         timer->setTimer(this->displayTime_, false, this, executor);
     92        new Timer<ChatOverlay>(this->displayTime_, false, this, createExecutor(createFunctor(&ChatOverlay::dropMessage)), true);
    9693
    9794        this->updateOverlayText();
    9895    }
    9996
    100     void ChatOverlay::dropMessage(Timer<ChatOverlay>* timer)
     97    void ChatOverlay::dropMessage()
    10198    {
    10299        this->messages_.pop_front();
    103100        this->updateOverlayText();
    104 
    105         delete timer;
    106101    }
    107102
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.h

    r1953 r1968  
    5454        private:
    5555            void updateOverlayText();
    56             void dropMessage(Timer<ChatOverlay>* timer);
     56            void dropMessage();
    5757
    5858            float displayTime_;
  • code/branches/objecthierarchy/src/orxonox/tools/Timer.cc

    r1755 r1968  
    9292        this->bLoop_ = false;
    9393        this->bActive_ = false;
     94        this->bKillAfterCall_ = false;
    9495
    9596        this->time_ = 0;
     
    112113    {
    113114        (*this->executor_)();
     115
     116        if (this->bKillAfterCall_)
     117            delete this;
    114118    }
    115119
     
    136140            {
    137141                // It's time to call the function
    138                 if (this->bLoop_)
     142                if (this->bLoop_ && !this->bKillAfterCall_)
    139143                {
    140144                    this->time_ += this->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
  • code/branches/objecthierarchy/src/orxonox/tools/Timer.h

    r1755 r1968  
    116116            TimerBase();
    117117
    118             Executor* executor_; //!< The executor of the function that should be called when the time expires
    119 
    120             long long interval_; //!< The time-interval in micro seconds
    121             bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
    122             bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
    123 
    124             long long time_;     //!< Internal variable, counting the time till the next function-call
     118            Executor* executor_;  //!< The executor of the function that should be called when the time expires
     119
     120            long long interval_;  //!< The time-interval in micro seconds
     121            bool bLoop_;          //!< If true, the function gets called every 'interval' seconds
     122            bool bActive_;        //!< If true, the Timer ticks and calls the function if the time's up
     123            bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function
     124
     125            long long time_;      //!< Internal variable, counting the time till the next function-call
    125126    };
    126127
     
    139140                @param exeuctor A executor of the function to call
    140141            */
    141             Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor)
    142             {
    143                 this->setTimer(interval, bLoop, object, exeuctor);
     142            Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false)
     143            {
     144                this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall);
    144145            }
    145146
     
    151152                @param exeuctor A executor of the function to call
    152153            */
    153             void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor)
     154            void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false)
    154155            {
    155156                this->deleteExecutor();
     
    162163
    163164                this->time_ = this->interval_;
     165                this->bKillAfterCall_ = bKillAfterCall;
    164166            }
    165167    };
     
    177179                @param exeuctor A executor of the function to call
    178180            */
    179             StaticTimer(float interval, bool bLoop, ExecutorStatic* executor)
    180             {
    181                 this->setTimer(interval, bLoop, executor);
     181            StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
     182            {
     183                this->setTimer(interval, bLoop, executor, bKillAfterCall);
    182184            }
    183185
     
    189191                @param executor A executor of the function to call
    190192            */
    191             void setTimer(float interval, bool bLoop, ExecutorStatic* executor)
     193            void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    192194            {
    193195                this->deleteExecutor();
     
    199201
    200202                this->time_ = this->interval_;
     203                this->bKillAfterCall_ = bKillAfterCall;
    201204            }
    202205    };
Note: See TracChangeset for help on using the changeset viewer.