- Timestamp:
- Dec 20, 2005, 4:42:53 PM (19 years ago)
- Location:
- branches/christmas_branche/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/christmas_branche/src/world_entities/creatures/md2_creature.cc
r6181 r6195 115 115 EventHandler::getInstance()->grabEvents(true); 116 116 117 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;117 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bStrafeL = bStrafeR = false; 118 118 bFire = false; 119 119 xMouse = yMouse = 0; 120 mouseSensitivity = 0.00 1;121 airViscosity = 1.0;120 mouseSensitivity = 0.003; 121 airViscosity = 0.0; 122 122 cycle = 0.0; 123 123 … … 241 241 } 242 242 243 243 244 /** 244 245 * the function called for each passing timeSnap … … 251 252 252 253 253 254 255 254 // MD2Creature controlled movement 256 255 this->calculateVelocity(time); 257 258 Vector move = (velocity)*time; 259 260 //orient the velocity in the direction of the MD2Creature. 261 travelSpeed = velocity.len(); 262 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity; 263 velocity = (velocity.getNormalized())*travelSpeed; 256 Vector move = this->velocity * time; 257 this->shiftCoor (move); 264 258 265 259 //orient the MD2Creature in direction of the mouse 266 rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3); 267 if (this->getAbsDir().distance(rotQuat) > 0.001) 268 this->setAbsDir( rotQuat); 269 //this->setAbsDirSoft(mouseDir,5); 270 271 // this is the air friction (necessary for a smooth control) 272 if(velocity.len() != 0) velocity -= velocity*0.01; 273 274 //hoover effect 275 cycle += time; 276 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 277 278 //readjust 279 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0))); 280 //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0))); 281 282 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); 283 284 this->shiftCoor (move); 260 this->setAbsDir( /*rotQuat*/ mouseDir); 285 261 286 262 this->getWeaponManager()->tick(time); … … 306 282 if( this->bUp ) 307 283 { 308 //this->shiftCoor(this->getAbsDirX());309 284 accel += (this->getAbsDirX())*2; 310 311 /* Heli-Steuerung312 accel += (this->getAbsDirX()*2;313 if(314 */315 285 } 316 286 317 287 if( this->bDown ) 318 288 { 319 //this->shiftCoor((this->getAbsDirX())*-1);320 289 accel -= (this->getAbsDirX())*2; 321 290 } … … 324 293 { 325 294 this->shiftDir(Quaternion(time, Vector(0,1,0))); 326 // accel -= rightDirection;327 //velocityDir.normalize();328 //rot +=Vector(1,0,0);329 //rotVal -= .4;330 295 } 331 296 if( this->bRight /* > this->getRelCoor().z*2*/) 332 297 { 333 298 this->shiftDir(Quaternion(-time, Vector(0,1,0))); 334 335 // accel += rightDirection; 336 //velocityDir.normalize(); 337 //rot += Vector(1,0,0); 338 //rotVal += .4; 339 } 340 341 342 if( this->bRollL /* > -this->getRelCoor().z*2*/) 343 { 344 mouseDir *= Quaternion(-time, Vector(1,0,0)); 345 // accel -= rightDirection; 346 //velocityDir.normalize(); 347 //rot +=Vector(1,0,0); 348 //rotVal -= .4; 349 } 350 if( this->bRollR /* > this->getRelCoor().z*2*/) 351 { 352 mouseDir *= Quaternion(time, Vector(1,0,0)); 353 354 // accel += rightDirection; 355 //velocityDir.normalize(); 356 //rot += Vector(1,0,0); 357 //rotVal += .4; 299 } 300 301 302 if( this->bStrafeL /* > -this->getRelCoor().z*2*/) 303 { 304 accel -= this->getAbsDirZ() * 2.0f; 305 } 306 if( this->bStrafeR /* > this->getRelCoor().z*2*/) 307 { 308 accel += this->getAbsDirZ() * 2.0f; 358 309 } 359 310 if (this->bAscend ) 360 311 { 361 312 this->shiftDir(Quaternion(time, Vector(0,0,1))); 362 363 // accel += upDirection;364 //velocityDir.normalize();365 //rot += Vector(0,0,1);366 //rotVal += .4;367 313 } 368 314 if (this->bDescend ) 369 315 { 370 316 this->shiftDir(Quaternion(-time, Vector(0,0,1))); 371 372 // accel -= upDirection; 373 //velocityDir.normalize(); 374 //rot += Vector(0,0,1); 375 //rotVal -= .4; 376 } 377 378 velocity += accel; 317 } 318 319 velocity = accel * 30.0f; 379 320 //rot.normalize(); 380 321 //this->setRelDirSoft(Quaternion(rotVal, rot), 5); 381 322 } 323 382 324 383 325 /** … … 397 339 void MD2Creature::process(const Event &event) 398 340 { 399 400 401 341 if( event.type == SDLK_a) 402 this->b RollL = event.bPressed;342 this->bStrafeL = event.bPressed; 403 343 else if( event.type == SDLK_d) 404 this->b RollR = event.bPressed;344 this->bStrafeR = event.bPressed; 405 345 else if( event.type == KeyMapper::PEV_FIRE1) 406 346 this->bFire = event.bPressed; … … 417 357 { 418 358 this->xMouse = event.xRel; 419 this->yMouse = event.yRel; 420 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 421 if( xMouse*xMouse + yMouse*yMouse < 0.9) 422 this->setAbsDir(mouseDir); 359 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))); 360 // if( xMouse*xMouse < 0.9) 361 // this->setAbsDir(mouseDir); 423 362 } 424 363 } -
branches/christmas_branche/src/world_entities/creatures/md2_creature.h
r6166 r6195 58 58 bool bRollL; //!< rolling button pressed (left) 59 59 bool bRollR; //!< rolling button pressed (right) 60 bool bStrafeL; //!< strafe to the left side 61 bool bStrafeR; //!< strafe to the rith side 60 62 61 63 float xMouse; //!< mouse moved in x-Direction -
branches/christmas_branche/src/world_entities/world_entity.cc
r6191 r6195 138 138 { 139 139 PRINTF(4)("fetching MD2 file: %s\n", fileName); 140 // MD2Model* m = (MD2Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN);141 140 Model* m = new MD2Model(fileName, this->md2TextureFileName); 142 141 //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
Note: See TracChangeset
for help on using the changeset viewer.