Changeset 2042
- Timestamp:
- Oct 29, 2008, 3:26:55 AM (16 years ago)
- Location:
- code/branches/objecthierarchy
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/bin/def_keybindings.ini
r2006 r2042 10 10 KeyBack= 11 11 KeyBackslash= 12 KeyC= 12 KeyC=switchCamera 13 13 KeyCalculator= 14 14 KeyCapsLock= -
code/branches/objecthierarchy/src/orxonox/CMakeLists.txt
r2030 r2042 58 58 objects/worldentities/Model.cc 59 59 objects/worldentities/Camera.cc 60 objects/worldentities/CameraPosition.cc 60 61 objects/worldentities/SpawnPoint.cc 61 62 # objects/worldentities/Backlight.cc -
code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h
r2023 r2042 98 98 99 99 class Camera; 100 class CameraPosition; 100 101 class SpawnPoint; 101 102 -
code/branches/objecthierarchy/src/orxonox/objects/controllers/Controller.h
r2041 r2042 48 48 49 49 virtual inline void setControllableEntity(ControllableEntity* entity) 50 { COUT(0) << "HC: start controlling entity" << std::endl;this->controllableEntity_ = entity; }50 { this->controllableEntity_ = entity; } 51 51 virtual inline ControllableEntity* getControllableEntity() const 52 52 { return this->controllableEntity_; } -
code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc
r2041 r2042 57 57 58 58 HumanController::localController_s = this; 59 60 COUT(0) << "HumanController created" << std::endl;61 59 } 62 60 -
code/branches/objecthierarchy/src/orxonox/objects/infos/HumanPlayer.cc
r2041 r2042 54 54 this->setConfigValues(); 55 55 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 else64 {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;83 56 } 84 57 85 58 HumanPlayer::~HumanPlayer() 86 59 { 87 COUT(0) << this->getObjectID() << ": HumanPlayer destroyed" << std::endl;88 60 } 89 61 … … 120 92 void HumanPlayer::networkcallback_clientIDchanged() 121 93 { 122 COUT(0) << this->getObjectID() << ": PI: clientID changed to " << this->clientID_ << std::endl;123 94 if (this->clientID_ == network::Host::getPlayerID()) 124 95 { 125 COUT(0) << this->getObjectID() << ": PI: it's my clientID" << std::endl;126 96 this->bLocalPlayer_ = true; 127 97 this->synchronize_nick_ = this->nick_; … … 129 99 130 100 if (!Core::isMaster()) 131 {132 101 this->setObjectMode(network::direction::bidirectional); 133 COUT(0) << this->getObjectID() << ": PI: set objectmode to bidirectional" << std::endl;134 }135 102 else 136 103 this->setName(this->nick_); … … 143 110 { 144 111 this->client_ready_ = true; 145 COUT(0) << this->getObjectID() << ": PI: server ready, client set ready too" << std::endl;146 112 } 147 113 148 114 void HumanPlayer::networkcallback_client_ready() 149 115 { 150 COUT(0) << this->getObjectID() << ": PI: client ready" << std::endl;151 116 if (this->getGametype()) 152 {153 COUT(0) << this->getObjectID() << ": PI: adding client to gametype" << std::endl;154 117 this->getGametype()->playerEntered(this); 155 }156 118 } 157 119 … … 173 135 void HumanPlayer::setClientID(unsigned int clientID) 174 136 { 175 COUT(0) << this->getObjectID() << ": PI: set clientID to " << clientID << std::endl;176 137 this->clientID_ = clientID; 177 138 this->networkcallback_clientIDchanged(); -
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc
r2041 r2042 128 128 this->controllableEntityID_ = network::OBJECTID_UNKNOWN; 129 129 } 130 COUT(0) << this->getObjectID() << ": PI: start control" << std::endl; 130 131 131 if (this->controller_) 132 132 this->controller_->setControllableEntity(entity); -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
r2041 r2042 37 37 #include "objects/infos/PlayerInfo.h" 38 38 #include "objects/worldentities/Camera.h" 39 #include "objects/worldentities/CameraPosition.h" 39 40 #include "overlays/OverlayGroup.h" 40 41 … … 92 93 93 94 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 } 94 146 } 95 147 … … 105 157 this->playerID_ = player->getObjectID(); 106 158 this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer()); 107 108 159 if (this->bControlled_) 109 160 { … … 111 162 112 163 if (!Core::isMaster()) 164 { 165 COUT(0) << "CE: bidirectional synchronization" << std::endl; 113 166 this->setObjectMode(network::direction::bidirectional); 167 } 114 168 } 115 169 } … … 145 199 this->camera_ = new Camera(this); 146 200 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_); 148 207 149 208 if (this->hudtemplate_ != "") … … 157 216 { 158 217 std::cout << "###### stop local control" << std::endl; 159 this-> detach(this->camera_);218 this->camera_->detachFromParent(); 160 219 delete this->camera_; 161 220 this->camera_ = 0; … … 187 246 void ControllableEntity::registerVariables() 188 247 { 248 REGISTERSTRING(this->cameraPositionTemplate_, network::direction::toclient); 249 189 250 REGISTERDATA(this->server_position_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 190 251 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 70 70 virtual void greet() {} 71 71 virtual void use() {} 72 virtual void switchCamera() {}72 virtual void switchCamera(); 73 73 74 74 inline const Vector3& getVelocity() const … … 112 112 inline OverlayGroup* getHUD() const 113 113 { 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_; } 114 124 115 125 protected: … … 158 168 Camera* camera_; 159 169 bool bDestroyWhenPlayerLeft_; 170 171 std::list<CameraPosition*> cameraPositions_; 172 std::string cameraPositionTemplate_; 160 173 }; 161 174 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r2040 r2042 136 136 object->parentID_ = (unsigned int)-1; 137 137 138 this->getScene()->getRootSceneNode()->addChild(object->node_);138 // this->getScene()->getRootSceneNode()->addChild(object->node_); 139 139 } 140 140 -
code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc
r2040 r2042 96 96 void ChatOverlay::dropMessage() 97 97 { 98 this->messages_.pop_front(); 98 if (this->messages_.size() > 0) 99 this->messages_.pop_front(); 99 100 this->updateOverlayText(); 100 101 }
Note: See TracChangeset
for help on using the changeset viewer.