px3Player.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _PX3PLAYER_H
  23. #define _PX3PLAYER_H
  24. #ifndef _PHYSX3_H_
  25. #include "T3D/physics/physx3/px3.h"
  26. #endif
  27. #ifndef _T3D_PHYSICS_PHYSICSPLAYER_H_
  28. #include "T3D/physics/physicsPlayer.h"
  29. #endif
  30. #ifndef _T3D_PHYSICSCOMMON_H_
  31. #include "T3D/physics/physicsCommon.h"
  32. #endif
  33. class Px3World;
  34. class Px3Player : public PhysicsPlayer, public physx::PxUserControllerHitReport
  35. {
  36. protected:
  37. physx::PxController *mController;
  38. physx::PxCapsuleGeometry mGeometry;
  39. F32 mSkinWidth;
  40. Px3World *mWorld;
  41. SceneObject *mObject;
  42. /// Used to get collision info out of the
  43. /// PxUserControllerHitReport callbacks.
  44. CollisionList *mCollisionList;
  45. ///
  46. F32 mOriginOffset;
  47. ///
  48. F32 mStepHeight;
  49. U32 mElapsed;
  50. ///
  51. void _releaseController();
  52. virtual void onShapeHit( const physx::PxControllerShapeHit &hit );
  53. virtual void onControllerHit( const physx::PxControllersHit &hit );
  54. virtual void onObstacleHit(const physx::PxControllerObstacleHit &){}
  55. void _findContact( SceneObject **contactObject, VectorF *contactNormal ) const;
  56. void _onPhysicsReset( PhysicsResetEvent reset );
  57. void _onStaticChanged();
  58. public:
  59. Px3Player();
  60. virtual ~Px3Player();
  61. // PhysicsObject
  62. virtual PhysicsWorld* getWorld();
  63. virtual void setTransform( const MatrixF &transform );
  64. virtual MatrixF& getTransform( MatrixF *outMatrix );
  65. virtual void setScale( const Point3F &scale );
  66. virtual Box3F getWorldBounds();
  67. virtual void setSimulationEnabled( bool enabled ) {}
  68. virtual bool isSimulationEnabled() { return true; }
  69. // PhysicsPlayer
  70. virtual void init( const char *type,
  71. const Point3F &size,
  72. F32 runSurfaceCos,
  73. F32 stepHeight,
  74. SceneObject *obj,
  75. PhysicsWorld *world );
  76. virtual Point3F move( const VectorF &displacement, CollisionList &outCol );
  77. virtual void findContact( SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects ) const;
  78. virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const;
  79. virtual void setSpacials( const Point3F &nPos, const Point3F &nSize );
  80. virtual void enableCollision();
  81. virtual void disableCollision();
  82. };
  83. #endif // _PX3PLAYER_H_