- Timestamp:
- May 31, 2010, 3:40:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc
r6908 r7052 33 33 #include <LinearMath/btVector3.h> 34 34 #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> 35 35 #include <OgreSceneManager.h> 36 #include <OgreSceneNode.h> 37 #include <OgreEntity.h> 36 38 37 39 #include "core/CoreIncludes.h" … … 40 42 #include "core/XMLPort.h" 41 43 #include "items/Engine.h" 44 #include "Scene.h" 45 #include "weaponsystem/WeaponPack.h" 46 #include "weaponsystem/WeaponSlot.h" 47 #include "weaponsystem/Weapon.h" 42 48 43 49 #include <cmath> … … 80 86 this->registerVariables(); 81 87 88 this->weaponNode = this->cameraPositionRootNode_; 89 //this->weaponNode = this->getScene()->getRootSceneNode()->createChildSceneNode(); 90 //this->weaponNode = this->cameraPositionRootNode_->createChildSceneNode(); 91 this->attachNode(this->weaponNode); 82 92 } 83 93 84 94 FpsPlayer::~FpsPlayer() 85 95 { 96 if (this->isInitialized() && this->mesh_.getEntity()) 97 this->detachOgreObject(this->mesh_.getEntity()); 86 98 } 87 99 … … 93 105 XMLPortParamVariable(FpsPlayer, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); 94 106 XMLPortParamVariable(FpsPlayer, "rotationThrust", rotationThrust_, xmlelement, mode); 107 XMLPortParam(FpsPlayer, "weapon", setMeshSource, getMeshSource, xmlelement, mode); 95 108 } 96 109 … … 100 113 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 101 114 registerVariable(this->rotationThrust_, VariableDirection::ToClient); 102 } 115 registerVariable(this->weaponmashname); 116 } 117 118 103 119 104 120 void FpsPlayer::setConfigValues() … … 145 161 if (!this->isInMouseLook()) 146 162 { 147 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent);148 //this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 163 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent); 164 149 165 Radian pitch=this->cameraPositionRootNode_->getOrientation().getPitch(); 150 if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 166 if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) { 167 //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 168 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 169 } 151 170 else if(pitch<Radian(-1.5707)){ 152 if(this->pitch_>0.0) this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 153 else if(pitch<Radian(-1.571)) this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796)); 171 if(this->pitch_>0.0) { 172 //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 173 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 174 } 175 else if(pitch<Radian(-1.571)){ 176 //this->weaponNode->pitch(-pitch+Radian(-1.570796)); 177 this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796)); 178 } 154 179 } 155 180 else if(pitch>Radian(1.5707)){ 156 if(this->pitch_<0.0) this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 157 else if(pitch>Radian(1.571)) this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796)); 181 if(this->pitch_<0.0) { 182 //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 183 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 184 } 185 else if(pitch>Radian(1.571)){ 186 //this->weaponNode->pitch(-pitch+Radian(1.570796)); 187 this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796)); 188 } 158 189 } 159 190 //this->weaponNode->setOrientation(this->cameraPositionRootNode_->getOrientation()); 160 191 161 // this->roll(Radian(this->roll_ * this->getMouseLookSpeed())); 162 } 192 } 163 193 164 194 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 172 202 SUPER(FpsPlayer, tick, dt); 173 203 } 204 205 void FpsPlayer::changedMesh() 206 { 207 if (GameMode::showsGraphics()) 208 { 209 if (this->mesh_.getEntity()) 210 this->weaponNode->detachObject(this->mesh_.getEntity()); 211 212 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 213 214 if (this->mesh_.getEntity()) 215 { 216 this->weaponNode->attachObject(this->mesh_.getEntity()); 217 } 218 } 219 } 174 220 175 221 void FpsPlayer::setPlayer(PlayerInfo* player) … … 244 290 } 245 291 292 void FpsPlayer::addedWeaponPack(WeaponPack* wPack) 293 { 294 for (size_t i = 0; i < wPack->getNumWeapons(); ++i) 295 { 296 Weapon* weapon = wPack->getWeapon(i); 297 if (weapon->getWeaponSlot()) 298 { 299 weapon->getWeaponSlot()->removeWeapon(); 300 weapon->detachFromParent(); 301 weapon->attachToNode(this->weaponNode); 302 } 303 } 304 } 246 305 }
Note: See TracChangeset
for help on using the changeset viewer.