- Timestamp:
- Jun 1, 2010, 2:42:24 PM (14 years ago)
- Location:
- code/branches/fps/src/orxonox/worldentities/pawns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc
r7052 r7070 51 51 namespace orxonox 52 52 { 53 const float orientationGain = 100;54 const float jump value= 300;53 const float orientationGain_ = 100; 54 const float jumpValue_ = 300; 55 55 CreateFactory(FpsPlayer); 56 56 … … 86 86 this->registerVariables(); 87 87 88 this->weaponNode = this->cameraPositionRootNode_; 89 //this->weaponNode = this->getScene()->getRootSceneNode()->createChildSceneNode(); 90 //this->weaponNode = this->cameraPositionRootNode_->createChildSceneNode(); 91 this->attachNode(this->weaponNode); 88 //this->weaponNode = this->cameraPositionRootNode_; 89 this->weaponNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 90 this->attachNode(this->weaponNode_); 92 91 } 93 92 … … 113 112 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 114 113 registerVariable(this->rotationThrust_, VariableDirection::ToClient); 115 registerVariable(this->weapon mashname);114 registerVariable(this->weaponMashName_); 116 115 } 117 116 … … 141 140 this->setOrientation(savedOrientation_); 142 141 143 this tickboost=false;142 thisTickBoost_=false; 144 143 145 144 float localSpeedSquared = this->localVelocity_.squaredLength(); … … 153 152 this->localVelocity_.z *= localSpeed; 154 153 Vector3 temp = this->getOrientation() * this->localVelocity_; 155 if(localVelocity_.y==jump value) this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z));154 if(localVelocity_.y==jumpValue_) this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z)); 156 155 else this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z)); 157 156 this->localVelocity_.x = 0; … … 165 164 Radian pitch=this->cameraPositionRootNode_->getOrientation().getPitch(); 166 165 if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) { 167 //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));168 166 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 169 167 } 170 168 else if(pitch<Radian(-1.5707)){ 171 169 if(this->pitch_>0.0) { 172 //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));173 170 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 174 171 } 175 172 else if(pitch<Radian(-1.571)){ 176 //this->weaponNode->pitch(-pitch+Radian(-1.570796));177 173 this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796)); 178 174 } … … 180 176 else if(pitch>Radian(1.5707)){ 181 177 if(this->pitch_<0.0) { 182 //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));183 178 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 184 179 } 185 180 else if(pitch>Radian(1.571)){ 186 //this->weaponNode->pitch(-pitch+Radian(1.570796));187 181 this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796)); 188 182 } 189 183 } 190 //this->weaponNode->setOrientation(this->cameraPositionRootNode_->getOrientation());184 this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation()); 191 185 192 186 } … … 194 188 this->yaw_ = this->pitch_ = this->roll_ = 0; 195 189 196 //Quaternion q=this->getOrientation();197 //if( q.y<0.99 ) this->setOrientation(q.w, q.x, 1.0, q.z);198 190 this->setAngularVelocity(0.0, 0.0, 0.0); 199 191 savedOrientation_=this->getOrientation(); … … 208 200 { 209 201 if (this->mesh_.getEntity()) 210 this->weaponNode ->detachObject(this->mesh_.getEntity());202 this->weaponNode_->detachObject(this->mesh_.getEntity()); 211 203 212 204 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); … … 214 206 if (this->mesh_.getEntity()) 215 207 { 216 this->weaponNode ->attachObject(this->mesh_.getEntity());208 this->weaponNode_->attachObject(this->mesh_.getEntity()); 217 209 } 218 210 } … … 274 266 void FpsPlayer::boost() //acctually jump 275 267 { 276 if(is floor) {277 if(!this tickboost) this->localVelocity_.y = jumpvalue;268 if(isFloor_) { 269 if(!thisTickBoost_) this->localVelocity_.y = jumpValue_; 278 270 //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0)); 279 this tickboost=true;280 is floor=false;271 thisTickBoost_=true; 272 isFloor_=false; 281 273 } 282 274 } … … 284 276 bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 285 277 { 286 if(contactPoint.m_normalWorldOnB.y() > 0.6) is floor=true;287 else is floor=false;278 if(contactPoint.m_normalWorldOnB.y() > 0.6) isFloor_=true; 279 else isFloor_=false; 288 280 289 281 return false; … … 299 291 weapon->getWeaponSlot()->removeWeapon(); 300 292 weapon->detachFromParent(); 301 weapon->attachToNode(this->weaponNode );293 weapon->attachToNode(this->weaponNode_); 302 294 } 303 295 } -
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h
r7052 r7070 84 84 float auxilaryThrust_; 85 85 float rotationThrust_; 86 std::string weapon mashname;86 std::string weaponMashName_; 87 87 btVector3 localLinearAcceleration_; 88 88 btVector3 localAngularAcceleration_; … … 99 99 float roll_; 100 100 Vector3 localVelocity_; 101 bool is floor;102 bool this tickboost;101 bool isFloor_; 102 bool thisTickBoost_; 103 103 Quaternion savedOrientation_; 104 Ogre::SceneNode* weaponNode; 105 Ogre::Camera* camera_; 106 }; 104 Ogre::SceneNode* weaponNode_; 105 }; 107 106 } 108 107
Note: See TracChangeset
for help on using the changeset viewer.