Changeset 7075 for code/branches/presentation3
- Timestamp:
- Jun 2, 2010, 12:27:03 AM (14 years ago)
- Location:
- code/branches/presentation3/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc
r7073 r7075 216 216 { 217 217 if (this->getControllableEntity() && (this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket")))) 218 {this->showOverlays();} 219 220 if (this->getControllableEntity() && this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))\ 221 {this->showOverlays(); 222 this->hideArrows();} 218 this->showOverlays(); 219 else if (this->getControllableEntity() && this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer"))) 220 { 221 this->showOverlays(); 222 this->hideArrows(); 223 } 223 224 224 225 this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5f-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5f-overlaySize_/2)); … … 378 379 // Try to cast the user pointer 379 380 WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny())); 380 381 381 382 // make sure we don't shoot ourselves 382 383 if( wePtr==myWe ) 383 384 continue; 384 385 385 386 if (wePtr) 386 387 { … … 592 593 } 593 594 } 594 595 596 595 596 597 597 598 598 599 -
code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.cc
r7073 r7075 60 60 this->speed_ = 200; 61 61 this->localVelocity_ = Vector3::ZERO; 62 /* 62 /* 63 63 * this->primaryThrust_ = 100; 64 64 * this->auxilaryThrust_ = 30; … … 70 70 * this->bPermanentBoost_ = false; 71 71 * this->steering_ = Vector3::ZERO; 72 */ 72 */ 73 73 74 74 … … 86 86 this->registerVariables(); 87 87 88 89 90 88 //this->weaponNode = this->cameraPositionRootNode_; 89 this->weaponNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 90 this->attachNode(this->weaponNode_); 91 91 } 92 92 93 93 FpsPlayer::~FpsPlayer() 94 94 { 95 95 if (this->isInitialized() && this->mesh_.getEntity()) 96 96 this->detachOgreObject(this->mesh_.getEntity()); 97 97 } … … 100 100 { 101 101 SUPER(FpsPlayer, XMLPort, xmlelement, mode); 102 102 103 103 XMLPortParamVariable(FpsPlayer, "primaryThrust", primaryThrust_, xmlelement, mode); 104 104 XMLPortParamVariable(FpsPlayer, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); 105 105 XMLPortParamVariable(FpsPlayer, "rotationThrust", rotationThrust_, xmlelement, mode); 106 106 XMLPortParam(FpsPlayer, "weapon", setMeshSource, getMeshSource, xmlelement, mode); 107 107 } 108 108 … … 112 112 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 113 113 registerVariable(this->rotationThrust_, VariableDirection::ToClient); 114 registerVariable(this->weaponMashName_);115 } 116 117 114 registerVariable(this->weaponMashName_, VariableDirection::ToClient); 115 } 116 117 118 118 119 119 void FpsPlayer::setConfigValues() … … 139 139 { 140 140 this->setOrientation(savedOrientation_); 141 142 thisTickBoost_=false;143 144 141 142 this->thisTickBoost_ = false; 143 144 float localSpeedSquared = this->localVelocity_.squaredLength(); 145 145 float localSpeed; 146 146 if (localSpeedSquared > 1.0) … … 151 151 this->localVelocity_.x *= localSpeed; 152 152 this->localVelocity_.z *= localSpeed; 153 Vector3 temp = this->getOrientation() * this->localVelocity_; 154 if(localVelocity_.y==jumpValue_) this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z)); 155 else this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z)); 153 Vector3 temp = this->getOrientation() * this->localVelocity_; 154 if (localVelocity_.y == jumpValue_) 155 this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z)); 156 else 157 this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z)); 156 158 this->localVelocity_.x = 0; 157 159 this->localVelocity_.y = 0; … … 161 163 { 162 164 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent); 163 164 Radian pitch=this->cameraPositionRootNode_->getOrientation().getPitch(); 165 if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) { 166 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 167 } 168 else if(pitch<Radian(-1.5707)){ 169 if(this->pitch_>0.0) { 170 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 171 } 172 else if(pitch<Radian(-1.571)){ 173 this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796)); 174 } 175 } 176 else if(pitch>Radian(1.5707)){ 177 if(this->pitch_<0.0) { 178 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 179 } 180 else if(pitch>Radian(1.571)){ 181 this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796)); 182 } 183 } 184 this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation()); 185 186 } 165 166 Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch(); 167 if (pitch < Radian(1.5707) && pitch > Radian(-1.5707)) 168 { 169 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 170 } 171 else if (pitch < Radian(-1.5707)) 172 { 173 if (this->pitch_ > 0.0) 174 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 175 else if (pitch < Radian(-1.571)) 176 this->cameraPositionRootNode_->pitch(-pitch + Radian(-1.570796)); 177 } 178 else if (pitch > Radian(1.5707)) 179 { 180 if (this->pitch_ < 0.0) 181 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 182 else if (pitch > Radian(1.571)) 183 this->cameraPositionRootNode_->pitch(-pitch + Radian(1.570796)); 184 } 185 this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation()); 186 } 187 187 188 188 this->yaw_ = this->pitch_ = this->roll_ = 0; 189 190 191 savedOrientation_=this->getOrientation();189 190 this->setAngularVelocity(0.0, 0.0, 0.0); 191 this->savedOrientation_ = this->getOrientation(); 192 192 } 193 193 194 194 SUPER(FpsPlayer, tick, dt); 195 195 } 196 196 197 197 void FpsPlayer::changedMesh() 198 198 { … … 222 222 ControllableEntity::startLocalHumanControl(); 223 223 } 224 224 225 225 void FpsPlayer::moveFrontBack(const Vector2& value) 226 226 { … … 263 263 { 264 264 } 265 266 void FpsPlayer::boost() //acctually jump 267 { 268 if(isFloor_) { 269 if(!thisTickBoost_) this->localVelocity_.y = jumpValue_; 270 //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0)); 271 thisTickBoost_=true; 272 isFloor_=false; 273 } 265 266 void FpsPlayer::boost() //acctually jump 267 { 268 if (this->isFloor_) 269 { 270 if (!this->thisTickBoost_) 271 this->localVelocity_.y = jumpValue_; 272 //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0)); 273 this->thisTickBoost_ = true; 274 this->isFloor_ = false; 275 } 274 276 } 275 277 276 278 bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 277 279 { 278 if(contactPoint.m_normalWorldOnB.y() > 0.6) isFloor_=true; 279 else isFloor_=false; 280 281 return false; 282 } 283 280 if (contactPoint.m_normalWorldOnB.y() > 0.6) 281 this->isFloor_ = true; 282 else 283 this->isFloor_ = false; 284 285 return false; 286 } 287 284 288 void FpsPlayer::addedWeaponPack(WeaponPack* wPack) 285 289 { 286 290 for (size_t i = 0; i < wPack->getNumWeapons(); ++i) 287 288 289 290 291 292 293 294 295 291 { 292 Weapon* weapon = wPack->getWeapon(i); 293 if (weapon->getWeaponSlot()) 294 { 295 weapon->getWeaponSlot()->removeWeapon(); 296 weapon->detachFromParent(); 297 weapon->attachToNode(this->weaponNode_); 298 } 299 } 296 300 } 297 301 } -
code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.h
r7073 r7075 58 58 virtual void rotatePitch(const Vector2& value); 59 59 virtual void rotateRoll(const Vector2& value); 60 61 60 61 62 62 inline void setMeshSource(const std::string& meshname) 63 63 { this->meshSrc_ = meshname; this->changedMesh(); } 64 64 inline const std::string& getMeshSource() const 65 65 { return this->meshSrc_; } 66 67 void boost();//acctually jump66 67 void boost(); //acctually jump 68 68 69 69 virtual void fire(); 70 71 bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);72 70 73 virtual void addedWeaponPack(WeaponPack* wPack); 74 71 bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 72 73 virtual void addedWeaponPack(WeaponPack* wPack); 74 75 75 protected: 76 76 virtual void setPlayer(PlayerInfo* player); … … 84 84 float auxilaryThrust_; 85 85 float rotationThrust_; 86 86 std::string weaponMashName_; 87 87 btVector3 localLinearAcceleration_; 88 88 btVector3 localAngularAcceleration_; … … 92 92 float speed_; 93 93 94 95 96 94 void changedMesh(); 95 Mesh mesh_; 96 std::string meshSrc_; 97 97 float yaw_; 98 98 float pitch_; 99 99 float roll_; 100 100 Vector3 localVelocity_; 101 102 103 104 105 101 bool isFloor_; 102 bool thisTickBoost_; 103 Quaternion savedOrientation_; 104 Ogre::SceneNode* weaponNode_; 105 }; 106 106 } 107 107 -
code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc
r7073 r7075 53 53 CreateFactory(Pawn); 54 54 55 Pawn::Pawn(BaseObject* creator) 55 Pawn::Pawn(BaseObject* creator) 56 56 : ControllableEntity(creator) 57 57 , RadarViewable(creator, static_cast<WorldEntity*>(this)) … … 363 363 { 364 364 if (this->weaponSystem_) 365 365 { 366 366 this->weaponSystem_->addWeaponPack(wPack); 367 368 367 this->addedWeaponPack(wPack); 368 } 369 369 } 370 370 … … 372 372 { 373 373 if (this->weaponSystem_) 374 374 { 375 375 if (!this->weaponSystem_->addWeaponPack(wPack)) 376 376 wPack->destroy(); 377 377 else 378 378 this->addedWeaponPack(wPack); 379 379 } 380 380 } 381 381 -
code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h
r7073 r7075 77 77 inline float getShieldHealth() 78 78 { return this->shieldHealth_; } 79 79 80 80 inline void setShieldAbsorption(float shieldAbsorption) 81 81 { this->shieldAbsorption_ = shieldAbsorption; } … … 101 101 void addWeaponPackXML(WeaponPack * wPack); 102 102 WeaponPack * getWeaponPack(unsigned int index) const; 103 104 103 104 virtual void addedWeaponPack(WeaponPack* wPack) {} 105 105 106 106 inline const WorldEntity* getWorldEntity() const … … 128 128 Vector3 getAimPosition() 129 129 { return this->aimPosition_; } 130 130 131 131 virtual const Vector3& getCarrierPosition(void) 132 132 { return this->getWorldPosition(); };
Note: See TracChangeset
for help on using the changeset viewer.