pxPlayer.h

Engine/source/T3D/physics/physx/pxPlayer.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 _PXPLAYER_H
 25#define _PXPLAYER_H
 26
 27#ifndef _PHYSX_H_
 28#include "T3D/physics/physX/px.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
 37
 38class PxWorld;
 39class NxController;
 40
 41
 42class PxPlayer : public PhysicsPlayer, public NxUserControllerHitReport
 43{
 44protected:
 45
 46   NxController *mController;
 47
 48   F32 mSkinWidth;
 49
 50   PxWorld *mWorld;
 51
 52   SceneObject *mObject;
 53
 54   /// Used to get collision info out of the
 55   /// NxUserControllerHitReport callbacks.
 56   CollisionList *mCollisionList;
 57
 58   ///
 59   F32 mOriginOffset;
 60
 61   ///
 62   F32 mStepHeight;
 63
 64   ///
 65   void _releaseController();
 66
 67   // NxUserControllerHitReport
 68   virtual NxControllerAction onShapeHit( const NxControllerShapeHit& hit );
 69   virtual NxControllerAction onControllerHit( const NxControllersHit& hit );
 70
 71   void _findContact( SceneObject **contactObject, VectorF *contactNormal ) const;
 72
 73   void _onPhysicsReset( PhysicsResetEvent reset );
 74
 75   void _onStaticChanged();
 76
 77public:
 78   
 79   PxPlayer();
 80   virtual ~PxPlayer(); 
 81
 82   // PhysicsObject
 83   virtual PhysicsWorld* getWorld();
 84   virtual void setTransform( const MatrixF &transform );
 85   virtual MatrixF& getTransform( MatrixF *outMatrix );
 86   virtual void setScale( const Point3F &scale );
 87   virtual Box3F getWorldBounds();
 88   virtual void setSimulationEnabled( bool enabled ) {}
 89   virtual bool isSimulationEnabled() { return true; }
 90
 91   // PhysicsPlayer
 92   virtual void init(   const char *type, 
 93                        const Point3F &size,
 94                        F32 runSurfaceCos,
 95                        F32 stepHeight,
 96                        SceneObject *obj, 
 97                        PhysicsWorld *world );
 98   virtual Point3F move( const VectorF &displacement, CollisionList &outCol );
 99   virtual void findContact( SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects ) const;
100   virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const { return true; }
101   virtual void setSpacials( const Point3F &nPos, const Point3F &nSize ) {}
102   virtual void enableCollision();
103   virtual void disableCollision();
104};
105
106
107#endif // _PXPLAYER_H
108