Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 24, 2008, 2:48:43 AM (16 years ago)
Author:
landauf
Message:

many changes, can't remember everything, but these are the most important:

  • attaching entities to other entities works
  • displaying models, lights and shadows works
  • controlling a spectator works
  • removed an update hack in PositionableEntity because I've found a much better solution

and with "works" I mean: it works on client, server and standalone

Location:
code/branches/objecthierarchy/src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/GamestateClient.h

    r1990 r2006  
    4848#include "GamestateHandler.h"
    4949
    50 const unsigned int GAMESTATEID_INITIAL=-1;
     50const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
    5151
    5252namespace network
  • code/branches/objecthierarchy/src/network/GamestateManager.cc

    r1990 r2006  
    165165    ClientInformation *temp = ClientInformation::findClient(clientID);
    166166    assert(temp);
    167     int curid = temp->getGamestateID();
     167    unsigned int curid = temp->getGamestateID();
    168168
    169169    if(gamestateID == 0){
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc

    r1962 r2006  
    5757        , radar_(0)
    5858        , startLevel_(0)
    59         , hud_(0)
    6059    {
    6160        RegisterObject(GSLevel);
     
    8382        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
    8483
     84        this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
     85
    8586        // temporary hack
    8687        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
     
    8889        // Start the Radar
    8990        this->radar_ = new Radar();
    90 
    91         // Load the HUD
    92         COUT(3) << "Orxonox: Loading HUD" << std::endl;
    93         hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
    94         Loader::load(hud_);
    9591
    9692        // reset game speed to normal
     
    113109    void GSLevel::leave()
    114110    {
    115         Loader::unload(hud_);
    116         delete this->hud_;
    117 
    118111        // this call will delete every BaseObject!
    119112        // But currently this will call methods of objects that exist no more
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.h

    r1887 r2006  
    6969        Radar*                radar_;            //!< represents the Radar (not the HUD part)
    7070        Level*                startLevel_;       //!< current hard coded default level
    71         Level*                hud_;              //!< 'level' object fo the HUD
    7271
    7372        // config values
    7473        std::string           keyDetectorCallbackCode_;
    75        
     74
    7675    private:
    7776        void setConfigValues();
  • code/branches/objecthierarchy/src/orxonox/objects/Camera.cc

    r1993 r2006  
    7070  void Camera::tick(float dt)
    7171  {
    72       SUPER(Camera, tick, dt);
    73 
    7472      // this stuff here may need some adjustments
    7573      float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
  • code/branches/objecthierarchy/src/orxonox/objects/Camera.h

    r1993 r2006  
    4040namespace orxonox
    4141{
    42     class _OrxonoxExport Camera : public PositionableEntity//, public Tickable
     42    class _OrxonoxExport Camera : public PositionableEntity, public Tickable
    4343    {
    4444      friend class CameraHandler;
  • code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc

    r1755 r2006  
    4646    this->cam_ = GraphicsEngine::getInstance().getLevelSceneManager()->createCamera("Cam");
    4747    GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
     48    this->cam_->setNearClipDistance(1);
    4849    //GraphicsEngine::getInstance().getRenderWindow()->addViewport(this->cam_, 2, 0.4, 0.4, 0.2, 0.2);
    4950    /*this->activeCamera_ = *ObjectList<Camera>::begin();
  • code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc

    r1993 r2006  
    3131
    3232#include "core/CoreIncludes.h"
    33 #include "core/ConsoleCommand.h"
    3433#include "objects/infos/PlayerInfo.h"
    3534#include "objects/worldentities/pawns/Spectator.h"
     
    3938namespace orxonox
    4039{
    41     SetConsoleCommand(Gametype, listPlayers, true);
    42 
    4340    CreateUnloadableFactory(Gametype);
    4441
     
    4845
    4946        this->defaultPawn_ = Class(Spectator);
    50         this->getConnectedClients();
    5147
    5248        COUT(0) << "created Gametype" << std::endl;
    53     }
    54 
    55     Gametype* Gametype::getCurrentGametype()
    56     {
    57         for (ObjectList<Gametype>::iterator it = ObjectList<Gametype>::begin(); it != ObjectList<Gametype>::end(); ++it)
    58             return (*it);
    59 
    60         return 0;
    61     }
    62 
    63     PlayerInfo* Gametype::getClient(unsigned int clientID)
    64     {
    65         Gametype* gametype = Gametype::getCurrentGametype();
    66         if (gametype)
    67         {
    68             std::map<unsigned int, PlayerInfo*>::const_iterator it = gametype->clients_.find(clientID);
    69             if (it != gametype->clients_.end())
    70                 return it->second;
    71         }
    72         else
    73         {
    74             for (ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)
    75                 if (it->getClientID() == clientID)
    76                     return (*it);
    77         }
    78         return 0;
    79     }
    80 
    81     void Gametype::listPlayers()
    82     {
    83         Gametype* gametype = Gametype::getCurrentGametype();
    84 
    85         if (gametype)
    86         {
    87             for (std::set<PlayerInfo*>::const_iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
    88                 COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
    89         }
    90         else
    91         {
    92             for (ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)
    93                 COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
    94         }
    95     }
    96 
    97     void Gametype::clientConnected(unsigned int clientID)
    98     {
    99         COUT(0) << "client connected" << std::endl;
    100 
    101         // create new PlayerInfo instance
    102         PlayerInfo* player = new PlayerInfo();
    103         player->setClientID(clientID);
    104 
    105         // add to clients-map
    106         assert(!this->clients_[clientID]);
    107         this->clients_[clientID] = player;
    108     }
    109 
    110     void Gametype::clientDisconnected(unsigned int clientID)
    111     {
    112         COUT(0) << "client disconnected" << std::endl;
    113 
    114         // remove from clients-map
    115         PlayerInfo* player = this->clients_[clientID];
    116         this->clients_.erase(clientID);
    117 
    118         // delete PlayerInfo instance
    119         delete player;
    12049    }
    12150
     
    13160    void Gametype::removePlayer(PlayerInfo* player)
    13261    {
    133         player->stopControl();
    134         this->players_.erase(player);
    135         this->playerLeft(player);
     62        if (this->players_.find(player) != this->players_.end())
     63        {
     64            player->stopControl();
     65            this->players_.erase(player);
     66            this->playerLeft(player);
     67        }
    13668    }
    13769
  • code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.h

    r1989 r2006  
    3636#include "core/BaseObject.h"
    3737#include "core/Identifier.h"
    38 #include "network/ClientConnectionListener.h"
    3938#include "objects/worldentities/ControllableEntity.h"
    4039
    4140namespace orxonox
    4241{
    43     class _OrxonoxExport Gametype : public BaseObject, public network::ClientConnectionListener
     42    class _OrxonoxExport Gametype : public BaseObject
    4443    {
    4544        friend class PlayerInfo;
     
    4948            virtual ~Gametype() {}
    5049
    51             static Gametype* getCurrentGametype();
    52             static void listPlayers();
    53 
    54             inline const std::map<unsigned int, PlayerInfo*>& getClients() const
    55                 { return this->clients_; }
    5650            inline const std::set<PlayerInfo*>& getPlayers() const
    5751                { return this->players_; }
    58             static PlayerInfo* getClient(unsigned int clientID);
    5952
    6053        protected:
    61             virtual void clientConnected(unsigned int clientID);
    62             virtual void clientDisconnected(unsigned int clientID);
    63 
    6454            virtual void playerJoined(PlayerInfo* player);
    6555            virtual void playerLeft(PlayerInfo* player);
     
    7262
    7363            std::set<PlayerInfo*> players_;
    74             std::map<unsigned int, PlayerInfo*> clients_;
    7564            SubclassIdentifier<ControllableEntity> defaultPawn_;
    7665    };
  • code/branches/objecthierarchy/src/orxonox/objects/infos/LevelInfo.cc

    r1968 r2006  
    3131
    3232#include <OgreSceneManager.h>
     33#include <OgreLight.h>
    3334
    3435#include "core/CoreIncludes.h"
    3536#include "core/XMLPort.h"
    3637#include "core/Core.h"
     38#include "core/ConsoleCommand.h"
     39#include "core/Loader.h"
     40#include "core/Template.h"
    3741
    3842#include "GraphicsEngine.h"
     43#include "Settings.h"
     44#include "PlayerInfo.h"
     45
     46#include "util/Math.h"
    3947
    4048namespace orxonox
    4149{
     50    SetConsoleCommand(LevelInfo, listPlayers, true);
     51
    4252    CreateFactory(LevelInfo);
    4353
     
    4656        RegisterObject(LevelInfo);
    4757
    48         this->gametypeInstance_ = 0;
     58        this->rootGametype_ = 0;
    4959        this->registerVariables();
    5060
     61        // test test test
     62        {
     63            Ogre::Light* light;
     64            light = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light0");
     65            light->setType(Ogre::Light::LT_DIRECTIONAL);
     66            light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));
     67            light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));
     68            light->setDirection(1, -0.2, 0.2);
     69        }
     70        // test test test
     71
    5172        COUT(0) << "created LevelInfo" << std::endl;
    5273    }
    5374
     75    LevelInfo* LevelInfo::getActiveLevelInfo()
     76    {
     77        for (ObjectList<LevelInfo>::iterator it = ObjectList<LevelInfo>::begin(); it != ObjectList<LevelInfo>::end(); ++it)
     78            if (it->isActive())
     79                return (*it);
     80
     81        return 0;
     82    }
     83
     84    PlayerInfo* LevelInfo::getClient(unsigned int clientID)
     85    {
     86        LevelInfo* levelinfo = LevelInfo::getActiveLevelInfo();
     87
     88        if (levelinfo)
     89        {
     90            std::map<unsigned int, PlayerInfo*>::const_iterator it = levelinfo->clients_.find(clientID);
     91            if (it != levelinfo->clients_.end())
     92                return it->second;
     93        }
     94        else
     95        {
     96            for (ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)
     97                if (it->getClientID() == clientID)
     98                    return (*it);
     99        }
     100        return 0;
     101    }
     102
     103    void LevelInfo::listPlayers()
     104    {
     105        LevelInfo* levelinfo = LevelInfo::getActiveLevelInfo();
     106
     107        if (levelinfo->getGametype())
     108        {
     109            for (std::set<PlayerInfo*>::const_iterator it = levelinfo->getGametype()->getPlayers().begin(); it != levelinfo->getGametype()->getPlayers().end(); ++it)
     110                COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
     111        }
     112        else
     113        {
     114            for (ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)
     115                COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
     116        }
     117    }
     118
     119    void LevelInfo::clientConnected(unsigned int clientID)
     120    {
     121        COUT(0) << "client connected" << std::endl;
     122
     123        // create new PlayerInfo instance
     124        PlayerInfo* player = new PlayerInfo();
     125        player->setGametype(this->getGametype());
     126        player->setClientID(clientID);
     127
     128        // add to clients-map
     129        assert(!this->clients_[clientID]);
     130        this->clients_[clientID] = player;
     131    }
     132
     133    void LevelInfo::clientDisconnected(unsigned int clientID)
     134    {
     135        COUT(0) << "client disconnected" << std::endl;
     136
     137        // remove from clients-map
     138        PlayerInfo* player = this->clients_[clientID];
     139        this->clients_.erase(clientID);
     140
     141        // delete PlayerInfo instance
     142        delete player;
     143    }
     144
    54145    void LevelInfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    55146    {
     
    57148
    58149        XMLPortParam(LevelInfo, "description", setDescription, getDescription, xmlelement, mode);
    59         XMLPortParam(LevelInfo, "gametype", setGametype, getGametype, xmlelement, mode).defaultValues("Gametype");
     150        XMLPortParam(LevelInfo, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    60151        XMLPortParam(LevelInfo, "skybox", setSkybox, getSkybox, xmlelement, mode);
    61152        XMLPortParam(LevelInfo, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2, 0.2, 0.2, 1));
     153
     154        this->levelfile_ = this->getLevelfile();
    62155    }
    63156
    64157    void LevelInfo::registerVariables()
    65158    {
    66         REGISTERSTRING(name_,         network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::changedName));
    67         REGISTERSTRING(description_,  network::direction::toclient);
    68         REGISTERSTRING(skybox_,       network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applySkybox));
    69         REGISTERDATA(ambientLight_, network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applyAmbientLight));
     159        REGISTERSTRING(this->levelfile_,    network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applyLevel));
     160        REGISTERSTRING(this->name_,         network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::changedName));
     161        REGISTERSTRING(this->description_,  network::direction::toclient);
     162        REGISTERSTRING(this->skybox_,       network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applySkybox));
     163        REGISTERDATA(this->ambientLight_, network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applyAmbientLight));
     164    }
     165
     166    void LevelInfo::applyLevel()
     167    {
     168        COUT(0) << "Loading level \"" << this->levelfile_ << "\"..." << std::endl;
     169
     170        ClassTreeMask mask;
     171        mask.exclude(Class(BaseObject));
     172        mask.include(Class(Template));
     173
     174        Level* level = new Level(Settings::getDataPath() + this->levelfile_, mask);
     175
     176        Loader::open(level);
    70177    }
    71178
     
    87194    }
    88195
    89     void LevelInfo::setGametype(const std::string& gametype)
     196    void LevelInfo::setGametypeString(const std::string& gametype)
    90197    {
    91198        Identifier* identifier = ClassByString(gametype);
     
    94201            this->gametype_ = gametype;
    95202            this->gametypeIdentifier_ = identifier;
    96             this->gametypeInstance_ = this->gametypeIdentifier_.fabricate();
     203            this->rootGametype_ = this->gametypeIdentifier_.fabricate();
     204            this->getConnectedClients();
    97205        }
    98206    }
  • code/branches/objecthierarchy/src/orxonox/objects/infos/LevelInfo.h

    r1940 r2006  
    3737
    3838#include "objects/gametypes/Gametype.h"
     39#include "network/ClientConnectionListener.h"
    3940
    4041namespace orxonox
    4142{
    42     class _OrxonoxExport LevelInfo : public Info
     43    class _OrxonoxExport LevelInfo : public Info, public network::ClientConnectionListener
    4344    {
    4445        public:
     
    4849            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4950            void registerVariables();
     51
     52            inline const std::map<unsigned int, PlayerInfo*>& getClients() const
     53                { return this->clients_; }
    5054
    5155            inline void setDescription(const std::string& description)
     
    6266                { return this->ambientLight_; }
    6367
    64             void setGametype(const std::string& gametype);
    65             inline const std::string& getGametype() const
     68            void setGametypeString(const std::string& gametype);
     69            inline const std::string& getGametypeString() const
    6670                { return this->gametype_; }
     71            inline Gametype* getGametype() const
     72                { return this->rootGametype_; }
     73
     74            static LevelInfo* getActiveLevelInfo();
     75            static void listPlayers();
     76            static PlayerInfo* getClient(unsigned int clientID);
    6777
    6878        private:
     79            virtual void clientConnected(unsigned int clientID);
     80            virtual void clientDisconnected(unsigned int clientID);
     81
     82            void applyLevel();
     83
    6984            void applySkybox()
    7085                { this->setSkybox(this->skybox_); }
     
    7287                { this->setAmbientLight(this->ambientLight_); }
    7388
     89            std::map<unsigned int, PlayerInfo*> clients_;
    7490            std::string description_;
    7591            std::string skybox_;
     
    7793            std::string gametype_;
    7894            SubclassIdentifier<Gametype> gametypeIdentifier_;
    79             Gametype* gametypeInstance_;
     95            Gametype* rootGametype_;
     96            std::string levelfile_;
    8097    };
    8198}
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r1993 r2006  
    3838
    3939#include "network/Host.h"
     40#include "network/ClientInformation.h"
    4041
    4142#include "GraphicsEngine.h"
     
    5758        this->bHumanPlayer_ = false;
    5859        this->bFinishedSetup_ = false;
     60        this->gametype_ = 0;
    5961
    6062        this->pawn_ = 0;
     
    7173        if (this->isInitialized())
    7274        {
    73             Gametype* gametype = Gametype::getCurrentGametype();
    74             if (gametype)
    75                 gametype->removePlayer(this);
     75            if (this->gametype_)
     76                this->gametype_->removePlayer(this);
    7677
    7778            if (this->controller_)
     
    101102    void PlayerInfo::changedName()
    102103    {
    103         Gametype* gametype = Gametype::getCurrentGametype();
    104         if (gametype)
    105             gametype->playerChangedName(this);
     104        if (this->gametype_)
     105            this->gametype_->playerChangedName(this);
    106106    }
    107107
     
    147147        else if (this->bFinishedSetup_)
    148148        {
    149             Gametype* gametype = Gametype::getCurrentGametype();
    150             if (gametype)
    151                 gametype->addPlayer(this);
     149            if (this->gametype_)
     150                this->gametype_->addPlayer(this);
    152151        }
    153152    }
     
    165164    void PlayerInfo::stopControl()
    166165    {
    167         this->pawn_->removePlayer();
     166        if (this->pawn_)
     167            this->pawn_->removePlayer();
    168168        this->pawn_ = 0;
    169169        this->pawnID_ = network::OBJECTID_UNKNOWN;
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.h

    r1993 r2006  
    7171                { return this->controller_; }
    7272*/
     73            inline void setGametype(Gametype* gametype)
     74                { this->gametype_ = gametype; }
     75            inline Gametype* getGametype() const
     76                { return this->gametype_; }
     77
    7378        protected:
    7479            inline void setDefaultController(Identifier* identifier)
     
    98103            Controller* controller_;
    99104            SubclassIdentifier<Controller> defaultController_;
     105            Gametype* gametype_;
    100106    };
    101107}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc

    r1994 r2006  
    127127    void ControllableEntity::startLocalControl()
    128128    {
    129         std::cout << "###### start local control" << std::endl;
     129        std::cout << this->getObjectID() << " ###### start local control" << std::endl;
    130130        this->camera_ = new Camera();
    131131        this->camera_->requestFocus();
     
    155155        {
    156156            this->velocity_ += (dt * this->acceleration_);
    157             this->node_->translate(dt * this->velocity_, Ogre::Node::TS_PARENT);
     157            this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
    158158
    159159            if (Core::isMaster())
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.h

    r1993 r2006  
    115115                { this->hudtemplate_ = name; }
    116116
     117            inline bool isLocallyControlled() const
     118                { return this->bControlled_; }
     119
    117120        private:
    118121            void overwrite();
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.cc

    r1993 r2006  
    5555
    5656        XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
     57        XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
    5758    }
    5859
    5960    void Model::registerVariables()
    6061    {
    61         REGISTERSTRING(this->meshSrc_, network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedMesh));
     62        REGISTERSTRING(this->meshSrc_,    network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedMesh));
     63        REGISTERDATA(this->bCastShadows_, network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedShadows));
    6264    }
    6365
     
    6870
    6971        this->mesh_.setMeshSource(this->meshSrc_);
     72
    7073        if (this->mesh_.getEntity())
     74        {
    7175            this->getNode()->attachObject(this->mesh_.getEntity());
     76            this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
     77        }
     78    }
     79
     80    void Model::changedShadows()
     81    {
     82        this->mesh_.setCastShadows(this->bCastShadows_);
    7283    }
    7384
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.h

    r1993 r2006  
    5454                { return this->mesh_; }
    5555
     56            inline void setCastShadows(bool bCastShadows)
     57                { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
     58            inline bool getCastShadows() const
     59                { return this->bCastShadows_; }
     60
    5661        private:
    5762            void changedMesh();
     63            void changedShadows();
    5864
    5965            std::string meshSrc_;
    6066            Mesh mesh_;
     67            bool bCastShadows_;
    6168    };
    6269}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.cc

    r1993 r2006  
    5757        REGISTERDATA(this->getOrientation().z, network::direction::toclient);
    5858    }
    59 
    60     void PositionableEntity::tick(float dt)
    61     {
    62         // I don't know why but this has to be done to update the position if attached to another Entity
    63         this->node_->translate(Vector3::ZERO);
    64         std::cout << this->getWorldPosition() << std::endl;
    65     }
    6659}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.h

    r1993 r2006  
    3232#include "OrxonoxPrereqs.h"
    3333#include "WorldEntity.h"
    34 #include "objects/Tickable.h"
    3534
    3635namespace orxonox
    3736{
    38     class _OrxonoxExport PositionableEntity : public WorldEntity, public Tickable
     37    class _OrxonoxExport PositionableEntity : public WorldEntity
    3938    {
    4039        public:
     
    4342
    4443            void registerVariables();
    45             virtual void tick(float dt);
    4644
    4745            using WorldEntity::setPosition;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc

    r1993 r2006  
    5151        RegisterObject(WorldEntity);
    5252
    53         this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->createSceneNode();
     53        this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode();
    5454        this->parent_ = 0;
    5555        this->parentID_ = (unsigned int)-1;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2001 r2006  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/Core.h"
    3334#include "objects/worldentities/Model.h"
     35#include "tools/BillboardSet.h"
    3436
    3537namespace orxonox
     
    5153        this->setDestroyWhenPlayerLeft(true);
    5254
    53         Model* temp = new Model;
    54         temp->setMeshSource("assff.mesh");
    55         this->attach(temp);
     55        // test test test
     56        {
     57            this->testmesh_ = new Mesh();
     58            this->testnode_ = this->getNode()->createChildSceneNode();
     59            this->testmesh_->setMeshSource("assff.mesh");
     60            if (this->testmesh_->getEntity())
     61                this->testnode_->attachObject(this->testmesh_->getEntity());
     62            this->testnode_->pitch(Degree(-90));
     63            this->testnode_->roll(Degree(+90));
     64            this->testnode_->scale(10, 10, 10);
     65        }
     66        // test test test
     67
     68        this->greetingFlare_ = new BillboardSet();
     69        this->greetingFlare_->setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
     70        this->getNode()->attachObject(this->greetingFlare_->getBillboardSet());
     71        this->greetingFlare_->setVisible(false);
     72        this->bGreetingFlareVisible_ = false;
     73        this->bGreeting_ = false;
     74
     75        this->registerVariables();
    5676    }
    5777
    5878    Spectator::~Spectator()
    5979    {
     80        if (this->isInitialized())
     81        {
     82            delete this->greetingFlare_;
     83
     84            // test test test
     85            {
     86                delete this->testmesh_;
     87                delete this->testnode_;
     88            }
     89            // test test test
     90        }
     91    }
     92
     93    void Spectator::registerVariables()
     94    {
     95        REGISTERDATA(this->bGreetingFlareVisible_, network::direction::toclient, new network::NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
     96        REGISTERDATA(this->bGreeting_,             network::direction::toserver, new network::NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
     97    }
     98
     99    void Spectator::changedGreeting()
     100    {
     101        this->bGreetingFlareVisible_ = this->bGreeting_;
     102        this->changedFlareVisibility();
     103    }
     104
     105    void Spectator::changedFlareVisibility()
     106    {
     107        this->greetingFlare_->setVisible(this->bGreetingFlareVisible_);
    60108    }
    61109
    62110    void Spectator::tick(float dt)
    63111    {
    64         Vector3 velocity = this->getVelocity();
    65         velocity.normalise();
    66         this->setVelocity(velocity * this->speed_);
     112        if (this->isLocallyControlled())
     113        {
     114            Vector3 velocity = this->getVelocity();
     115            velocity.normalise();
     116            this->setVelocity(velocity * this->speed_);
    67117
    68         // TODO: Check why I have removed *dt (1337)
    69         this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
    70         this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
    71         this->roll(Radian(this->roll_ * this->rotationSpeed_));
     118            this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
     119            this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
     120            this->roll(Radian(this->roll_ * this->rotationSpeed_));
    72121
    73         this->yaw_ = this->pitch_ = this->roll_ = 0;
     122            this->yaw_ = this->pitch_ = this->roll_ = 0;
     123        }
    74124
    75125        SUPER(Spectator, tick, dt);
    76126
    77         this->setVelocity(Vector3::ZERO);
     127        if (this->isLocallyControlled())
     128        {
     129            this->setVelocity(Vector3::ZERO);
     130        }
    78131    }
    79132
     
    82135        ControllableEntity::setPlayer(player);
    83136
    84         this->setObjectMode(network::direction::toclient);
     137//        this->setObjectMode(network::direction::toclient);
     138    }
     139
     140    void Spectator::startLocalControl()
     141    {
     142        ControllableEntity::startLocalControl();
     143        if (this->isLocallyControlled())
     144            this->testmesh_->setVisible(false);
    85145    }
    86146
     
    118178    {
    119179    }
     180
     181    void Spectator::greet()
     182    {
     183        this->bGreeting_ = !this->bGreeting_;
     184
     185        if (Core::isMaster())
     186        {
     187            this->bGreetingFlareVisible_ = this->bGreeting_;
     188            this->changedFlareVisibility();
     189        }
     190    }
    120191}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h

    r1993 r2006  
    4242            virtual ~Spectator();
    4343
     44            void registerVariables();
    4445            virtual void tick(float dt);
    4546
    4647            virtual void setPlayer(PlayerInfo* player);
     48            virtual void startLocalControl();
    4749
    4850            virtual void moveFrontBack(float value);
     
    5557
    5658            virtual void fire();
     59            virtual void greet();
    5760
    5861        private:
     62            void changedGreeting();
     63            void changedFlareVisibility();
     64
     65            BillboardSet* greetingFlare_;
     66            bool bGreetingFlareVisible_;
     67            bool bGreeting_;
     68
    5969            float speed_;
    6070            float rotationSpeed_;
     
    6373            float pitch_;
    6474            float roll_;
     75
     76            // test test test
     77            Mesh* testmesh_;
     78            Ogre::SceneNode* testnode_;
     79            // test test test
    6580    };
    6681}
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc

    r1968 r2006  
    3939
    4040#include "GraphicsEngine.h"
    41 #include "objects/gametypes/Gametype.h"
     41#include "objects/infos/LevelInfo.h"
    4242#include "objects/infos/PlayerInfo.h"
    4343#include "overlays/console/InGameConsole.h"
     
    7676            std::string name = "unknown";
    7777
    78             PlayerInfo* player = Gametype::getClient(senderID);
     78            PlayerInfo* player = LevelInfo::getClient(senderID);
    7979            if (player)
    8080                name = player->getName();
  • code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc

    r1993 r2006  
    4545    {
    4646        this->entity_ = 0;
     47        this->bCastShadows_ = true;
    4748    }
    4849
     
    5960            if (this->entity_)
    6061                GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
    61             this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     62
     63            try
     64            {
     65                this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     66                this->entity_->setCastShadows(this->bCastShadows_);
     67            }
     68            catch (...)
     69            {
     70                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
     71            }
    6272        }
     73    }
     74
     75    void Mesh::setCastShadows(bool bCastShadows)
     76    {
     77        this->bCastShadows_ = bCastShadows;
     78        if (this->entity_)
     79            this->entity_->setCastShadows(this->bCastShadows_);
    6380    }
    6481
  • code/branches/objecthierarchy/src/orxonox/tools/Mesh.h

    r1993 r2006  
    5353            bool isVisible() const;
    5454
     55            void setCastShadows(bool bCastShadows);
     56            inline bool getCastShadows() const
     57                { return this->bCastShadows_; }
     58
    5559        private:
    5660            static unsigned int meshCounter_s;
    5761            Ogre::Entity* entity_;
     62            bool bCastShadows_;
    5863    };
    5964}
Note: See TracChangeset for help on using the changeset viewer.