px3Player.h

Engine/source/T3D/physics/physx3/px3Player.h

More...

Classes:

Detailed Description

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