Changeset 2024 for code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc
- Timestamp:
- Oct 28, 2008, 3:05:17 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2019 r2024 35 35 #include "objects/Scene.h" 36 36 #include "objects/infos/PlayerInfo.h" 37 #include "objects/gametypes/Gametype.h" 37 38 #include "tools/BillboardSet.h" 39 #include "overlays/OverlayText.h" 40 #include "overlays/OverlayGroup.h" 41 #include "util/Convert.h" 38 42 39 43 namespace orxonox … … 54 58 55 59 this->setDestroyWhenPlayerLeft(true); 56 57 // test test test58 if (this->getScene()->getSceneManager())59 {60 this->testmesh_ = new Mesh();61 this->testnode_ = this->getNode()->createChildSceneNode();62 this->testmesh_->setMeshSource(this->getScene()->getSceneManager(), "assff.mesh");63 if (this->testmesh_->getEntity())64 this->testnode_->attachObject(this->testmesh_->getEntity());65 this->testnode_->pitch(Degree(-90));66 this->testnode_->roll(Degree(+90));67 this->testnode_->scale(10, 10, 10);68 }69 else70 {71 this->testmesh_ = 0;72 this->testnode_ = 0;73 }74 // test test test75 60 76 61 this->greetingFlare_ = new BillboardSet(); … … 93 78 delete this->greetingFlare_; 94 79 } 95 96 // test test test97 {98 if (this->testmesh_ && this->testnode_)99 this->testnode_->detachObject(this->testmesh_->getEntity());100 101 if (this->testmesh_)102 delete this->testmesh_;103 104 if (this->testnode_)105 this->getNode()->removeAndDestroyChild(this->testnode_->getName());106 }107 // test test test108 80 } 109 81 } … … 130 102 if (this->isLocallyControlled()) 131 103 { 104 this->updateHUD(); 105 132 106 Vector3 velocity = this->getVelocity(); 133 107 velocity.normalise(); … … 159 133 { 160 134 ControllableEntity::startLocalControl(); 161 if (this->isLocallyControlled())162 this->testmesh_->setVisible(false);163 } 164 165 void Spectator::moveFrontBack( floatvalue)166 { 167 this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::FRONT);168 } 169 170 void Spectator::moveRightLeft( floatvalue)171 { 172 this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::RIGHT);173 } 174 175 void Spectator::moveUpDown( floatvalue)176 { 177 this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::UP);178 } 179 180 void Spectator::rotateYaw( floatvalue)181 { 182 this->yaw_ = value ;183 } 184 185 void Spectator::rotatePitch( floatvalue)186 { 187 this->pitch_ = value ;188 } 189 190 void Spectator::rotateRoll( floatvalue)191 { 192 this->roll_ = value ;135 // if (this->isLocallyControlled()) 136 // this->testmesh_->setVisible(false); 137 } 138 139 void Spectator::moveFrontBack(const Vector2& value) 140 { 141 this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT); 142 } 143 144 void Spectator::moveRightLeft(const Vector2& value) 145 { 146 this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT); 147 } 148 149 void Spectator::moveUpDown(const Vector2& value) 150 { 151 this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP); 152 } 153 154 void Spectator::rotateYaw(const Vector2& value) 155 { 156 this->yaw_ = value.y; 157 } 158 159 void Spectator::rotatePitch(const Vector2& value) 160 { 161 this->pitch_ = value.y; 162 } 163 164 void Spectator::rotateRoll(const Vector2& value) 165 { 166 this->roll_ = value.y; 193 167 } 194 168 … … 209 183 } 210 184 } 185 186 void Spectator::updateHUD() 187 { 188 // <hack> 189 if (this->getHUD()) 190 { 191 std::string text; 192 193 if (this->getPlayer() && this->getGametype()) 194 { 195 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning()) 196 { 197 if (!this->getPlayer()->isReadyToSpawn()) 198 text = "Press [Fire] to start the match"; 199 else 200 text = "Waiting for other players"; 201 } 202 else if (!this->getGametype()->hasEnded()) 203 { 204 if (this->getGametype()->isStartCountdownRunning()) 205 { 206 text = convertToString(ceil(this->getGametype()->getStartCountdown())); 207 } 208 else 209 { 210 text = "Press [Fire] to respawn"; 211 } 212 } 213 else 214 { 215 text = "Game has ended"; 216 } 217 } 218 else 219 { 220 return; 221 } 222 223 std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin(); 224 for (; it != this->getHUD()->getOverlays().end(); ++it) 225 { 226 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state") 227 { 228 OverlayText* overlay = dynamic_cast<OverlayText*>(it->second); 229 if (overlay) 230 overlay->setCaption(text); 231 break; 232 } 233 } 234 } 235 // </hack> 236 } 211 237 }
Note: See TracChangeset
for help on using the changeset viewer.