Phys Material.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /******************************************************************************/
  2. const_mem_addr struct PhysMtrl // Physics Material !! must be stored in constant memory address !!
  3. {
  4. enum MODE : Byte
  5. {
  6. MODE_AVG, // average of materials values
  7. MODE_MUL, // multiplication of materials values
  8. MODE_MIN, // minimum of materials values
  9. MODE_MAX, // maximum of materials values
  10. };
  11. PhysMtrl& create(); // create material
  12. #if EE_PRIVATE
  13. void reset(); // set default values
  14. #endif
  15. // get / set
  16. Flt bounciness ()C; PhysMtrl& bounciness ( Flt x ); // get/set bounciness , 0..1 , default=0
  17. Flt frictionStatic ()C; PhysMtrl& frictionStatic ( Flt x ); // get/set static friction , 0..Inf , default=0
  18. Flt frictionDynamic ()C; PhysMtrl& frictionDynamic ( Flt x ); // get/set dynamic friction , 0..Inf , default=0
  19. Flt frictionStaticA ()C; PhysMtrl& frictionStaticA ( Flt x ); // get/set static anisotropic friction , 0..Inf , default=0
  20. Flt frictionDynamicA()C; PhysMtrl& frictionDynamicA( Flt x ); // get/set dynamic anisotropic friction , 0..Inf , default=0
  21. Flt density ()C; PhysMtrl& density ( Flt x ); // get/set density , 0..Inf , default=1
  22. Flt damping ()C; PhysMtrl& damping ( Flt x ); // get/set damping , 0..Inf , default=0.05
  23. Flt adamping ()C; PhysMtrl& adamping ( Flt x ); // get/set angular damping , 0..Inf , default=0.05
  24. Bool anisotropic ()C; PhysMtrl& anisotropic ( Bool on ); // get/set enable anisotropic friction , true/false , default=false
  25. Vec anisotropicDir ()C; PhysMtrl& anisotropicDir (C Vec &dir ); // get/set anisotropic friction direction, normalized vector
  26. MODE bouncinessMode ()C; PhysMtrl& bouncinessMode ( MODE mode); // get/set bounciness mode , MODE , default=MODE_AVG
  27. MODE frictionMode ()C; PhysMtrl& frictionMode ( MODE mode); // get/set friction mode , MODE , default=MODE_AVG
  28. // io
  29. Bool save(C Str &name)C; // save to file, false on fail
  30. Bool load(C Str &name) ; // load from file, false on fail
  31. Bool save( File &f )C; // save to file, false on fail
  32. Bool load( File &f ) ; // load from file, false on fail
  33. void del();
  34. ~PhysMtrl() {del();}
  35. PhysMtrl();
  36. #if !EE_PRIVATE
  37. private:
  38. #endif
  39. Flt _bounciness, _friction_static, _friction_dynamic, _density, _damping, _adamping;
  40. MODE _bounciness_mode, _friction_mode;
  41. #if EE_PRIVATE
  42. PHYS_API(PxMaterial, void) *_m;
  43. #else
  44. Ptr _m;
  45. #endif
  46. NO_COPY_CONSTRUCTOR(PhysMtrl);
  47. };
  48. /******************************************************************************/
  49. extern Cache<PhysMtrl> PhysMtrls; // Physics Material Cache
  50. /******************************************************************************/