Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2042


Ignore:
Timestamp:
Oct 29, 2008, 3:26:55 AM (16 years ago)
Author:
landauf
Message:

added camerapositions

Location:
code/branches/objecthierarchy
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/bin/def_keybindings.ini

    r2006 r2042  
    1010KeyBack=
    1111KeyBackslash=
    12 KeyC=
     12KeyC=switchCamera
    1313KeyCalculator=
    1414KeyCapsLock=
  • code/branches/objecthierarchy/src/orxonox/CMakeLists.txt

    r2030 r2042  
    5858  objects/worldentities/Model.cc
    5959  objects/worldentities/Camera.cc
     60  objects/worldentities/CameraPosition.cc
    6061  objects/worldentities/SpawnPoint.cc
    6162#  objects/worldentities/Backlight.cc
  • code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h

    r2023 r2042  
    9898
    9999    class Camera;
     100    class CameraPosition;
    100101    class SpawnPoint;
    101102
  • code/branches/objecthierarchy/src/orxonox/objects/controllers/Controller.h

    r2041 r2042  
    4848
    4949            virtual inline void setControllableEntity(ControllableEntity* entity)
    50                 { COUT(0) << "HC: start controlling entity" << std::endl; this->controllableEntity_ = entity; }
     50                { this->controllableEntity_ = entity; }
    5151            virtual inline ControllableEntity* getControllableEntity() const
    5252                { return this->controllableEntity_; }
  • code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc

    r2041 r2042  
    5757
    5858        HumanController::localController_s = this;
    59 
    60         COUT(0) << "HumanController created" << std::endl;
    6159    }
    6260
  • code/branches/objecthierarchy/src/orxonox/objects/infos/HumanPlayer.cc

    r2041 r2042  
    5454        this->setConfigValues();
    5555        this->registerVariables();
    56 
    57 COUT(0) << this->getObjectID() << ": HumanPlayer created" << std::endl;
    58         network::Synchronisable* temp = dynamic_cast<network::Synchronisable*>(creator);
    59         if (temp)
    60         {
    61 COUT(0) << this->getObjectID() << ": CreatorID: " << temp->getObjectID() << std::endl;
    62         }
    63         else
    64         {
    65 COUT(0) << this->getObjectID() << ": Creator is no Synchronisable" << std::endl;
    66         }
    67     unsigned int creatorID = network::OBJECTID_UNKNOWN;
    68     searchcreatorID:
    69     if (creator)
    70     {
    71         if (creator->isA(Class(Synchronisable)))
    72         {
    73             Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
    74             creatorID = synchronisable_creator->getObjectID();
    75         }
    76         else if (creator != creator->getCreator())
    77         {
    78             creator = creator->getCreator();
    79             goto searchcreatorID;
    80         }
    81     }
    82 COUT(0) << this->getObjectID() << ": ### tranmitted creatorID: " << creatorID << std::endl;
    8356    }
    8457
    8558    HumanPlayer::~HumanPlayer()
    8659    {
    87 COUT(0) << this->getObjectID() << ": HumanPlayer destroyed" << std::endl;
    8860    }
    8961
     
    12092    void HumanPlayer::networkcallback_clientIDchanged()
    12193    {
    122 COUT(0) << this->getObjectID() << ": PI: clientID changed to " << this->clientID_ << std::endl;
    12394        if (this->clientID_ == network::Host::getPlayerID())
    12495        {
    125 COUT(0) << this->getObjectID() << ": PI: it's my clientID" << std::endl;
    12696            this->bLocalPlayer_ = true;
    12797            this->synchronize_nick_ = this->nick_;
     
    12999
    130100            if (!Core::isMaster())
    131             {
    132101                this->setObjectMode(network::direction::bidirectional);
    133 COUT(0) << this->getObjectID() << ": PI: set objectmode to bidirectional" << std::endl;
    134             }
    135102            else
    136103                this->setName(this->nick_);
     
    143110    {
    144111        this->client_ready_ = true;
    145 COUT(0) << this->getObjectID() << ": PI: server ready, client set ready too" << std::endl;
    146112    }
    147113
    148114    void HumanPlayer::networkcallback_client_ready()
    149115    {
    150 COUT(0) << this->getObjectID() << ": PI: client ready" << std::endl;
    151116        if (this->getGametype())
    152         {
    153 COUT(0) << this->getObjectID() << ": PI: adding client to gametype" << std::endl;
    154117            this->getGametype()->playerEntered(this);
    155         }
    156118    }
    157119
     
    173135    void HumanPlayer::setClientID(unsigned int clientID)
    174136    {
    175 COUT(0) << this->getObjectID() << ": PI: set clientID to " << clientID << std::endl;
    176137        this->clientID_ = clientID;
    177138        this->networkcallback_clientIDchanged();
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r2041 r2042  
    128128            this->controllableEntityID_ = network::OBJECTID_UNKNOWN;
    129129        }
    130 COUT(0) << this->getObjectID() << ": PI: start control" << std::endl;
     130
    131131        if (this->controller_)
    132132            this->controller_->setControllableEntity(entity);
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2041 r2042  
    3737#include "objects/infos/PlayerInfo.h"
    3838#include "objects/worldentities/Camera.h"
     39#include "objects/worldentities/CameraPosition.h"
    3940#include "overlays/OverlayGroup.h"
    4041
     
    9293
    9394        XMLPortParam(ControllableEntity, "hudtemplate", setHudTemplate, getHudTemplate, xmlelement, mode);
     95        XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemkplate, xmlelement, mode);
     96
     97        XMLPortObject(ControllableEntity, WorldEntity, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode);
     98    }
     99
     100    void ControllableEntity::addCameraPosition(CameraPosition* position)
     101    {
     102        this->attach(position);
     103        this->cameraPositions_.push_back(position);
     104    }
     105
     106    CameraPosition* ControllableEntity::getCameraPosition(unsigned int index) const
     107    {
     108        unsigned int i = 0;
     109        for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     110        {
     111            if (i == index)
     112                return (*it);
     113            ++i;
     114        }
     115        return 0;
     116    }
     117
     118    void ControllableEntity::switchCamera()
     119    {
     120        if (this->camera_)
     121        {
     122            if (this->camera_->getParent() == this && this->cameraPositions_.size() > 0)
     123            {
     124                this->cameraPositions_.front()->attachCamera(this->camera_);
     125            }
     126            else if (this->cameraPositions_.size() > 0)
     127            {
     128                for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     129                {
     130                    if ((*it) == this->camera_->getParent())
     131                    {
     132                        ++it;
     133                        if (it != this->cameraPositions_.end())
     134                            (*it)->attachCamera(this->camera_);
     135                        else
     136                            (*this->cameraPositions_.begin())->attachCamera(this->camera_);
     137                        break;
     138                    }
     139                }
     140            }
     141            else
     142            {
     143                this->attach(this->camera_);
     144            }
     145        }
    94146    }
    95147
     
    105157        this->playerID_ = player->getObjectID();
    106158        this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer());
    107 
    108159        if (this->bControlled_)
    109160        {
     
    111162
    112163            if (!Core::isMaster())
     164            {
     165COUT(0) << "CE: bidirectional synchronization" << std::endl;
    113166                this->setObjectMode(network::direction::bidirectional);
     167            }
    114168        }
    115169    }
     
    145199        this->camera_ = new Camera(this);
    146200        this->camera_->requestFocus();
    147         this->attach(this->camera_);
     201        if (this->cameraPositionTemplate_ != "")
     202            this->addTemplate(this->cameraPositionTemplate_);
     203        if (this->cameraPositions_.size() > 0)
     204            this->cameraPositions_.front()->attachCamera(this->camera_);
     205        else
     206            this->attach(this->camera_);
    148207
    149208        if (this->hudtemplate_ != "")
     
    157216    {
    158217        std::cout << "###### stop local control" << std::endl;
    159         this->detach(this->camera_);
     218        this->camera_->detachFromParent();
    160219        delete this->camera_;
    161220        this->camera_ = 0;
     
    187246    void ControllableEntity::registerVariables()
    188247    {
     248        REGISTERSTRING(this->cameraPositionTemplate_, network::direction::toclient);
     249
    189250        REGISTERDATA(this->server_position_,    network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    190251        REGISTERDATA(this->server_velocity_,    network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.h

    r2040 r2042  
    7070            virtual void greet() {}
    7171            virtual void use() {}
    72             virtual void switchCamera() {}
     72            virtual void switchCamera();
    7373
    7474            inline const Vector3& getVelocity() const
     
    112112            inline OverlayGroup* getHUD() const
    113113                { return this->hud_; }
     114
     115            void addCameraPosition(CameraPosition* position);
     116            CameraPosition* getCameraPosition(unsigned int index) const;
     117            inline const std::list<CameraPosition*>& getCameraPositions() const
     118                { return this->cameraPositions_; }
     119
     120            inline void setCameraPositionTemplate(const std::string& name)
     121                { this->cameraPositionTemplate_ = name; }
     122            inline const std::string& getCameraPositionTemkplate() const
     123                { return this->cameraPositionTemplate_; }
    114124
    115125        protected:
     
    158168            Camera* camera_;
    159169            bool bDestroyWhenPlayerLeft_;
     170
     171            std::list<CameraPosition*> cameraPositions_;
     172            std::string cameraPositionTemplate_;
    160173    };
    161174}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc

    r2040 r2042  
    136136        object->parentID_ = (unsigned int)-1;
    137137
    138         this->getScene()->getRootSceneNode()->addChild(object->node_);
     138//        this->getScene()->getRootSceneNode()->addChild(object->node_);
    139139    }
    140140
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc

    r2040 r2042  
    9696    void ChatOverlay::dropMessage()
    9797    {
    98         this->messages_.pop_front();
     98        if (this->messages_.size() > 0)
     99            this->messages_.pop_front();
    99100        this->updateOverlayText();
    100101    }
Note: See TracChangeset for help on using the changeset viewer.