px3Body.h

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

More...

Classes:

class

Namespaces:

namespace

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 _PX3BODY_H_
 25#define _PX3BODY_H_
 26
 27#ifndef _T3D_PHYSICS_PHYSICSBODY_H_
 28#include "T3D/physics/physicsBody.h"
 29#endif
 30#ifndef _PHYSICS_PHYSICSUSERDATA_H_
 31#include "T3D/physics/physicsUserData.h"
 32#endif
 33#ifndef _REFBASE_H_
 34#include "core/util/refBase.h"
 35#endif
 36#ifndef _MMATRIX_H_
 37#include "math/mMatrix.h"
 38#endif
 39
 40class Px3World;
 41class Px3Collision;
 42struct Px3CollisionDesc;
 43
 44namespace physx
 45{
 46   class PxRigidActor;
 47   class PxMaterial;
 48   class PxShape;
 49}
 50
 51
 52class Px3Body : public PhysicsBody
 53{
 54protected:
 55
 56   /// The physics world we are in.
 57   Px3World *mWorld;
 58
 59   /// The physics actor.
 60   physx::PxRigidActor *mActor;
 61
 62   /// The unshared local material used on all the 
 63   /// shapes on this actor.
 64   physx::PxMaterial *mMaterial;
 65
 66   /// We hold the collision reference as it contains
 67   /// allocated objects that we own and must free.
 68   StrongRefPtr<Px3Collision> mColShape;
 69
 70   /// 
 71   MatrixF mInternalTransform;
 72
 73   /// The body flags set at creation time.
 74   U32 mBodyFlags;
 75
 76   /// Is true if this body is enabled and active
 77   /// in the simulation of the scene.
 78   bool mIsEnabled;
 79   bool mIsStatic;
 80
 81   ///
 82   void _releaseActor();
 83
 84   
 85public:
 86
 87   Px3Body();
 88   virtual ~Px3Body();
 89
 90   // PhysicsObject
 91   virtual PhysicsWorld* getWorld();
 92   virtual void setTransform( const MatrixF &xfm );
 93   virtual MatrixF& getTransform( MatrixF *outMatrix );
 94   virtual Box3F getWorldBounds();
 95   virtual void setSimulationEnabled( bool enabled );
 96   virtual bool isSimulationEnabled() { return mIsEnabled; }
 97
 98   // PhysicsBody
 99   virtual bool init(   PhysicsCollision *shape, 
100                        F32 mass,
101                        U32 bodyFlags,
102                        SceneObject *obj, 
103                        PhysicsWorld *world );
104
105   virtual bool isDynamic() const;
106   virtual PhysicsCollision* getColShape();
107   virtual void setSleepThreshold( F32 linear, F32 angular );
108   virtual void setDamping( F32 linear, F32 angular );
109   virtual void getState( PhysicsState *outState );
110   virtual F32 getMass() const;
111   virtual Point3F getCMassPosition() const;
112   virtual void setLinVelocity( const Point3F &vel );
113   virtual void setAngVelocity( const Point3F &vel );
114   virtual Point3F getLinVelocity() const;
115   virtual Point3F getAngVelocity() const;
116   virtual void setSleeping( bool sleeping );
117   virtual void setMaterial(  F32 restitution,
118                              F32 friction, 
119                              F32 staticFriction );
120   virtual void applyCorrection( const MatrixF &xfm );
121   virtual void applyImpulse( const Point3F &origin, const Point3F &force );
122   virtual void applyTorque( const Point3F &torque );
123   virtual void applyForce( const Point3F &force );
124   virtual void findContact(SceneObject **contactObject, VectorF *contactNormal,
125      Vector<SceneObject*> *outOverlapObjects) const;
126   virtual void moveKinematicTo(const MatrixF &xfm);
127
128};
129
130#endif // _PX3BODY_H_
131