40 #ifndef _rigidproxy_cpp
41 #define _rigidproxy_cpp
43 #include "Physics/rigidproxy.h"
44 #include "Physics/collisionshape.h"
45 #include "Physics/physicsmanager.h"
46 #include "Physics/collisionshapemanager.h"
49 #include "stringtool.h"
51 #include "Internal/motionstate.h.cpp"
53 #include <btBulletDynamicsCommon.h>
54 #include <BulletSoftBody/btSoftRigidDynamicsWorld.h>
62 PhysicsRigidBody(NULL)
69 PhysicsRigidBody(NULL)
77 PhysicsRigidBody(NULL)
95 this->
PhysicsRigidBody->setMotionState(
new Internal::MultiMotionState(
this ) );
96 this->
PhysicsRigidBody->setUserPointer( static_cast<CollidableProxy*>(
this ) );
98 this->
PhysicsRigidBody->setCollisionFlags( btCollisionObject::CF_STATIC_OBJECT );
100 this->
CollisionMask = Physics::CF_AllFilter & ~Physics::CF_StaticFilter;
113 return Mezzanine::PT_Physics_RigidProxy;
138 if( Shape != NULL ) {
144 btVector3 Inertia(0,0,0);
329 if( !PropertiesNode.
Empty() ) {
331 Real LinDam = 0, AngDam = 0;
334 if( !CurrAttrib.
Empty() )
337 CurrAttrib = PropertiesNode.
GetAttribute(
"LinearDamping");
338 if( !CurrAttrib.
Empty() )
339 LinDam = CurrAttrib.
AsReal();
341 CurrAttrib = PropertiesNode.
GetAttribute(
"AngularDamping");
342 if( !CurrAttrib.
Empty() )
343 AngDam = CurrAttrib.
AsReal();
349 if( !LinVelNode.
Empty() ) {
355 if( !AngVelNode.
Empty() ) {
361 if( !LinFactNode.
Empty() ) {
367 if( !AngFactNode.
Empty() ) {
373 if( !ForceNode.
Empty() ) {
379 if( !TorqueNode.
Empty() ) {
385 if( !GravityNode.
Empty() ) {
401 {
return "RigidProxy"; }
This is the base class for all collision shapes.
virtual UInt32 GetNumSyncObjects() const
Gets the number of WorldProxies being sync'd to this RigidProxy.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
virtual void ApplyForce(const Vector3 &Force)
Push/Apply force to an proxy.
RigidProxy(const UInt32 ID, const Real Mass, PhysicsManager *Creator)
Class Constructor.
virtual Vector3 GetAngularVelocity() const
Gets the Angular Velocity of this proxy.
virtual void RemoveAllSyncObjects()
Removes all WorldProxies being sync'd to this RigidProxy.
virtual void SetMass(const Real Mass)
Change the mass of the proxy.
virtual Vector3 GetAppliedForce() const
Get the total Force currently being applied to this proxy.
Indicates the class is a StaticMeshCollisionShape.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
PhysicsManager * Manager
This is a pointer to the physics manager that created and owns this proxy.
Thrown when the requested identity could not be found.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
virtual ~RigidProxy()
Class Destructor.
virtual void SetLinearMovementFactor(const Vector3 &Factor)
Restricts movement on the axis or axies of your choice.
virtual Mezzanine::ProxyType GetProxyType() const
Accessor for the type of proxy.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
virtual Vector3 GetGravity() const
Gets the gravity being applied to this proxy.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
virtual Vector3 GetAppliedTorque() const
Get the total Torque currently being applied to this proxy.
virtual btCollisionShape * _GetInternalShape() const
Gets the internal shape pointer this collision shape is based on.
virtual void SetLinearVelocity(const Vector3 &LinVel)
Sets the Linear Velocity of this proxy.
Any global enumerations shared between multiple classes is to be declared here.
virtual void SetAngularVelocity(const Vector3 &AngVel)
Sets the Angular Velocity of this proxy.
bool Empty() const
Is this storing anything at all?
virtual void AddSyncObject(TransformableObject *ToBeAdded)
Adds a TransformableObject that will force it's transform to sync with this RigidProxy.
virtual void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
Vector3 GetWorldGravity()
Gets the gravity.
virtual void AddToWorld()
Performs all the necessary task to ensure this object is connected to it's respective world and ready...
float Real
A Datatype used to represent a real floating point number.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual void SetCollisionShape(CollisionShape *Shape)
Sets the collision shape to be used.
static CollisionShapeManager * GetSingletonPtr()
Fetches a pointer to the singleton.
Int16 CollisionGroup
The classifications pertaining to this object in regards to collisions.
btVector3 GetBulletVector3() const
Gets a Bullet vector3.
A light-weight handle for manipulating nodes in DOM tree.
btRigidBody * PhysicsRigidBody
RigidBody proxy used by the internal physics.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
ProxyType
Used by all World proxies to describe what their derived types are.
uint32_t UInt32
An 32-bit unsigned integer.
bool Empty() const
Is this storing anything at all?
virtual Real GetAngularDamping() const
Get the Angular damping.
virtual void SetAngularMovementFactor(const Vector3 &Factor)
Restricts movement on the axis or axes of your choice.
virtual btRigidBody * _GetPhysicsObject() const
Accessor for the internal rigid body physics proxy.
virtual btCollisionObject * _GetBasePhysicsObject() const
Accessor for the internal physics object.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
virtual void CreateRigidObject(const Real Mass)
Used to create the physics representation of the rigid body.
virtual void RemoveSyncObject(TransformableObject *ToBeRemoved)
Removes a proxy being sync'd, so it will no longer match it's transform with this RigidProxy...
static String GetSerializableName()
Get the name of the the XML tag the proxy class will leave behind as its instances are serialized...
btSoftRigidDynamicsWorld * _GetPhysicsWorldPointer()
This returns a pointer to the bullet physics world. This is for internal use only.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
virtual Vector3 GetLinearVelocity() const
Gets the Linear Velocity of this proxy.
This is a proxy from which physics objects that can collide with each other are handled.
This is simply a place for storing all the Physics Related functions.
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this WorldProxy.
This is used to represent a point in space, or a vector through space.
The bulk of the engine components go in this namspace.
virtual void RemoveFromWorld()
Unhooks this proxy from it's respective world.
virtual Vector3 GetAngularMovementFactor() const
Gets the current angular factors being applied to this actor.
virtual Boole IsInWorld() const
Gets whether or not this object is inside of it's world.
Int16 CollisionMask
Stores the kind of World Objects that can collide with each other.
virtual Real GetLinearDamping() const
Get the linear damping.
virtual void SetGravity(const Vector3 &Gravity)
Sets the gravity for only this proxy.
virtual void SetCollisionShape(CollisionShape *Shape)
Sets the collision shape to be used.
virtual void SetDamping(const Real LinDamping, const Real AngDamping)
Sets the Damping for this proxy.
virtual TransformableObject * GetSyncObject(const UInt32 Index) const
Gets a TransformableObject being sync'd to this RigidProxy by it's index.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
virtual void ApplyTorque(const Vector3 &Torque)
Spin/Apply torque to an proxy.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
virtual CollisionShape::ShapeType GetType() const =0
Gets the type of Collision shape this is.
std::string String
A datatype used to a series of characters.
virtual Vector3 GetLinearMovementFactor() const
Gets the current linear factors being applied to this actor.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual Real GetMass() const
Get the total Mass of the proxy.