40 #ifndef _physicssliderconstraint_cpp
41 #define _physicssliderconstraint_cpp
43 #include "Physics/sliderconstraint.h"
44 #include "Physics/rigidproxy.h"
46 #include "stringtool.h"
49 #include <btBulletDynamicsCommon.h>
78 if( this->
Slider == NULL ) {
79 if( RigidA && RigidB ) {
90 if( this->
Slider != NULL ) {
111 {
return this->
Slider->getFrameOffsetA(); }
114 {
return this->
Slider->getFrameOffsetB(); }
123 {
return Vector3(this->
Slider->getFrameOffsetA().getOrigin()); }
126 {
return Vector3(this->
Slider->getFrameOffsetB().getOrigin()); }
144 { this->
Slider->setUseFrameOffset(FrameOffset); }
147 {
return this->
Slider->getUseFrameOffset(); }
150 { this->
Slider->setUpperLinLimit(UpperLimit); }
153 {
return this->
Slider->getUpperLinLimit(); }
156 { this->
Slider->setUpperAngLimit(UpperLimit); }
159 {
return this->
Slider->getUpperAngLimit(); }
162 { this->
Slider->setLowerLinLimit(LowerLimit); }
165 {
return this->
Slider->getLowerLinLimit(); }
168 { this->
Slider->setLowerAngLimit(LowerLimit); }
171 {
return this->
Slider->getLowerAngLimit(); }
174 { this->
Slider->setPoweredLinMotor(OnOff); }
177 {
return this->
Slider->getPoweredLinMotor(); }
180 { this->
Slider->setPoweredAngMotor(OnOff); }
183 {
return this->
Slider->getPoweredAngMotor(); }
186 { this->
Slider->setTargetLinMotorVelocity(TargetLinMotorVelocity); }
189 {
return this->
Slider->getTargetLinMotorVelocity(); }
192 { this->
Slider->setTargetAngMotorVelocity(TargetAngMotorVelocity); }
195 {
return this->
Slider->getTargetAngMotorVelocity(); }
198 { this->
Slider->setMaxLinMotorForce(MaxLinMotorForce); }
201 {
return this->
Slider->getMaxLinMotorForce(); }
204 { this->
Slider->setMaxAngMotorForce(MaxAngMotorForce); }
207 {
return this->
Slider->getMaxAngMotorForce(); }
210 { this->
Slider->setSoftnessLimLin(SoftnessLimLin); }
213 {
return this->
Slider->getSoftnessLimLin(); }
216 { this->
Slider->setSoftnessLimAng(SoftnessLimAng); }
219 {
return this->
Slider->getSoftnessLimAng(); }
222 { this->
Slider->setSoftnessOrthoLin(SoftnessOrthoLin); }
225 {
return this->
Slider->getSoftnessOrthoLin(); }
228 { this->
Slider->setSoftnessOrthoAng(SoftnessOrthoAng); }
231 {
return this->
Slider->getSoftnessOrthoAng(); }
237 { this->
Slider->setSoftnessDirLin(SoftnessDirLin); }
240 {
return this->
Slider->getSoftnessDirLin(); }
243 { this->
Slider->setSoftnessDirAng(SoftnessDirAng); }
246 {
return this->
Slider->getSoftnessDirAng(); }
249 { this->
Slider->setDampingDirLin(DampingDirLin); }
252 {
return this->
Slider->getDampingDirLin(); }
255 { this->
Slider->setDampingDirAng(DampingDirAng); }
258 {
return this->
Slider->getDampingDirAng(); }
261 { this->
Slider->setDampingLimLin(DampingLimLin); }
264 {
return this->
Slider->getDampingLimLin(); }
267 { this->
Slider->setDampingLimAng(DampingLimAng); }
270 {
return this->
Slider->getDampingLimAng(); }
273 { this->
Slider->setDampingOrthoLin(DampingOrthoLin); }
276 {
return this->
Slider->getDampingOrthoLin(); }
279 { this->
Slider->setDampingOrthoAng(DampingOrthoAng); }
282 {
return this->
Slider->getDampingOrthoAng(); }
285 { this->
Slider->setRestitutionDirLin(RestitutionDirLin); }
288 {
return this->
Slider->getRestitutionDirLin(); }
291 { this->
Slider->setRestitutionDirAng(RestitutionDirAng); }
294 {
return this->
Slider->getRestitutionDirAng(); }
297 { this->
Slider->setRestitutionLimLin(RestitutionLimLin); }
300 {
return this->
Slider->getRestitutionLimLin(); }
303 { this->
Slider->setRestitutionLimAng(RestitutionLimAng); }
306 {
return this->
Slider->getRestitutionLimAng(); }
309 { this->
Slider->setRestitutionOrthoLin(RestitutionOrthoLin); }
312 {
return this->
Slider->getRestitutionOrthoLin(); }
315 { this->
Slider->setRestitutionOrthoAng(RestitutionOrthoAng); }
318 {
return this->
Slider->getRestitutionOrthoAng(); }
326 if( 0 <= Axis && 5 >= Axis ) {
327 Results.push_back(Con_Stop_ERP);
329 Results.push_back(Con_Stop_CFM);
337 Results.push_back(0);
338 Results.push_back(1);
339 Results.push_back(2);
346 Results.push_back(3);
347 Results.push_back(4);
348 Results.push_back(5);
358 if( Con_Stop_ERP == Param )
360 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_ERP_LIMLIN )
return true;
361 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_ERP_ORTLIN )
return true;
362 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_ERP_LIMANG )
return true;
363 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_ERP_ORTANG )
return true;
365 else if( Con_Stop_CFM == Param )
367 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_CFM_DIRLIN )
return true;
368 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_CFM_DIRANG )
return true;
372 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_CFM_LIMLIN )
return true;
373 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_CFM_ORTLIN )
return true;
374 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_CFM_LIMANG )
return true;
375 if( this->
Slider->getFlags() & BT_SLIDER_FLAGS_CFM_ORTANG )
return true;
419 if( !PropertiesNode.
Empty() ) {
421 CurrAttrib = PropertiesNode.
GetAttribute(
"UseFrameOffset");
422 if( !CurrAttrib.
Empty() )
425 CurrAttrib = PropertiesNode.
GetAttribute(
"UpperLinLimit");
426 if( !CurrAttrib.
Empty() )
429 CurrAttrib = PropertiesNode.
GetAttribute(
"UpperAngLimit");
430 if( !CurrAttrib.
Empty() )
433 CurrAttrib = PropertiesNode.
GetAttribute(
"LowerLinLimit");
434 if( !CurrAttrib.
Empty() )
437 CurrAttrib = PropertiesNode.
GetAttribute(
"LowerAngLimit");
438 if( !CurrAttrib.
Empty() )
441 CurrAttrib = PropertiesNode.
GetAttribute(
"PoweredLinMotor");
442 if( !CurrAttrib.
Empty() )
445 CurrAttrib = PropertiesNode.
GetAttribute(
"PoweredAngMotor");
446 if( !CurrAttrib.
Empty() )
449 CurrAttrib = PropertiesNode.
GetAttribute(
"TargetLinMotorVelocity");
450 if( !CurrAttrib.
Empty() )
453 CurrAttrib = PropertiesNode.
GetAttribute(
"TargetAngMotorVelocity");
454 if( !CurrAttrib.
Empty() )
457 CurrAttrib = PropertiesNode.
GetAttribute(
"MaxLinMotorForce");
458 if( !CurrAttrib.
Empty() )
461 CurrAttrib = PropertiesNode.
GetAttribute(
"MaxAngMotorForce");
462 if( !CurrAttrib.
Empty() )
465 CurrAttrib = PropertiesNode.
GetAttribute(
"SoftnessLimLin");
466 if( !CurrAttrib.
Empty() )
469 CurrAttrib = PropertiesNode.
GetAttribute(
"SoftnessLimAng");
470 if( !CurrAttrib.
Empty() )
473 CurrAttrib = PropertiesNode.
GetAttribute(
"SoftnessOrthoLin");
474 if( !CurrAttrib.
Empty() )
477 CurrAttrib = PropertiesNode.
GetAttribute(
"SoftnessOrthoAng");
478 if( !CurrAttrib.
Empty() )
492 {
return "SliderConstraint"; }
virtual Real GetTargetLinMotorVelocity() const
Gets the target velocity of the motor on the linear axis of ths constraint.
virtual void SetSoftnessDirAng(const Real SoftnessDirAng)
Sets the softness value to be used when within the angular limits of this constraint.
std::vector< int > AxisList
Used to Store lists of Int Axis for return types.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
CFM values adds some small value to the main diagonal on the constraint matrix to prevent degenerate ...
virtual Vector3 GetPivotALocation() const
Gets the location of the pivot relative to ProxA's Center of gravity.
virtual Real GetSoftnessOrthoLin() const
Gets the softness value to be used when force is applied against the configured linear axis of this c...
A light-weight handle for manipulating attributes in DOM tree.
virtual Constraint::AxisList GetValidAngularAxes() const
Get A list sorted (low to high) of all axis that operate Angularly (that lock sliding/translation) ...
virtual void SetRestitutionLimAng(const Real RestitutionLimAng)
Sets the restitution value to be used when hitting the angular limit of this constraint.
virtual void SetMaxAngMotorForce(const Real MaxAngMotorForce)
Sets the maximum force allowed to be applied on the angular axis of this constraint.
virtual Real GetUpperLinLimit() const
Gets the upper linear limit of this slider.
virtual Boole HasParamBeenSet(ConstraintParam Param, int Axis) const
bool Boole
Generally acts a single bit, true or false.
virtual Real GetDampingLimAng() const
Gets the damping value to be used when hitting the angular limit of this constraint.
virtual Real GetRestitutionLimLin() const
Gets the restitution value to be used when hitting the linear limit of this constraint.
bool AsBool(bool def=false) const
Attempts to convert the value of the attribute to a float and returns the results.
virtual Real GetTargetAngMotorVelocity() const
Gets the target velocity of the motor on the angular axis of ths constraint.
virtual void SetDampingLimLin(const Real DampingLimLin)
Sets the damping value to be used when hitting the linear limit of this constraint.
virtual void SetTargetAngMotorVelocity(const Real TargetAngMotorVelocity)
Sets the target velocity of the motor on the angular axis of ths constraint.
virtual Quaternion GetPivotBRotation() const
Gets the relative rotation for ProxB.
virtual void SetSoftnessLimLin(const Real SoftnessLimLin)
Sets the softness value to be used when hitting the linear limit of this constraint.
virtual Real GetDampingDirLin() const
Gets the damping value to be used when within the linear limits of this constraint.
Thrown when the requested identity could not be found.
virtual void SetPivotBRotation(const Quaternion &Rotation)
Sets The relative rotation of ProxB.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
virtual Real GetLowerLinLimit() const
Gets the lower linear limit of this slider.
virtual void SetPivotBLocation(const Vector3 &Location)
Sets The relative location of the pivot from ProxB's Center of gravity.
virtual Real GetDampingLimLin() const
Gets the damping value to be used when hitting the linear limit of this constraint.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
virtual void SetPivotBTransform(const Transform &TranB)
Sets the Position and Rotation for the second body using a Transform.
virtual void EnableConstraint(const Boole Enable)
Enables or disables this constraint.
virtual void SetUpperLinLimit(const Real UpperLimit)
Sets the upper linear limit of this slider.
static String GetSerializableName()
Get the name of the the XML tag the class will leave behind as its instances are serialized.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
virtual void SetSoftnessDirLin(const Real SoftnessDirLin)
Sets the softness value to be used when within the linear limits of this constraint.
bool Empty() const
Is this storing anything at all?
virtual void SetSoftnessLimAng(const Real SoftnessLimAng)
Sets the softness value to be used when hitting the angular limit of this constraint.
virtual Real GetSoftnessDirAng() const
Gets the softness value to be used when within the angular limits of this constraint.
virtual Real GetRestitutionOrthoLin() const
Gets the restitution value to be used when force is applied against the configured linear axis of thi...
virtual Vector3 GetPivotBLocation() const
Gets the location of the pivot relative to ProxB's Center of gravity.
btQuaternion GetBulletQuaternion(Boole normalize=false) const
Gets a Bullet quaternion.
virtual Real GetMaxAngMotorForce() const
Gets the maximum force allowed to be applied on the angular axis of this constraint.
virtual void SetPivotALocation(const Vector3 &Location)
Sets The relative location of the pivot from ProxA's Center of gravity.
virtual void SetDampingLimAng(const Real DampingLimAng)
Sets the damping value to be used when hitting the angular limit of this constraint.
virtual Real GetSoftnessLimLin() const
Gets the softness value to be used when hitting the linear limit of this constraint.
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
virtual Real GetLowerAngLimit() const
Gets the lower angular limit of this slider.
virtual Boole GetPoweredLinMotor() const
Gets whether or not the motor for the linear axis of this constraint is enabled.
virtual Real GetSoftnessOrthoAng() const
Gets the softness value to be used when force is applied against the configured angular axis of this ...
bool SetValue(const Char8 *rhs)
Set the value of this.
btSliderConstraint * Slider
Bullet constraint that this class encapsulates.
virtual Real GetDampingDirAng() const
Gets the damping value to be used when within the angular limits of this constraint.
virtual Constraint::AxisList GetValidLinearAxes() const
Get a sorted (low to high) list of all axis that operate linearly (that lock sliding/translation) ...
SliderConstraint(const UInt32 ID, RigidProxy *ProxyA, RigidProxy *ProxyB, const Transform &TransA, const Transform &TransB, PhysicsManager *Creator)
Two body Terse constructor.
virtual Real GetSoftnessDirLin() const
Gets the softness value to be used when within the linear limits of this constraint.
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 Boole GetPoweredAngMotor() const
Gets whether or not the motor for the angular axis of this constraint is enabled. ...
virtual void SetSoftnessOrthoLin(const Real SoftnessOrthoLin)
Sets the softness value to be used when force is applied against the configured linear axis of this c...
virtual void SetUseFrameOffset(const Boole FrameOffset)
Sets whether or not an offset of the constraint frame should be used to calculate internal data...
btVector3 GetBulletVector3() const
Gets a Bullet vector3.
A light-weight handle for manipulating nodes in DOM tree.
virtual Real GetDampingOrthoAng() const
Gets the damping value to be used when force is applied against the configured angular axis of this c...
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
uint32_t UInt32
An 32-bit unsigned integer.
virtual void SetPivotARotation(const Quaternion &Rotation)
Sets The relative rotation of ProxA.
bool Empty() const
Is this storing anything at all?
virtual void SetRestitutionOrthoLin(const Real RestitutionOrthoLin)
Sets the restitution value to be used when force is applied against the configured linear axis of thi...
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this Constraint.
virtual Transform GetPivotBTransform() const
Gets the current Rotation and Location of ProxyB.
virtual btTypedConstraint * _GetConstraintBase() const
Get the Bullet constraint that this class encapsulates.
virtual btRigidBody * _GetPhysicsObject() const
Accessor for the internal rigid body physics proxy.
virtual void SetRestitutionDirLin(const Real RestitutionDirLin)
Sets the restitution value to be used when within the linear limits of this constraint.
virtual void SetDampingDirAng(const Real DampingDirAng)
Sets the damping value to be used when within the angular limits of this constraint.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
ConstraintParam
Used by constraints for setting some parameters.
virtual Real GetUpperAngLimit() const
Gets the upper angular limit of this slider.
virtual void SetLowerAngLimit(const Real LowerLimit)
Sets the lower angular limit of this slider.
virtual Real GetRestitutionLimAng() const
Gets the restitution value to be used when hitting the angular limit of this constraint.
virtual void DestroyConstraint()
Destroys the internal constraint.
virtual void SetDampingOrthoLin(const Real DampingOrthoLin)
Sets the damping value to be used when force is applied against the configured linear axis of this co...
virtual ~SliderConstraint()
Class destructor.
This is a proxy from which rigid body proxys are handled.
virtual void SetTargetLinMotorVelocity(const Real TargetLinMotorVelocity)
Sets the target velocity of the motor on the linear axis of ths constraint.
virtual Real GetRestitutionOrthoAng() const
Gets the restitution value to be used when force is applied against the configured angular axis of th...
std::vector< ConstraintParam > ParamList
Used to Store lists of param for return types.
This is simply a place for storing all the Physics Related functions.
virtual void SetRestitutionLimLin(const Real RestitutionLimLin)
Sets the restitution value to be used when hitting the linear limit of this constraint.
RigidProxy * ProxA
The first Collidable this constraint applies to.
virtual void SetDampingDirLin(const Real DampingDirLin)
Sets the damping value to be used when within the linear limits of this constraint.
virtual Real GetMaxLinMotorForce() const
Gets the maximum force allowed to be applied on the linear axis of this constraint.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
virtual void SetPoweredAngMotor(const Boole OnOff)
Sets whether or not the motor for the angular axis of this constraint is enabled. ...
This is used to represent a point in space, or a vector through space.
virtual void SetDampingOrthoAng(const Real DampingOrthoAng)
Sets the damping value to be used when force is applied against the configured angular axis of this c...
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
RigidProxy * ProxB
The second Collidable this constraint applies to.
virtual void SetPivotTransforms(const Transform &TransA, const Transform &TransB)
Sets the Position and Rotation for the first and second body using a Transform.
virtual Real GetSoftnessLimAng() const
Gets the softness value to be used when hitting the angular limit of this constraint.
The bulk of the engine components go in this namspace.
virtual void SetMaxLinMotorForce(const Real MaxLinMotorForce)
Sets the maximum force allowed to be applied on the linear axis of this constraint.
virtual Transform GetPivotATransform() const
Gets the current Rotation and Location of ProxyA.
virtual void SetRestitutionOrthoAng(const Real RestitutionOrthoAng)
Sets the restitution value to be used when force is applied against the configured angular axis of th...
This is used to store information about rotation in 3d space.
virtual void SetPoweredLinMotor(const Boole OnOff)
Sets whether or not the motor for the linear axis of this constraint is enabled.
virtual void SetLowerLinLimit(const Real LowerLimit)
Sets the lower linear limit of this slider.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
virtual void SetUpperAngLimit(const Real UpperLimit)
Sets the upper angular limit of this slider.
std::string String
A datatype used to a series of characters.
virtual Constraint::ParamList GetValidParamsOnAxis(int Axis) const
Get a sorted (low to high) list of Parameters that are valid on this Axis.
virtual void CreateConstraint(RigidProxy *RigidA, RigidProxy *RigidB, const Transform &TransA, const Transform &TransB)
Creates the internal constraint.
virtual void SetPivotATransform(const Transform &TranA)
Sets the Position and Rotation for the first body using a Transform.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual Real GetDampingOrthoLin() const
Gets the damping value to be used when force is applied against the configured linear axis of this co...
virtual Real GetRestitutionDirAng() const
Gets the restitution value to be used when within the angular limits of this constraint.
virtual Real GetRestitutionDirLin() const
Gets the restitution value to be used when within the linear limits of this constraint.
virtual void SetRestitutionDirAng(const Real RestitutionDirAng)
Sets the restitution value to be used when within the angular limits of this constraint.
virtual Boole GetUseFrameOffset() const
Gets whether or not an offset of the constraint frame should be used to calculate internal data...
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual Quaternion GetPivotARotation() const
Gets the relative rotation for ProxA.
virtual void SetSoftnessOrthoAng(const Real SoftnessOrthoAng)
Sets the softness value to be used when force is applied against the configured angular axis of this ...