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