Changeset 2041 for code/branches/objecthierarchy/src/orxonox
- Timestamp:
- Oct 29, 2008, 12:48:11 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/LevelManager.cc
r2040 r2041 112 112 assert(!this->clients_[clientID]); 113 113 this->clients_[clientID] = player; 114 115 if (this->getActiveLevel()) 116 this->getActiveLevel()->playerEntered(player); 114 117 } 115 118 … … 121 124 PlayerInfo* player = this->clients_[clientID]; 122 125 this->clients_.erase(clientID); 126 127 if (this->getActiveLevel()) 128 this->getActiveLevel()->playerLeft(player); 123 129 124 130 // delete PlayerInfo instance -
code/branches/objecthierarchy/src/orxonox/objects/controllers/Controller.h
r2040 r2041 48 48 49 49 virtual inline void setControllableEntity(ControllableEntity* entity) 50 { this->controllableEntity_ = entity; }50 { COUT(0) << "HC: start controlling entity" << std::endl; this->controllableEntity_ = entity; } 51 51 virtual inline ControllableEntity* getControllableEntity() const 52 52 { return this->controllableEntity_; } -
code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc
r2040 r2041 57 57 58 58 HumanController::localController_s = this; 59 60 COUT(0) << "HumanController created" << std::endl; 59 61 } 60 62 -
code/branches/objecthierarchy/src/orxonox/objects/infos/HumanPlayer.cc
r2040 r2041 55 55 this->registerVariables(); 56 56 57 COUT(0) << "HumanPlayer created" << std::endl; 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; 58 83 } 59 84 60 85 HumanPlayer::~HumanPlayer() 61 86 { 87 COUT(0) << this->getObjectID() << ": HumanPlayer destroyed" << std::endl; 62 88 } 63 89 … … 94 120 void HumanPlayer::networkcallback_clientIDchanged() 95 121 { 122 COUT(0) << this->getObjectID() << ": PI: clientID changed to " << this->clientID_ << std::endl; 96 123 if (this->clientID_ == network::Host::getPlayerID()) 97 124 { 125 COUT(0) << this->getObjectID() << ": PI: it's my clientID" << std::endl; 98 126 this->bLocalPlayer_ = true; 99 127 this->synchronize_nick_ = this->nick_; … … 101 129 102 130 if (!Core::isMaster()) 131 { 103 132 this->setObjectMode(network::direction::bidirectional); 133 COUT(0) << this->getObjectID() << ": PI: set objectmode to bidirectional" << std::endl; 134 } 104 135 else 105 136 this->setName(this->nick_); … … 112 143 { 113 144 this->client_ready_ = true; 145 COUT(0) << this->getObjectID() << ": PI: server ready, client set ready too" << std::endl; 114 146 } 115 147 116 148 void HumanPlayer::networkcallback_client_ready() 117 149 { 150 COUT(0) << this->getObjectID() << ": PI: client ready" << std::endl; 118 151 if (this->getGametype()) 152 { 153 COUT(0) << this->getObjectID() << ": PI: adding client to gametype" << std::endl; 119 154 this->getGametype()->playerEntered(this); 155 } 120 156 } 121 157 … … 137 173 void HumanPlayer::setClientID(unsigned int clientID) 138 174 { 175 COUT(0) << this->getObjectID() << ": PI: set clientID to " << clientID << std::endl; 139 176 this->clientID_ = clientID; 140 177 this->networkcallback_clientIDchanged(); -
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc
r2040 r2041 71 71 REGISTERSTRING(this->name_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 72 72 REGISTERDATA (this->controllableEntityID_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 73 REGISTERDATA (this->bReadyToSpawn_, network::direction::toserver); 73 74 } 74 75 … … 127 128 this->controllableEntityID_ = network::OBJECTID_UNKNOWN; 128 129 } 129 130 COUT(0) << this->getObjectID() << ": PI: start control" << std::endl; 130 131 if (this->controller_) 131 132 this->controller_->setControllableEntity(entity); 132 133 } 133 134 134 void PlayerInfo::stopControl(ControllableEntity* entity )135 void PlayerInfo::stopControl(ControllableEntity* entity, bool callback) 135 136 { 136 137 if (entity && this->controllableEntity_ == entity) … … 142 143 this->controller_->setControllableEntity(0); 143 144 144 entity->removePlayer(); 145 if (callback) 146 entity->removePlayer(); 145 147 } 146 148 } -
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.h
r2040 r2041 66 66 67 67 void startControl(ControllableEntity* entity); 68 void stopControl(ControllableEntity* entity );68 void stopControl(ControllableEntity* entity, bool callback = true); 69 69 70 70 inline ControllableEntity* getControllableEntity() const -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
r2040 r2041 81 81 if (this->camera_) 82 82 delete this->camera_; 83 84 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 85 this->getPlayer()->stopControl(this, false); 83 86 } 84 87 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2040 r2041 58 58 this->bInvertYAxis_ = false; 59 59 60 this->setDestroyWhenPlayerLeft(true); 61 60 62 this->setConfigValues(); 61 63 this->registerVariables(); … … 80 82 void SpaceShip::registerVariables() 81 83 { 84 REGISTERDATA(this->maxSpeed_, network::direction::toclient); 85 REGISTERDATA(this->maxSecondarySpeed_, network::direction::toclient); 86 REGISTERDATA(this->maxRotation_, network::direction::toclient); 87 REGISTERDATA(this->translationAcceleration_, network::direction::toclient); 88 REGISTERDATA(this->rotationAcceleration_, network::direction::toclient); 89 REGISTERDATA(this->translationDamping_, network::direction::toclient); 82 90 } 83 91 … … 89 97 void SpaceShip::tick(float dt) 90 98 { 91 // ##################################### 92 // ############# STEERING ############## 93 // ##################################### 94 95 Vector3 velocity = this->getVelocity(); 96 if (velocity.x > this->maxSecondarySpeed_) 97 velocity.x = this->maxSecondarySpeed_; 98 if (velocity.x < -this->maxSecondarySpeed_) 99 velocity.x = -this->maxSecondarySpeed_; 100 if (velocity.y > this->maxSecondarySpeed_) 101 velocity.y = this->maxSecondarySpeed_; 102 if (velocity.y < -this->maxSecondarySpeed_) 103 velocity.y = -this->maxSecondarySpeed_; 104 if (velocity.z > this->maxSecondarySpeed_) 105 velocity.z = this->maxSecondarySpeed_; 106 if (velocity.z < -this->maxSpeed_) 107 velocity.z = -this->maxSpeed_; 108 109 // normalize velocity and acceleration 110 for (size_t dimension = 0; dimension < 3; ++dimension) 99 if (this->isLocallyControlled()) 111 100 { 112 if (this->acceleration_[dimension] == 0) 101 // ##################################### 102 // ############# STEERING ############## 103 // ##################################### 104 105 Vector3 velocity = this->getVelocity(); 106 if (velocity.x > this->maxSecondarySpeed_) 107 velocity.x = this->maxSecondarySpeed_; 108 if (velocity.x < -this->maxSecondarySpeed_) 109 velocity.x = -this->maxSecondarySpeed_; 110 if (velocity.y > this->maxSecondarySpeed_) 111 velocity.y = this->maxSecondarySpeed_; 112 if (velocity.y < -this->maxSecondarySpeed_) 113 velocity.y = -this->maxSecondarySpeed_; 114 if (velocity.z > this->maxSecondarySpeed_) 115 velocity.z = this->maxSecondarySpeed_; 116 if (velocity.z < -this->maxSpeed_) 117 velocity.z = -this->maxSpeed_; 118 119 // normalize velocity and acceleration 120 for (size_t dimension = 0; dimension < 3; ++dimension) 113 121 { 114 if ( velocity[dimension] >0)122 if (this->acceleration_[dimension] == 0) 115 123 { 116 velocity[dimension] -= (this->translationDamping_ * dt);117 if (velocity[dimension] < 0)118 velocity[dimension] = 0;119 }120 else if (velocity[dimension] < 0)121 {122 velocity[dimension] += (this->translationDamping_ * dt);123 124 if (velocity[dimension] > 0) 124 velocity[dimension] = 0; 125 { 126 velocity[dimension] -= (this->translationDamping_ * dt); 127 if (velocity[dimension] < 0) 128 velocity[dimension] = 0; 129 } 130 else if (velocity[dimension] < 0) 131 { 132 velocity[dimension] += (this->translationDamping_ * dt); 133 if (velocity[dimension] > 0) 134 velocity[dimension] = 0; 135 } 125 136 } 126 137 } 138 139 this->setVelocity(velocity); 127 140 } 128 141 129 this->setVelocity(velocity);130 131 142 132 143 SUPER(SpaceShip, tick, dt); 133 144 134 145 135 this->yaw(this->yawRotation_ * dt); 136 if (this->bInvertYAxis_) 137 this->pitch(Degree(-this->pitchRotation_ * dt)); 138 else 139 this->pitch(Degree( this->pitchRotation_ * dt)); 140 this->roll(this->rollRotation_ * dt); 141 142 this->acceleration_.x = 0; 143 this->acceleration_.y = 0; 144 this->acceleration_.z = 0; 145 146 this->yawRotation_ = this->zeroDegree_; 147 this->pitchRotation_ = this->zeroDegree_; 148 this->rollRotation_ = this->zeroDegree_; 146 if (this->isLocallyControlled()) 147 { 148 this->yaw(this->yawRotation_ * dt); 149 if (this->bInvertYAxis_) 150 this->pitch(Degree(-this->pitchRotation_ * dt)); 151 else 152 this->pitch(Degree( this->pitchRotation_ * dt)); 153 this->roll(this->rollRotation_ * dt); 154 155 this->acceleration_.x = 0; 156 this->acceleration_.y = 0; 157 this->acceleration_.z = 0; 158 159 this->yawRotation_ = this->zeroDegree_; 160 this->pitchRotation_ = this->zeroDegree_; 161 this->rollRotation_ = this->zeroDegree_; 162 } 149 163 } 150 164 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2040 r2041 56 56 this->roll_ = 0; 57 57 this->setHudTemplate("spectatorhud"); 58 this->hudmode_ = 0; 58 59 59 60 this->setDestroyWhenPlayerLeft(true); … … 85 86 REGISTERDATA(this->bGreetingFlareVisible_, network::direction::toclient, new network::NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 86 87 REGISTERDATA(this->bGreeting_, network::direction::toserver, new network::NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 88 REGISTERDATA(this->hudmode_, network::direction::toclient); 87 89 } 88 90 … … 100 102 void Spectator::tick(float dt) 101 103 { 104 this->updateHUD(); 105 102 106 if (this->isLocallyControlled()) 103 107 { 104 this->updateHUD();105 106 108 Vector3 velocity = this->getVelocity(); 107 109 velocity.normalise(); … … 187 189 { 188 190 // <hack> 189 if (this->getHUD()) 190 { 191 std::string text; 192 191 if (Core::isMaster()) 192 { 193 193 if (this->getPlayer() && this->getGametype()) 194 194 { … … 196 196 { 197 197 if (!this->getPlayer()->isReadyToSpawn()) 198 t ext = "Press [Fire] to start the match";198 this->hudmode_ = 0; 199 199 else 200 t ext = "Waiting for other players";200 this->hudmode_ = 1; 201 201 } 202 202 else if (!this->getGametype()->hasEnded()) 203 203 { 204 204 if (this->getGametype()->isStartCountdownRunning()) 205 { 206 text = convertToString(ceil(this->getGametype()->getStartCountdown())); 207 } 205 this->hudmode_ = 2 + 10*ceil(this->getGametype()->getStartCountdown()); 208 206 else 209 { 210 text = "Press [Fire] to respawn"; 211 } 207 this->hudmode_ = 3; 212 208 } 213 209 else 214 { 210 this->hudmode_ = 4; 211 } 212 else 213 return; 214 } 215 216 if (this->getHUD()) 217 { 218 std::string text; 219 int hudmode = this->hudmode_ % 10; 220 221 switch (hudmode) 222 { 223 case 0: 224 text = "Press [Fire] to start the match"; 225 break; 226 case 1: 227 text = "Waiting for other players"; 228 break; 229 case 2: 230 text = convertToString((this->hudmode_ - 2) / 10); 231 break; 232 case 3: 233 text = "Press [Fire] to respawn"; 234 break; 235 case 4: 215 236 text = "Game has ended"; 216 } 217 } 218 else 219 { 220 return; 237 break; 238 default:; 221 239 } 222 240 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h
r2040 r2041 74 74 float pitch_; 75 75 float roll_; 76 77 int hudmode_; 76 78 }; 77 79 }
Note: See TracChangeset
for help on using the changeset viewer.