Character Ragdoll.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. namespace EE{
  4. namespace Game{
  5. /******************************************************************************/
  6. void Chr::ragdollValidate()
  7. {
  8. if(!ragdoll.is()) // if ragdoll hasn't yet been created
  9. {
  10. ragdoll.create(skel ) // create from 'AnimatedSkeleton'
  11. .obj (this ) // set Game.Chr object
  12. .ignore(ctrl.actor); // ignore collisions with the character controller
  13. }
  14. }
  15. /******************************************************************************/
  16. void Chr::ragdollEnable()
  17. {
  18. if(ragdoll_mode!=RAGDOLL_FULL)
  19. {
  20. ragdollValidate(); // make sure the ragdoll is created
  21. ctrl.actor.active (false); // disable character controller completely
  22. ragdoll .active (true ) // enable ragdoll actors
  23. .gravity (true ) // gravity should be enabled for full ragdoll mode
  24. .fromSkel(skel, ctrl.actor.vel()); // set ragdoll initial pose
  25. ragdoll_mode=RAGDOLL_FULL;
  26. }
  27. }
  28. /******************************************************************************/
  29. void Chr::ragdollDisable()
  30. {
  31. if(ragdoll_mode==RAGDOLL_FULL)
  32. {
  33. ragdoll .active(false);
  34. ctrl.actor.active(true );
  35. ragdoll_mode=RAGDOLL_NONE;
  36. }
  37. }
  38. /******************************************************************************/
  39. Bool Chr::ragdollBlend()
  40. {
  41. if(ragdoll_mode!=RAGDOLL_FULL)
  42. {
  43. ragdollValidate(); // make sure the ragdoll is created
  44. ragdoll.active (true ) // enable ragdoll collisions
  45. .gravity (false) // disable gravity for hit-simulation effects because they look better this way
  46. .fromSkel(skel, ctrl.actor.vel()); // set ragdoll initial pose
  47. ragdoll_time=0;
  48. ragdoll_mode=RAGDOLL_PART;
  49. return true; // ragdoll set successfully
  50. }
  51. return false; // can't set ragdoll mode
  52. }
  53. /******************************************************************************/
  54. }}
  55. /******************************************************************************/