- Timestamp:
- Oct 29, 2008, 12:48:11 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects/worldentities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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.