pxBody.h
Engine/source/T3D/physics/physx/pxBody.h
Classes:
class
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 _T3D_PHYSICS_PXBODY_H_ 25#define _T3D_PHYSICS_PXBODY_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 PxWorld; 41class NxActor; 42class PxCollision; 43class NxMaterial; 44 45 46class PxBody : public PhysicsBody 47{ 48protected: 49 50 /// The physics world we are in. 51 PxWorld *mWorld; 52 53 /// The physics actor. 54 NxActor *mActor; 55 56 /// The unshared local material used on all the 57 /// shapes on this actor. 58 NxMaterial *mMaterial; 59 60 /// We hold the collision reference as it contains 61 /// allocated objects that we own and must free. 62 StrongRefPtr<PxCollision> mColShape; 63 64 /// 65 MatrixF mInternalTransform; 66 67 /// The body flags set at creation time. 68 U32 mBodyFlags; 69 70 /// Is true if this body is enabled and active 71 /// in the simulation of the scene. 72 bool mIsEnabled; 73 74 /// 75 void _releaseActor(); 76 77public: 78 79 PxBody(); 80 virtual ~PxBody(); 81 82 // PhysicsObject 83 virtual PhysicsWorld* getWorld(); 84 virtual void setTransform( const MatrixF &xfm ); 85 virtual MatrixF& getTransform( MatrixF *outMatrix ); 86 virtual Box3F getWorldBounds(); 87 virtual void setSimulationEnabled( bool enabled ); 88 virtual bool isSimulationEnabled() { return mIsEnabled; } 89 90 // PhysicsBody 91 virtual bool init( PhysicsCollision *shape, 92 F32 mass, 93 U32 bodyFlags, 94 SceneObject *obj, 95 PhysicsWorld *world ); 96 virtual bool isDynamic() const; 97 virtual PhysicsCollision* getColShape(); 98 virtual void setSleepThreshold( F32 linear, F32 angular ); 99 virtual void setDamping( F32 linear, F32 angular ); 100 virtual void getState( PhysicsState *outState ); 101 virtual F32 getMass() const; 102 virtual Point3F getCMassPosition() const; 103 virtual void setLinVelocity( const Point3F &vel ); 104 virtual void setAngVelocity( const Point3F &vel ); 105 virtual Point3F getLinVelocity() const; 106 virtual Point3F getAngVelocity() const; 107 virtual void setSleeping( bool sleeping ); 108 virtual void setMaterial( F32 restitution, 109 F32 friction, 110 F32 staticFriction ); 111 virtual void applyCorrection( const MatrixF &xfm ); 112 virtual void applyImpulse( const Point3F &origin, const Point3F &force ); 113}; 114 115#endif // _T3D_PHYSICS_PXBODY_H_ 116
