Changeset 9110 in orxonox.OLD for trunk/src/world_entities/creatures
- Timestamp:
- Jul 4, 2006, 11:18:41 AM (18 years ago)
- Location:
- trunk/src/world_entities/creatures
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/creatures/fps_player.cc
r9003 r9110 21 21 22 22 #include "src/lib/util/loading/factory.h" 23 24 #include "md2/md2Model.h" 23 25 24 26 #include "weapons/weapon_manager.h" … … 28 30 #include "weapons/fps_sniper_rifle.h" 29 31 32 #include "aabb.h" 33 30 34 #include "key_mapper.h" 31 35 32 36 #include "debug.h" 33 37 38 #include "shared_network_data.h" 34 39 35 40 … … 92 97 93 98 this->fallVelocity = 0.0f; 99 this->jumpForce = 0.0f; 94 100 95 101 this->cameraNode.setParent(this); … … 123 129 124 130 this->getWeaponManager().setSlotCount(2); 125 this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));126 131 // this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_2, Vector(0,1,0))); 127 132 this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 133 this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0))); 134 this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1)); 128 135 this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0)); 129 this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0))); 136 130 137 131 138 this->getWeaponManager().setParentNode(&this->cameraNode); … … 141 148 registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) ); 142 149 registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) ); 143 // registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) ); 144 145 146 // collision reaction registration 147 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY); 150 registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) ); 151 registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) ); 148 152 } 149 153 … … 189 193 190 194 191 State::getCameraNode()->setRelCoor(0,0,0); 192 State::getCameraTargetNode()->setRelCoor(10,0,0); 195 AABB* box = this->getModelAABB(); 196 if( box != NULL) 197 { 198 State::getCameraNode()->setRelCoor(0, box->halfLength[1] * 2.0f, 0); 199 State::getCameraTargetNode()->setRelCoor(10, box->halfLength[1] * 2.0f, 0); 200 201 this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * 2.0f - 0.7, 1.1)); 202 this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * 2.0f, 0.0)); 203 } 193 204 } 194 205 … … 207 218 void FPSPlayer::tick (float time) 208 219 { 209 220 210 221 if( this->bPosBut) 211 222 { 212 223 this->bPosBut = false; 213 printf(" prisoner:walkTo( %f,height, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());214 } 215 224 printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ()); 225 } 226 216 227 Playable::tick( time ); 217 228 218 if( ( xMouse != 0 || yMouse != 0 ) /*&& this->getOwner() == this->getHostID() */)229 if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) ) 219 230 { 220 231 xMouse *= time ; … … 230 241 attitude = -1.15; 231 242 232 this->setAbsDir(Quaternion(heading, Vector(0,1,0)));233 this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));234 235 243 xMouse = yMouse = 0; 236 244 } 237 245 238 // this->setAbsDir( this->mouseDir ); 246 this->setAbsDir(Quaternion(heading, Vector(0,1,0))); 247 this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) )); 239 248 240 249 Vector velocity; … … 262 271 263 272 velocity *= 100; 273 274 if( this->bJump && likely(this->getModel(0) != NULL)) 275 { 276 if( this->jumpForce < 1.0f) 277 { 278 this->jumpForce = 300.0f; 279 280 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP) 281 ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP); 282 } 283 } 284 else if(velocity.len() != 0.0f) 285 { 286 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN) 287 ((InteractiveModel*)this->getModel(0))->setAnimation(RUN); 288 } 289 else 290 { 291 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND) 292 ((InteractiveModel*)this->getModel(0))->setAnimation(STAND); 293 } 294 295 296 velocity.y += this->jumpForce; 297 if( this->jumpForce > 1.0f) 298 this->jumpForce *= 0.9f; 264 299 265 300 … … 287 322 { 288 323 ((InteractiveModel*)this->getModel(0))->tick(time); 289 // 290 // // handle animations differently 291 // if( this->bJump && likely(this->getModel(0) != NULL)) 292 // { 293 // ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP); 294 // } 324 325 // handle animations differently 326 327 328 329 330 295 331 // else if( this->bFire && likely(this->getModel(0) != NULL)) 296 332 // { … … 347 383 } 348 384 else if( event.type == KeyMapper::PEV_JUMP) 385 this->bJump = event.bPressed; 349 386 this->bPosBut = event.bPressed; 350 387 } -
trunk/src/world_entities/creatures/fps_player.h
r9003 r9110 54 54 55 55 float fallVelocity; //!< velocity for falling down 56 float jumpForce; //!< the jump force 56 57 }; 57 58
Note: See TracChangeset
for help on using the changeset viewer.