Spinning Topp Logo BlackTopp Studios
inc
generic6dofconstraint.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _physicsgeneric6dofconstraint_cpp
41 #define _physicsgeneric6dofconstraint_cpp
42 
43 #include "Physics/generic6dofconstraint.h"
44 #include "Physics/rigidproxy.h"
45 
46 #include "stringtool.h"
47 #include "serialization.h"
48 
49 #include <btBulletDynamicsCommon.h>
50 
51 namespace Mezzanine
52 {
53  namespace Physics
54  {
55  /// @todo Assess whether or not the array access methods here should be wrapped in bounds checks, as Bullet only does bounds checks for half of them, if that.
56 
57  ////////////////////////////////////////////////////////////////////////////////
58  // Generic6Dof Constraint Functions
59 
61  DualTransformConstraint(ID,Prox1,Creator)
62  { }
63 
65  DualTransformConstraint(ID,Prox1,Prox2,Creator)
66  { }
67 
68  ////////////////////////////////////////////////////////////////////////////////
69  // Generic6DofConstraint Construction and Destruction
70 
71  Generic6DofConstraint::Generic6DofConstraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Transform& TransA, const Transform& TransB, PhysicsManager* Creator) :
72  DualTransformConstraint(ID,ProxyA,ProxyB,Creator),
73  Generic6dof(NULL)
74  { this->CreateConstraint(ProxyA,ProxyB,TransA,TransB); }
75 
77  DualTransformConstraint(ID,ProxyB,Creator),
78  Generic6dof(NULL)
79  { this->CreateConstraint(ProxyB,NULL,TransB,Transform()); }
80 
82  DualTransformConstraint(0,NULL,Creator),
83  Generic6dof(NULL)
84  { this->ProtoDeSerialize(SelfRoot); }
85 
87  { this->DestroyConstraint(); }
88 
89  void Generic6DofConstraint::CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Transform& TransA, const Transform& TransB)
90  {
91  if( this->Generic6dof == NULL ) {
92  if( RigidA && RigidB ) {
93  this->Generic6dof = new btGeneric6DofConstraint(*(RigidA->_GetPhysicsObject()),*(RigidB->_GetPhysicsObject()),TransA.GetBulletTransform(),TransB.GetBulletTransform(),false);
94  }else if( RigidA ) {
95  this->Generic6dof = new btGeneric6DofConstraint(*(RigidA->_GetPhysicsObject()),TransA.GetBulletTransform(),true);
96  }
97  }
98  }
99 
101  {
102  this->EnableConstraint(false);
103  if( this->Generic6dof != NULL ) {
104  delete this->Generic6dof;
105  this->Generic6dof = NULL;
106  }
107  this->ProxA = NULL;
108  this->ProxB = NULL;
109  }
110 
111  ////////////////////////////////////////////////////////////////////////////////
112  // Generic6DofConstraint Location and Rotation
113 
115  { this->Generic6dof->setFrames(TransA.GetBulletTransform(),TransB.GetBulletTransform()); }
116 
118  { this->Generic6dof->setFrames(TransA.GetBulletTransform(),this->Generic6dof->getFrameOffsetB()); }
119 
121  { this->Generic6dof->setFrames(this->Generic6dof->getFrameOffsetA(),TransB.GetBulletTransform()); }
122 
124  { return this->Generic6dof->getFrameOffsetA(); }
125 
127  { return this->Generic6dof->getFrameOffsetB(); }
128 
130  { this->Generic6dof->getFrameOffsetA().setOrigin(Location.GetBulletVector3()); }
131 
133  { this->Generic6dof->getFrameOffsetB().setOrigin(Location.GetBulletVector3()); }
134 
136  { return Vector3(this->Generic6dof->getFrameOffsetA().getOrigin()); }
137 
139  { return Vector3(this->Generic6dof->getFrameOffsetB().getOrigin()); }
140 
142  { this->Generic6dof->getFrameOffsetA().setRotation(Rotation.GetBulletQuaternion()); }
143 
145  { this->Generic6dof->getFrameOffsetA().setRotation(Rotation.GetBulletQuaternion()); }
146 
148  { return Quaternion(this->Generic6dof->getFrameOffsetA().getRotation()); }
149 
151  { return Quaternion(this->Generic6dof->getFrameOffsetB().getRotation()); }
152 
153  ////////////////////////////////////////////////////////////////////////////////
154  // Utility
155 
157  { this->Generic6dof->setUseFrameOffset(FrameOffset); }
158 
160  { return this->Generic6dof->getUseFrameOffset(); }
161 
163  { this->Generic6dof->setUseLinearReferenceFrameA(UseRefFrameA); }
164 
166  { return this->Generic6dof->getUseLinearReferenceFrameA(); }
167 
169  { return ( Axis % 3 ); }
170 
172  { return ( Axis > 2 ? Axis : Axis + 3 ); }
173 
174  ////////////////////////////////////////////////////////////////////////////////
175  // Basic Limit Accessors
176 
178  { this->Generic6dof->setLimit(Axis, Lower, Upper); }
179 
181  { this->Generic6dof->setLinearLowerLimit(Limit.GetBulletVector3()); }
182 
184  { return Vector3(this->Generic6dof->getTranslationalLimitMotor()->m_lowerLimit); }
185 
187  { this->Generic6dof->setLinearUpperLimit(Limit.GetBulletVector3()); }
188 
190  { return Vector3(this->Generic6dof->getTranslationalLimitMotor()->m_upperLimit); }
191 
193  { this->Generic6dof->getTranslationalLimitMotor()->m_lowerLimit[TranslationAxis] = Limit; }
194 
196  { return this->Generic6dof->getTranslationalLimitMotor()->m_lowerLimit[TranslationAxis]; }
197 
199  { this->Generic6dof->getTranslationalLimitMotor()->m_upperLimit[TranslationAxis] = Limit; }
200 
202  { return this->Generic6dof->getTranslationalLimitMotor()->m_upperLimit[TranslationAxis]; }
203 
205  { this->Generic6dof->setAngularUpperLimit(Limit.GetBulletVector3()); }
206 
209 
211  { this->Generic6dof->setAngularLowerLimit(Limit.GetBulletVector3()); }
212 
215 
217  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(RotationAxis))->m_loLimit = Limit; }
218 
220  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(RotationAxis))->m_loLimit; }
221 
223  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(RotationAxis))->m_hiLimit = Limit; }
224 
226  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(RotationAxis))->m_hiLimit; }
227 
228  ////////////////////////////////////////////////////////////////////////////////
229  // Angular Limit and Motor Details
230 
233 
236 
238  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_maxLimitForce = MaxLimitForce; }
239 
241  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_maxLimitForce; }
242 
245 
248 
250  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_targetVelocity = Velocity; }
251 
253  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_targetVelocity; }
254 
257 
260 
262  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_maxMotorForce = Force; }
263 
265  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_maxMotorForce; }
266 
269 
272 
274  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_damping = Damping; }
275 
277  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_damping; }
278 
281 
284 
286  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_bounce = Restitution; }
287 
289  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_bounce; }
290 
293 
296 
298  { this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_enableMotor = Enabled; }
299 
301  { return this->Generic6dof->getRotationalLimitMotor(ConvertFrom6AxisTo3Axis(Axis))->m_enableMotor; }
302 
303  ////////////////////////////////////////////////////////////////////////////////
304  // Linear Limit and Motor Details
305 
307  { this->Generic6dof->getTranslationalLimitMotor()->m_limitSoftness = Softness; }
308 
310  { return this->Generic6dof->getTranslationalLimitMotor()->m_limitSoftness; }
311 
313  { this->Generic6dof->getTranslationalLimitMotor()->m_damping = Damping; }
314 
316  { return this->Generic6dof->getTranslationalLimitMotor()->m_damping; }
317 
319  { this->Generic6dof->getTranslationalLimitMotor()->m_restitution = Restitution; }
320 
322  { return this->Generic6dof->getTranslationalLimitMotor()->m_restitution; }
323 
326 
328  { this->Generic6dof->getTranslationalLimitMotor()->m_maxMotorForce[Axis] = Force; }
329 
332 
334  { return this->Generic6dof->getTranslationalLimitMotor()->m_maxMotorForce[Axis]; }
335 
338 
340  { this->Generic6dof->getTranslationalLimitMotor()->m_targetVelocity[Axis] = Velocity; }
341 
344 
346  { return this->Generic6dof->getTranslationalLimitMotor()->m_targetVelocity[Axis]; }
347 
349  { this->SetLinearMotorEnabledOnAxis(Enableds.X,LinearX); this->SetLinearMotorEnabledOnAxis(Enableds.Y,LinearY); this->SetLinearMotorEnabledOnAxis(Enableds.Z,LinearZ); }
350 
352  { this->Generic6dof->getTranslationalLimitMotor()->m_enableMotor[Axis] = Enabled; }
353 
356 
358  { return this->Generic6dof->getTranslationalLimitMotor()->m_enableMotor[Axis]; }
359 
360  ////////////////////////////////////////////////////////////////////////////////
361  // Axis and Params
362 
364  {
365  Constraint::ParamList Results;
366  if( 0 <= Axis && 5 >= Axis ) {
367  Results.push_back(Con_Stop_ERP);
368  Results.push_back(Con_CFM);
369  Results.push_back(Con_Stop_CFM);
370  }
371  return Results;
372  }
373 
375  {
376  Constraint::AxisList Results;
377  Results.push_back(0);
378  Results.push_back(1);
379  Results.push_back(2);
380  return Results;
381  }
382 
384  {
385  Constraint::AxisList Results;
386  Results.push_back(3);
387  Results.push_back(4);
388  Results.push_back(5);
389  return Results;
390  }
391 
393  {
394  // the logic here should match the logic in the source at http://bulletphysics.com/Bullet/BulletFull/btGeneric6DofConstraint_8cpp_source.html#l00964
395  if( 0 > Axis || 5 < Axis )
396  { return false; }
397  return ( Con_Stop_ERP==Param && this->Generic6dof->getFlags() & (BT_6DOF_FLAGS_ERP_STOP << (Axis * BT_6DOF_FLAGS_AXIS_SHIFT)) ) || //if we are checking the stop_erp AND the stop_erp bit is set for the correct axis
398  ( Con_Stop_CFM==Param && this->Generic6dof->getFlags() & (BT_6DOF_FLAGS_CFM_STOP << (Axis * BT_6DOF_FLAGS_AXIS_SHIFT)) ) || //if we are checking the stop_cfm AND the stop_cfm bit is set
399  ( Con_CFM==Param && this->Generic6dof->getFlags() & (BT_6DOF_FLAGS_CFM_NORM << (Axis * BT_6DOF_FLAGS_AXIS_SHIFT)) ) ; //if we are checking the cfm AND the cfm bit is set
400  }
401 
402  ///////////////////////////////////////////////////////////////////////////////
403  // Serialization
404 
406  {
407  this->Constraint::ProtoSerializeProperties(SelfRoot);
408 
409  XML::Node PropertiesNode = SelfRoot.AppendChild( Generic6DofConstraint::GetSerializableName() + "Properties" );
410 
411  if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
412  PropertiesNode.AppendAttribute("UseFrameOffset").SetValue( this->GetUseFrameOffset() ) &&
413  PropertiesNode.AppendAttribute("UseLinearReferenceFrameA").SetValue( this->GetUseLinearReferenceFrameA() ) &&
414  PropertiesNode.AppendAttribute("LinearLimitSoftness").SetValue( this->GetLinearLimitSoftness() ) &&
415  PropertiesNode.AppendAttribute("LinearLimitDamping").SetValue( this->GetLinearLimitDamping() ) &&
416  PropertiesNode.AppendAttribute("LinearLimitRestitution").SetValue( this->GetLinearLimitRestitution() ) )
417  {
418  XML::Node LinearAxesNode = PropertiesNode.AppendChild("LinearAxes");
419  for( Integer LinAxis = Generic6DofConstraint::LinearStart ; LinAxis < Generic6DofConstraint::LinearEnd ; ++LinAxis )
420  {
421  XML::Node LinearAxisNode = LinearAxesNode.AppendChild("LinearAxis");
422  if( LinearAxisNode.AppendAttribute("Version").SetValue("1") &&
423  LinearAxisNode.AppendAttribute("Axis").SetValue( LinAxis ) &&
424  LinearAxisNode.AppendAttribute("LimitLower").SetValue( this->GetLinearLimitLowerOnAxis(LinAxis) ) &&
425  LinearAxisNode.AppendAttribute("LimitUpper").SetValue( this->GetLinearLimitUpperOnAxis(LinAxis) ) &&
426  LinearAxisNode.AppendAttribute("MotorMaxForce").SetValue( this->GetLinearMotorMaxForceOnAxis(LinAxis) ) &&
427  LinearAxisNode.AppendAttribute("MotorTargetVelocity").SetValue( this->GetLinearMotorTargetVelocityOnAxis(LinAxis) ) &&
428  LinearAxisNode.AppendAttribute("MotorEnabled").SetValue( this->GetLinearMotorEnabledOnAxis(LinAxis) ) )
429  {
430  continue;
431  }else{
432  SerializeError("Create XML Attribute Values",Generic6DofConstraint::GetSerializableName() + " Linear Axes",true);
433  }
434  }
435 
436  XML::Node AngularAxesNode = PropertiesNode.AppendChild("AngularAxes");
437  for( Integer AngAxis = Generic6DofConstraint::AngularStart ; AngAxis < Generic6DofConstraint::AngularEnd ; ++AngAxis )
438  {
439  XML::Node AngularAxisNode = AngularAxesNode.AppendChild("AngularAxis");
440  if( AngularAxisNode.AppendAttribute("Version").SetValue("1") &&
441  AngularAxisNode.AppendAttribute("Axis").SetValue( ConvertFrom6AxisTo3Axis(AngAxis) ) &&
442  AngularAxisNode.AppendAttribute("LimitLower").SetValue( this->GetAngularLimitLowerOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
443  AngularAxisNode.AppendAttribute("LimitUpper").SetValue( this->GetAngularLimitUpperOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
444  AngularAxisNode.AppendAttribute("LimitMaxForce").SetValue( this->GetAngularLimitMaxForceOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
445  AngularAxisNode.AppendAttribute("MotorTargetVelocity").SetValue( this->GetAngularMotorTargetVelocityOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
446  AngularAxisNode.AppendAttribute("MotorMaxForce").SetValue( this->GetAngularMotorMaxForceOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
447  AngularAxisNode.AppendAttribute("MotorDamping").SetValue( this->GetAngularMotorDampingOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
448  AngularAxisNode.AppendAttribute("MotorRestitution").SetValue( this->GetAngularMotorRestitutionOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) &&
449  AngularAxisNode.AppendAttribute("MotorEnabled").SetValue( this->GetAngularMotorEnabledOnAxis( ConvertFrom6AxisTo3Axis(AngAxis) ) ) )
450  {
451  continue;
452  }else{
453  SerializeError("Create XML Attribute Values",Generic6DofConstraint::GetSerializableName() + " Angular Axes",true);
454  }
455  }
456 
457  return;
458  }else{
459  SerializeError("Create XML Attribute Values",Generic6DofConstraint::GetSerializableName() + "Properties",true);
460  }
461  }
462 
464  {
466 
467  XML::Attribute CurrAttrib;
468  XML::Node PropertiesNode = SelfRoot.GetChild( Generic6DofConstraint::GetSerializableName() + "Properties" );
469 
470  if( !PropertiesNode.Empty() ) {
471  if( PropertiesNode.GetAttribute("Version").AsInt() == 1 ) {
472  CurrAttrib = PropertiesNode.GetAttribute("UseFrameOffset");
473  if( !CurrAttrib.Empty() )
474  this->SetUseFrameOffset( CurrAttrib.AsBool() );
475 
476  CurrAttrib = PropertiesNode.GetAttribute("UseLinearReferenceFrameA");
477  if( !CurrAttrib.Empty() )
478  this->SetUseLinearReferenceFrameA( CurrAttrib.AsBool() );
479 
480  CurrAttrib = PropertiesNode.GetAttribute("LinearLimitSoftness");
481  if( !CurrAttrib.Empty() )
482  this->SetLinearLimitSoftness( CurrAttrib.AsReal() );
483 
484  CurrAttrib = PropertiesNode.GetAttribute("LinearLimitDamping");
485  if( !CurrAttrib.Empty() )
486  this->SetLinearLimitDamping( CurrAttrib.AsReal() );
487 
488  CurrAttrib = PropertiesNode.GetAttribute("LinearLimitRestitution");
489  if( !CurrAttrib.Empty() )
490  this->SetLinearLimitRestitution( CurrAttrib.AsReal() );
491 
492  XML::Node LinearAxesNode = PropertiesNode.GetChild("LinearAxes");
493  for( XML::NodeIterator LinearAxesNodeIt = LinearAxesNode.begin() ; LinearAxesNodeIt != LinearAxesNode.end() ; ++LinearAxesNodeIt )
494  {
495  if( !(*LinearAxesNodeIt).Empty() ) {
496  if( (*LinearAxesNodeIt).GetAttribute("Version").AsInt() == 1 ) {
497  Integer Axis = -1;
498 
499  CurrAttrib = (*LinearAxesNodeIt).GetAttribute("Axis");
500  if( !CurrAttrib.Empty() )
501  Axis = CurrAttrib.AsInt();
502 
503  if( Axis < 0 || Axis > 2 )
504  continue;
505 
506  CurrAttrib = (*LinearAxesNodeIt).GetAttribute("LimitLower");
507  if( !CurrAttrib.Empty() )
508  this->SetLinearLimitLowerOnAxis( CurrAttrib.AsReal(), Axis );
509 
510  CurrAttrib = (*LinearAxesNodeIt).GetAttribute("LimitUpper");
511  if( !CurrAttrib.Empty() )
512  this->SetLinearLimitUpperOnAxis( CurrAttrib.AsReal(), Axis );
513 
514  CurrAttrib = (*LinearAxesNodeIt).GetAttribute("MotorMaxForce");
515  if( !CurrAttrib.Empty() )
516  this->SetLinearMotorMaxForceOnAxis( CurrAttrib.AsReal(), Axis );
517 
518  CurrAttrib = (*LinearAxesNodeIt).GetAttribute("MotorTargetVelocity");
519  if( !CurrAttrib.Empty() )
520  this->SetLinearMotorTargetVelocityOnAxis( CurrAttrib.AsReal(), Axis );
521 
522  CurrAttrib = (*LinearAxesNodeIt).GetAttribute("MotorEnabled");
523  if( !CurrAttrib.Empty() )
524  this->SetLinearMotorEnabledOnAxis( CurrAttrib.AsReal(), Axis );
525  }
526  }
527  }
528 
529  XML::Node AngularAxesNode = PropertiesNode.GetChild("AngularAxes");
530  for( XML::NodeIterator AngularAxesNodeIt = AngularAxesNode.begin() ; AngularAxesNodeIt != AngularAxesNode.end() ; ++AngularAxesNodeIt )
531  {
532  if( !(*AngularAxesNodeIt).Empty() ) {
533  if( (*AngularAxesNodeIt).GetAttribute("Version").AsInt() == 1 ) {
534  Integer Axis = -1;
535 
536  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("Axis");
537  if( !CurrAttrib.Empty() )
538  Axis = CurrAttrib.AsInt();
539 
540  if( Axis < 0 || Axis > 5 )
541  continue;
542 
543  Axis = this->ConvertFrom6AxisTo3Axis(Axis);
544 
545  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("LimitLower");
546  if( !CurrAttrib.Empty() )
547  this->SetAngularLimitLowerOnAxis( CurrAttrib.AsReal(), Axis );
548 
549  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("LimitUpper");
550  if( !CurrAttrib.Empty() )
551  this->SetAngularLimitUpperOnAxis( CurrAttrib.AsReal(), Axis );
552 
553  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("LimitMaxForce");
554  if( !CurrAttrib.Empty() )
555  this->SetAngularLimitMaxForceOnAxis( CurrAttrib.AsReal(), Axis );
556 
557  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("MotorTargetVelocity");
558  if( !CurrAttrib.Empty() )
559  this->SetAngularMotorTargetVelocityOnAxis( CurrAttrib.AsReal(), Axis );
560 
561  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("MotorMaxForce");
562  if( !CurrAttrib.Empty() )
563  this->SetAngularMotorMaxForceOnAxis( CurrAttrib.AsReal(), Axis );
564 
565  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("MotorDamping");
566  if( !CurrAttrib.Empty() )
567  this->SetAngularMotorDampingOnAxis( CurrAttrib.AsReal(), Axis );
568 
569  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("MotorRestitution");
570  if( !CurrAttrib.Empty() )
571  this->SetAngularMotorRestitutionOnAxis( CurrAttrib.AsReal(), Axis );
572 
573  CurrAttrib = (*AngularAxesNodeIt).GetAttribute("MotorEnabled");
574  if( !CurrAttrib.Empty() )
575  this->SetAngularMotorEnabledOnAxis( CurrAttrib.AsReal(), Axis );
576  }
577  }
578  }
579  }else{
580  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + ( Generic6DofConstraint::GetSerializableName() + "Properties" ) + ": Not Version 1.");
581  }
582  }else{
583  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,Generic6DofConstraint::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
584  }
585  }
586 
589 
591  { return "Generic6DofConstraint"; }
592 
593  ///////////////////////////////////////////////////////////////////////////////
594  // Internal
595 
596  btTypedConstraint* Generic6DofConstraint::_GetConstraintBase() const
597  { return this->Generic6dof; }
598  }//Physics
599 }//Mezzanine
600 
601 #endif
virtual Vector3 GetAngularMotorRestitution() const
Get the Restitution values for all three axis.
virtual Constraint::AxisList GetValidLinearAxes() const
Get a sorted (low to high) list of all axis that operate linearly (that lock sliding/translation) ...
std::vector< int > AxisList
Used to Store lists of Int Axis for return types.
Definition: constraint.h:124
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 ...
Definition: constraint.h:65
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
virtual void SetAngularLimitLower(const Vector3 &Limit)
Set the Lower limits on rotation.
virtual void SetPivotBRotation(const Quaternion &Rotation)
Sets The relative rotation of ProxB.
virtual btTypedConstraint * _GetConstraintBase() const
Get the Bullet constraint that this class encapsulates.
virtual void SetAngularMotorRestitutionOnAxis(const Real Restitution, Whole Axis)
For one Axis, set the Restitution/Bounciness/.
virtual void SetLinearLimitDamping(const Real Damping)
Set the Damping of the linear Limits.
All constraints that track rotation and location of the Pivot relative to each Actor inherit from thi...
virtual Quaternion GetPivotARotation() const
Gets the relative rotation for ProxA.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
virtual void SetAngularMotorDampingOnAxis(const Real Damping, Whole Axis)
For one Axis, set the Damping.
virtual Boole GetLinearMotorEnabledOnAxis(Whole Axis) const
Is a specific Linear motor enabled.
bool AsBool(bool def=false) const
Attempts to convert the value of the attribute to a float and returns the results.
static String GetSerializableName()
Get the name of the the XML tag the class will leave behind as its instances are serialized.
virtual Vector3 GetAngularMotorEnabled() const
Get a Vector3 with 3 zero or nonzero values that store whether or not a given rotational motor is ena...
virtual Vector3 GetAngularMotorMaxForce() const
Get the Max Motor Force for each Axis.
virtual void SetPivotTransforms(const Transform &TransA, const Transform &TransB)
Sets the Position and Rotation for the first and second body using a Transform.
Real X
Coordinate on the X vector.
Definition: vector3.h:85
virtual Vector3 GetPivotALocation() const
Gets the location of the pivot relative to ProxA's Center of gravity.
virtual void SetLinearMotorMaxForceOnAxis(const Real Force, Whole Axis)
For one Axis, set the Maximimum Motor Force.
Real Z
Coordinate on the Z vector.
Definition: vector3.h:89
virtual Transform GetPivotATransform() const
Gets the current Rotation and Location of ProxyA.
virtual Quaternion GetPivotBRotation() const
Gets the relative rotation for ProxB.
virtual void SetLinearMotorMaxForce(const Vector3 &Forces)
Set the Linear Motor Maximum force on all 3 translation axis.
virtual void SetAngularLimitMaxForceOnAxis(const Real MaxLimitForce, Whole Axis)
Set the Maximimum amount of force applied to ensure a limit on one axis is not surpassed.
virtual Vector3 GetLinearLimitLower() const
Get the Upper limits on translation.
virtual Vector3 GetAngularLimitMaxForce() const
Get the Maximimum amount of force applied to ensure limits are not surpassed.
Thrown when the requested identity could not be found.
Definition: exception.h:94
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
virtual void SetPivotBTransform(const Transform &TransB)
Sets the Position and Rotation for the second body using a Transform.
virtual void SetLinearMotorTargetVelocityOnAxis(const Real Velocity, Whole Axis)
For one Axis, set the target velocity of the Linear motor.
virtual Vector3 GetLinearMotorTargetVelocity() const
Get the target velocity for all Linear Axis.
virtual void SetAngularMotorDamping(const Vector3 &Dampings)
Set the Angular Motor Damping for each Angular Axis.
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
Boole Enabled
Whether or not the constraint is currently taking effect.
Definition: constraint.h:145
virtual void DestroyConstraint()
Destroys the internal constraint.
virtual ~Generic6DofConstraint()
Class destructor.
virtual Real GetAngularMotorDampingOnAxis(Whole Axis) const
Get the Damping for one given Axis.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
virtual Vector3 GetPivotBLocation() const
Gets the location of the pivot relative to ProxB's Center of gravity.
Rotation on the Y axis, when working with only rotational Axis.
virtual void SetLimit(Whole Axis, Real Lower, Real Upper)
Change the upper and lower limit for one axis of translation or rotation limit.
virtual void SetLinearLimitRestitution(const Real Restitution)
Set the Restitution of the linear Limits.
Rotation on the X axis, when working with only rotational Axis.
virtual void EnableConstraint(const Boole Enable)
Enables or disables this constraint.
virtual Real GetLinearLimitSoftness() const
Get the Softness of the linear Limits.
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 GetAngularLimitLower() const
Get the Upper limits on rotation.
void SetAngularLimitLowerOnAxis(const Real Limit, Whole RotationAxis)
Sets the lower rotation limit on a specific axis of the constraint.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Rotation on the Z axis, when working with only rotational Axis.
virtual Transform GetPivotBTransform() const
Gets the current Rotation and Location of ProxyB.
Real GetLinearLimitLowerOnAxis(Whole TranslationAxis) const
Get a specific lower translation limit.
bool Empty() const
Is this storing anything at all?
virtual void SetAngularMotorTargetVelocityOnAxis(const Real Velocity, Whole Axis)
For one Axis, set the target velocity of the angular motor.
virtual void SetAngularLimitUpper(const Vector3 &Limit)
Set the Upper limits on rotation.
virtual void SetPivotALocation(const Vector3 &Location)
Sets The relative location of the pivot from ProxA's Center of gravity.
virtual void SetLinearLimitUpper(const Vector3 &Limit)
Set the lower limits on translation.
Boole GetUseLinearReferenceFrameA() const
Gets whether or not to perform linear math from ProxyA's perspective.
btQuaternion GetBulletQuaternion(Boole normalize=false) const
Gets a Bullet quaternion.
Definition: quaternion.cpp:243
Real GetAngularLimitUpperOnAxis(Whole RotationAxis) const
Get a specific upper rotation limit.
virtual Vector3 GetLinearMotorEnabled() const
Get a Vector3 with 3 zero or nonzero values that store whether or not a given rotational motor is ena...
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
The interface for serialization.
virtual void SetLinearLimitLower(const Vector3 &Limit)
Set the Upper limits on translation.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual void SetAngularLimitMaxForce(const Vector3 &MaxLimitForces)
Set the Maximimum amount of force applied to ensure limits are not surpassed.
virtual void SetLinearMotorEnabledOnAxis(const Boole Enabled, Whole Axis)
For one Axis, set whether or not the motor is enabled.
btTransform GetBulletTransform() const
Gets a Bullet Transform.
Definition: transform.cpp:71
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 Real GetLinearLimitRestitution() const
Get the Restitution of the linear Limits.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Child node iterator (a bidirectional iterator over a collection of Node)
Definition: nodeiterator.h:77
btVector3 GetBulletVector3() const
Gets a Bullet vector3.
Definition: vector3.cpp:555
virtual Real GetAngularLimitMaxForceOnAxis(Whole Axis) const
Get the Maximimum amount of force applied to ensure a limit one axis is not surpassed.
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
iterator begin() const
Get a Child node iterator that references the first child Node.
virtual Boole GetUseFrameOffset() const
Gets whether or not an offset of the constraint frame should be used to calculate internal data...
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.
Definition: datatypes.h:126
virtual void SetLinearLimitSoftness(const Real Softness)
Set the Softness of the linear Limits.
virtual void SetAngularMotorRestitution(const Vector3 &Restitutions)
Set the Bounciness/Restition for rotation on all three Axis.
iterator end() const
Get a Child node iterator that references one past the last child Node.
virtual Boole HasParamBeenSet(ConstraintParam Param, int Axis) const
bool Empty() const
Is this storing anything at all?
virtual Vector3 GetAngularMotorTargetVelocity() const
Get the target velocity for all angular Axis.
btGeneric6DofConstraint * Generic6dof
The internal constraint that this class encapsulates.
Generic6DofConstraint(const UInt32 ID, RigidProxy *Prox1, PhysicsManager *Creator)
Single body inheritance constructor.
virtual btRigidBody * _GetPhysicsObject() const
Accessor for the internal rigid body physics proxy.
Definition: rigidproxy.cpp:406
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
Real Y
Coordinate on the Y vector.
Definition: vector3.h:87
ConstraintParam
Used by constraints for setting some parameters.
Definition: constraint.h:61
virtual Vector3 GetLinearMotorMaxForce() const
Get the Max Motor Force for each Axis.
Real GetLinearLimitUpperOnAxis(Whole TranslationAxis) const
Get a specific upper translation limit.
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this Constraint.
virtual void SetAngularMotorEnabled(const Vector3 &Enableds)
Set whether or not the motor is enabled for all Axis Simultaneously.
virtual void SetPivotARotation(const Quaternion &Rotation)
Sets The relative rotation of ProxA.
void SetUseLinearReferenceFrameA(const Boole UseRefFrameA)
Sets whether or not to perform linear math from ProxyA's perspective.
This is a proxy from which rigid body proxys are handled.
Definition: rigidproxy.h:102
Stores information about relative location and rotation in 3d space.
Definition: transform.h:62
virtual Vector3 GetAngularMotorDamping() const
Get the Damping for all Angular Axis.
std::vector< ConstraintParam > ParamList
Used to Store lists of param for return types.
Definition: constraint.h:120
virtual Real GetLinearLimitDamping() const
Get the Damping of the linear Limits.
This is simply a place for storing all the Physics Related functions.
virtual void SetPivotBLocation(const Vector3 &Location)
Sets The relative location of the pivot from ProxB's Center of gravity.
RigidProxy * ProxA
The first Collidable this constraint applies to.
Definition: constraint.h:130
virtual void SetAngularMotorMaxForce(const Vector3 &Forces)
Set the Angular Motor Maximum force on all 3 rotational axis.
virtual Real GetAngularMotorTargetVelocityOnAxis(Whole Axis) const
Get the Target Velocity for one axis.
virtual void SetAngularMotorTargetVelocity(const Vector3 &Velocities)
Set the Target velocity of the motor on each anuglar axis.
virtual Constraint::ParamList GetValidParamsOnAxis(int Axis) const
Get a sorted (low to high) list of Parameters that are valid on this Axis.
virtual Boole GetAngularMotorEnabledOnAxis(Whole Axis) const
Is a specific rotational motor enabled.
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
virtual void SetLinearMotorEnabled(const Vector3 &Enableds)
Set whether or not the motor is enabled for all Linear Axis Simultaneously.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
virtual void SetAngularMotorMaxForceOnAxis(const Real Force, Whole Axis)
For one Axis, set the Maximimum Motor Force.
void SetAngularLimitUpperOnAxis(const Real Limit, Whole RotationAxis)
Sets the upper rotation limit on a specific axis of the constraint.
RigidProxy * ProxB
The second Collidable this constraint applies to.
Definition: constraint.h:133
virtual Whole ConvertAngularTo6Axis(const Whole Axis) const
Convert an angular Axis from a 3 digit range to a full 6 digit range.
virtual Real GetAngularMotorMaxForceOnAxis(Whole Axis) const
Get the Max motor Force on a certain Axis.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Real GetAngularLimitLowerOnAxis(Whole RotationAxis) const
Get a specific lower rotation limit.
virtual Vector3 GetAngularLimitUpper() const
Get the Power limits on rotation.
virtual void CreateConstraint(RigidProxy *RigidA, RigidProxy *RigidB, const Transform &TransA, const Transform &TransB)
Creates the internal constraint.
This is used to store information about rotation in 3d space.
Definition: quaternion.h:68
void SetLinearLimitLowerOnAxis(const Real Limit, Whole TranslationAxis)
Sets the lower linear limit on a specific axis of the constraint.
virtual Real GetLinearMotorMaxForceOnAxis(Whole Axis) const
Get the Max motor Force on a certain Axis.
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 SetPivotATransform(const Transform &TransA)
Sets the Position and Rotation for the first body using a Transform.
virtual void SetUseFrameOffset(const Boole FrameOffset)
Sets whether or not an offset of the constraint frame should be used to calculate internal data...
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
virtual Whole ConvertFrom6AxisTo3Axis(const Whole Axis) const
Convert an Axis from a full 6 digit range to a 3 digit range.
virtual Real GetLinearMotorTargetVelocityOnAxis(Whole Axis) const
Get the Target Velocity for one axis.
virtual void SetAngularMotorEnabledOnAxis(const Boole Enabled, Whole Axis)
For one Axis, set whether or not the motor is enabled.
virtual Constraint::AxisList GetValidAngularAxes() const
Get A list sorted (low to high) of all axis that operate Angularly (that lock sliding/translation) ...
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual Real GetAngularMotorRestitutionOnAxis(Whole Axis) const
Get the Restitution/Bounciness for a single Axis.
virtual Vector3 GetLinearLimitUpper() const
Get the lower limits on translation.
virtual void SetLinearMotorTargetVelocity(const Vector3 &Velocities)
Set the Target velocity of the motor on each anuglar axis.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
void SetLinearLimitUpperOnAxis(const Real Limit, Whole TranslationAxis)
Sets the upper linear limit on a specific axis of the constraint.