AGX Dynamics  2.35.0.1
RigidBody.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_RIGIDBODY_H
18 #define AGX_RIGIDBODY_H
19 
20 #include <agx/agx.h>
21 #include <agx/Frame.h>
22 #include <agx/MassProperties.h>
23 #include <agx/BitArray.h>
24 
26 
27 #include <agxCollide/Geometry.h>
28 
29 #include <agx/SleepThreshold.h>
30 #include <agx/RigidBodyState.h>
31 #include <agx/SetVector.h>
32 
33 #include <agx/macros.h>
34 
35 #ifdef _MSC_VER
36 # pragma warning(push)
37 # pragma warning(disable:4355) //Disable 'this' : used in base member initializer list warning
38 #endif
39 
40 namespace agx
41 {
42  class DynamicsSystem;
43  class AutoSleep;
44  class MergeSplitBodyStorage;
45  class InternalData;
46 
50 
55  {
56  public:
66  {
67  STATIC = 1,
68  KINEMATICS = 2,
69  DYNAMICS = 3
70  };
71 
72  public:
79  RigidBody( const agx::Name& name = "" );
80 
87 
91  RigidBody *clone( bool shallowCopyRenderData=false ) const;
92 
98  agx::Frame* getFrame();
99 
105  const agx::Frame* getFrame() const;
106 
112  void setTransform( const agx::AffineMatrix4x4& matrix );
113 
118 
124 
129 
134  void setLocalPosition( const agx::Vec3& p );
135 
143 
148  void setRotation( const agx::Quat& q );
149 
154  void setRotation( const agx::EulerAngles& e);
155 
161 
166 
171  void setLocalRotation( const agx::Quat& q );
172 
178 
183 
187  const agx::Frame* getParentFrame() const;
188 
201  bool setParentFrame( agx::Frame* frame );
202 
207  void setPosition( const agx::Vec3& p );
208 
216 
225  agx::Frame* getCmFrame();
226 
235  const agx::Frame* getCmFrame() const;
236 
241  const agx::AffineMatrix4x4& getTransform() const;
242 
247  CALLABLE_UNIT("m/s")
248  agx::Vec3 getPosition() const;
249 
254  agx::Quat getRotation() const;
255 
267  void setVelocity( const agx::Vec3& velocity );
268 
280  void setVelocity( agx::Real vx, agx::Real vy, agx::Real vz );
281 
293  void setAngularVelocity( const agx::Vec3& angularVelocity );
294 
306  void setAngularVelocity( agx::Real vx, agx::Real vy, agx::Real vz );
307 
313  agx::Vec3 getVelocity() const;
314 
321  agx::Vec3 getAngularVelocity() const;
322 
331  agx::Vec3 getModelVelocity( const agx::Vec3& relPos = agx::Vec3() ) const;
332 
341  agx::Vec3 getModelAcceleration( const agx::Vec3& relPos = agx::Vec3() ) const;
342 
348  void setEnable( bool enable );
349 
354  bool getEnable() const;
355 
360  bool isEnabled() const;
361 
365  agx::RigidBody::MotionControl getMotionControl() const;
366 
375 
379  agx::DynamicsSystem* getSystem();
380 
384  const agx::DynamicsSystem* getSystem() const;
385 
393  agx::Vec3 getLastForce() const;
394 
402  agx::Vec3 getLastTorque() const;
403 
414  agx::PropertyContainer* getPropertyContainer() const;
415 
419  bool hasPropertyContainer() const;
420 
425  void setPropertyContainer( agx::PropertyContainer* container );
426 
430  const agx::Name& getName() const;
431 
436  void setName( const agx::Name& name );
437 
444  agx::UInt32 getId() const;
445 
452  agx::AutoSleepThreshold* getAutoSleepThreshold();
453 
460  const agx::AutoSleepThreshold* getAutoSleepThreshold() const;
461 
468  void setAutoSleepThreshold( agx::AutoSleepThreshold* threshold );
469 
475  agx::MergeSplitThreshold* getMergeSplitThreshold();
476 
482  const agx::MergeSplitThreshold* getMergeSplitThreshold() const;
483 
490  void setMergeSplitThreshold( agx::MergeSplitThreshold* threshold );
491 
505  const agx::AffineMatrix4x4& getCmTransform() const;
506 
517  void setCmTransform( const agx::AffineMatrix4x4& matrix, bool synchronizeModel = true );
518 
522  agx::Vec3 getCmLocalTranslate() const;
523 
528  void setCmLocalTranslate(const agx::Vec3& translate);
529 
533  agx::Vec3 getCmPosition() const;
534 
541  void setCmPosition( const agx::Vec3& p, bool synchronizeModel = true );
542 
546  agx::Quat getCmRotation() const;
547 
556  void setCmRotation( const agx::Quat& q);
557 
566  void setCmRotation( const agx::EulerAngles& e);
567 
576  void setCmRotation( const agx::OrthoMatrix3x3& m);
577 
592  void setInertiaTensor( const agx::SPDMatrix3x3& inertiaTensor, const agx::AffineMatrix4x4& cmLocalTransform = agx::AffineMatrix4x4(), bool autogenerateCmOffset = false, bool autogenerateInertia = false );
593 
609  void setInertiaTensor( const agx::Vec3& inertiaDiagonal, const agx::AffineMatrix4x4& cmLocalTransform = agx::AffineMatrix4x4(), bool autogenerateCmOffset = false, bool autogenerateInertia = false );
610 
615  bool addAttachment( agx::Frame* frame, const agx::String& name );
616 
621  bool removeAttachment( const agx::String& name );
622 
628  Frame* getAttachment( const agx::String& name );
629 
633  const agx::MassProperties* getMassProperties() const;
634 
638  agx::MassProperties* getMassProperties();
639 
647  void setForce( const agx::Vec3& force );
648 
656  void setForce( agx::Real fx, agx::Real fy, agx::Real fz );
657 
665  void setTorque( const agx::Vec3& torque );
666 
674  void setTorque( agx::Real tx, agx::Real ty, agx::Real tz );
675 
681  void addForce( const agx::Vec3& force );
682 
688  void addForce( agx::Real fx, agx::Real fy, agx::Real fz );
689 
696  void addForceAtPosition( const agx::Vec3& force, const agx::Vec3& position );
697 
704  void addForceAtPosition( agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz );
705 
712  void addForceAtLocalPosition( const agx::Vec3& force, const agx::Vec3& position );
713 
720  void addForceAtLocalPosition( agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz );
721 
728  void addForceAtLocalCmPosition( const agx::Vec3& force, const agx::Vec3& position );
729 
736  void addForceAtLocalCmPosition( agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz );
737 
743  void addTorque( const agx::Vec3& torque );
744 
750  void addTorque( agx::Real tx, agx::Real ty, agx::Real tz );
751 
757  void addLocalTorque( agx::Real tx, agx::Real ty, agx::Real tz );
758 
764  void addLocalTorque( const agx::Vec3& torque );
765 
785  bool add( agxCollide::Geometry* geometry , const agx::AffineMatrix4x4& localTransform, bool incrementalMassCalculation = false );
786 
810  bool add( agxCollide::Geometry* geometry, bool incrementalMassCalculation = false );
811 
822  bool remove( agxCollide::Geometry* geometry, bool incrementalMassCalculation = false );
823 
829  const agxCollide::Geometry* getGeometry(const agx::Name& name) const;
830 
837  agxCollide::Geometry* getGeometry(const agx::Name& name);
838 
842  const agxCollide::GeometryRefVector& getGeometries() const;
843 
848  const agxCollide::GeometryRefVector& getOriginalGeometries() const;
849 
859  void moveTo( const agx::AffineMatrix4x4& target, agx::Real t );
860 
871  void moveTo( const agx::Vec3& targetPosition, const agx::Quat& targetRotation, agx::Real t );
872 
879  void updateMassProperties();
880 
891  void updateMassProperties( agx::UInt32 mask );
892 
899  agx::Real calculateMass() const;
900 
907  agx::Vec3 calculateCenterOfMassOffset( agx::Real mass = agx::Real() ) const;
908 
914  void setLinearVelocityZeroDamping( const agx::Vec3f& dir );
915 
921  void setAngularVelocityZeroDamping( const agx::Vec3f& dir );
922 
927  agx::Vec3f getLinearVelocityZeroDamping() const;
928 
933  agx::Vec3f getAngularVelocityZeroDamping() const;
934 
941  void setLinearVelocityDamping( float damping );
942 
949  void setLinearVelocityDamping( const agx::Vec3f& damping );
950 
957  void setAngularVelocityDamping( float damping );
958 
965  void setAngularVelocityDamping( const agx::Vec3f& damping );
966 
972  void setVelocityDamping( float damping );
973 
977  agx::Vec3f getLinearVelocityDamping() const;
978 
982  agx::Vec3f getAngularVelocityDamping() const;
983 
987  agx::Vec3 getLinearMomentum() const;
988 
992  agx::Vec3 getAngularMomentum() const;
993 
997  AGX_DEPRECATED(2.29.0.0)
998  agx::Real getPotentialEnergy() const;
999 
1003  AGX_DEPRECATED( 2.29.0.0 )
1004  agx::Real getTranslationalEnergy() const;
1005 
1009  AGX_DEPRECATED( 2.29.0.0 )
1010  agx::Real getRotationalEnergy() const;
1011 
1015  AGX_DEPRECATED( 2.29.0.0 )
1016  agx::Real getTotalEnergy() const;
1017 
1024  void setHandleAsParticle( bool handleAsParticle );
1025 
1029  bool getHandleAsParticle() const;
1030 
1035  agx::Vec3 getAcceleration() const;
1036 
1041  agx::Vec3 getAngularAcceleration() const;
1042 
1049  bool hasConstraints() const;
1050 
1057  agx::UInt16 getNumConstraints() const;
1058 
1063  agx::Referenced* getCustomData() const;
1064 
1074  void setCustomData( agx::Referenced* data );
1075 
1080  agx::Physics::RigidBodyPtr getEntity() const;
1081 
1086  void setEntity( agx::Physics::RigidBodyPtr entity );
1087 
1092  void transfer( agxData::EntityStorage* storage );
1093 
1097  agx::Vec3 getForce() const;
1098 
1102  agx::Vec3 getTorque() const;
1103 
1109  agx::MergeSplitBodyStorage* getBodyStorage();
1110 
1116  const agx::MergeSplitBodyStorage* getBodyStorage() const;
1117 
1121  bool hasBodyStorage() const;
1122 
1126  bool isPowerlineBody() const;
1127 
1131  void setIsPowerlineBody(bool isHydraulicBody);
1132 
1142  agx::AffineMatrix4x4 getMergedWorldTransform() const;
1143 
1147  bool isMerged() const;
1148 
1149 #ifndef SWIG
1151  inline static bool shouldIgnoreGravity(agx::RigidBodyState state)
1152  {
1153  return !state.enabled() ||
1154  state.motionControl() != agx::RigidBody::DYNAMICS ||
1155  state.powerline();
1156  }
1157 #endif
1158 
1164  {
1165  public:
1171 
1176  void setEnableMerge( bool flag );
1177 
1181  bool getEnableMerge() const;
1182 
1187  void setEnableSplit( bool flag );
1188 
1192  bool getEnableSplit() const;
1193 
1198  void setMergeOnlyWithStatic( bool flag );
1199 
1203  bool getMergeOnlyWithStatic() const;
1204 
1205  private:
1206  enum FLAGS
1207  {
1208  ENABLE_MERGE,
1209  ENABLE_SPLIT,
1210  ENABLE_MERGE_WITH_STATIC,
1211  NUM_ELEMENTS
1212  };
1213 
1214  typedef agx::BitArray<NUM_ELEMENTS> FlagVector;
1215 
1216  private:
1217  FlagVector m_flags;
1218  };
1219 
1223  agx::RigidBody::MergeSplitProperties& getMergeSplitProperties();
1224  const agx::RigidBody::MergeSplitProperties& getMergeSplitProperties() const;
1225 
1230  {
1231  public:
1235  enum State {
1236  AWAKE = 0,
1237  TIRED = 1,
1238  ASLEEP = 2
1239  };
1240 
1251  void setSleeping( bool flag );
1252 
1256  State getState() const;
1257 
1261  bool isSleeping( ) const;
1262 
1268  void setEnable( bool flag );
1269 
1273  bool getEnable( ) const;
1274 
1278  float getRestTime() const;
1279 
1280  protected:
1281  // Never create this outside of a RigidBody.
1282  AutoSleepProperties( RigidBody *body = nullptr );
1283 
1284  private:
1296  void setSleeping( bool flag, State state );
1297 
1302  void setState( State state );
1303 
1304  friend class RigidBody;
1305  friend class AutoSleep;
1307 
1309  void setRestTime( float t );
1310 
1311  private:
1312  float m_restTime;
1313  bool m_enabled;
1314  agx::UInt8 m_state;
1315  RigidBody *m_body;
1316  };
1317 
1321  agx::RigidBody::AutoSleepProperties& getAutoSleepProperties();
1322  const agx::RigidBody::AutoSleepProperties& getAutoSleepProperties() const;
1323 
1325 
1326  bool hasValidEntityIndex() const;
1327 
1328  protected:
1329  friend class DynamicsSystem;
1330  friend class GeometryListener;
1332  friend class MergeSplit;
1334  friend class AutoSleepProperties;
1335 
1336  virtual ~RigidBody();
1337 
1338  // Never use these
1341  RigidBody& operator = ( const agx::RigidBody& ) { return *this; }
1342 
1347  void setId( agx::UInt32 id );
1348 
1354 
1360 
1365 
1373 
1374  private:
1375  void init( const agx::Name& name );
1376 
1377  void incrementNumConstraints();
1378  void decrementNumConstraints();
1379  void resetNumConstraints();
1380 
1381  void removeAllGeometries();
1382  void appendGeometry( agxCollide::Geometry* geometry );
1383  void removeGeometry( agx::Physics::GeometryPtr before, agx::Physics::GeometryPtr toBeRemoved );
1384 
1386  friend class InternalData;
1390  agx::Referenced* getInternalData() const;
1391 
1395  void setInternalData( agx::Referenced* data );
1397 
1398  private:
1399  // Low level data.
1400  Physics::RigidBodyRef m_entity;
1401 
1402  mutable PropertyContainerRef m_propertyContainer;
1403 
1404  DynamicsSystem* m_mainSystem;
1405 
1406  AutoSleepThresholdRef m_autoSleepThreshold;
1407  MergeSplitThresholdRef m_mergeSplitThreshold;
1408 
1409  FrameRef m_frame;
1410  FrameRef m_cmFrame;
1411 
1412  MassProperties m_massProperties;
1413 
1414  agxCollide::GeometryRefVector m_geometries;
1415 
1416  typedef HashTable<agx::String, FrameRef > FrameTable;
1417  FrameTable m_namedAttachments;
1418 
1419  agx::ref_ptr<agx::Referenced> m_customData;
1420  agx::ref_ptr<agx::Referenced> m_internalData;
1421 
1422  MergeSplitBodyStorage* m_bodyStorage;
1423  MergeSplitProperties m_msProperties;
1424  AutoSleepProperties m_autoSleepProperties;
1425  };
1426 
1427  AGX_FORCE_INLINE bool RigidBody::getEnable() const
1428  {
1429  return m_entity.state().enabled();
1430  }
1431 
1433  {
1434  return m_entity.state().enabled();
1435  }
1436 
1438  {
1439  return (MotionControl)m_entity.state().motionControl();
1440  }
1441 
1443  {
1444  return ( m_propertyContainer.isValid() );
1445  }
1446 
1448  {
1449  if ( m_propertyContainer == nullptr )
1450  m_propertyContainer = new agx::PropertyContainer;
1451  return m_propertyContainer;
1452  }
1453 
1455  {
1456  return m_entity;
1457  }
1458 
1460  {
1461  return m_entity.id();
1462  }
1463 
1465  {
1466  return m_autoSleepThreshold;
1467  }
1468 
1470  {
1471  return m_autoSleepThreshold;
1472  }
1473 
1475  {
1476  return m_mergeSplitThreshold;
1477  }
1478 
1480  {
1481  return m_mergeSplitThreshold;
1482  }
1483 
1485  {
1486  return m_frame.get();
1487  }
1488 
1490  {
1491  return m_frame.get();
1492  }
1493 
1495  {
1496  return m_cmFrame.get();
1497  }
1498 
1500  {
1501  return m_cmFrame.get();
1502  }
1503 
1505  {
1506  return m_entity.cmTransform();
1507  }
1508 
1510  {
1511  return m_entity.velocity();
1512  }
1513 
1515  {
1516  return m_entity.angularVelocity();
1517  }
1518 
1520  {
1521  return getCmFrame()->getLocalTranslate();
1522  }
1523 
1525  {
1526  return getCmTransform().getTranslate();
1527  }
1528 
1530  {
1531  return getCmTransform().getRotate();
1532  }
1533 
1535  {
1536  return &m_massProperties;
1537  }
1538 
1540  {
1541  return &m_massProperties;
1542  }
1543 
1545  {
1546  return m_entity.state().handleAsParticle();
1547  }
1548 
1550  {
1551  return m_flags[ENABLE_MERGE];
1552  }
1553 
1555  {
1556  return m_flags[ENABLE_SPLIT];
1557  }
1558 
1560  {
1561  return m_flags[ENABLE_MERGE_WITH_STATIC];
1562  }
1563 
1565  {
1566  return m_msProperties;
1567  }
1568 
1570  {
1571  return m_msProperties;
1572  }
1573 
1575  {
1576  return (State)m_state;
1577  }
1578 
1580  {
1581  return m_enabled;
1582  }
1583 
1585  {
1586  return getState() == ASLEEP;
1587  }
1588 
1590  {
1591  return m_restTime;
1592  }
1593 
1594  AGX_FORCE_INLINE void RigidBody::AutoSleepProperties::setRestTime( float t )
1595  {
1596  m_restTime = t;
1597  }
1598 
1600  {
1601  return m_autoSleepProperties;
1602  }
1604  {
1605  return m_autoSleepProperties;
1606  }
1607 
1609  {
1610  return m_entity.linearAcceleration();
1611  }
1612 
1614  {
1615  return m_entity.angularAcceleration();
1616  }
1617 
1619  {
1620  return m_entity.numConstraints() > 0;
1621  }
1622 
1624  {
1625  return m_entity.numConstraints();
1626  }
1627 
1629  {
1630  return m_customData.get();
1631  }
1632 
1634  {
1635  return m_entity.modelTransform();
1636  }
1637 
1639  {
1640  return m_entity.modelTransform().getTranslate();
1641  }
1642 
1644  {
1645  return m_entity.modelTransform().getRotate();
1646  }
1647 
1648  inline Referenced* RigidBody::getInternalData() const
1649  {
1650  return m_internalData;
1651  }
1652 
1654  {
1655  setVelocity(agx::Vec3(vx,vy,vz));
1656  }
1657 
1659  {
1660  setAngularVelocity(agx::Vec3(vx,vy,vz));
1661  }
1662 
1664  {
1665  addForce( agx::Vec3(fx,fy,fz) );
1666  }
1667 
1669  {
1670  addForceAtPosition( agx::Vec3(fx,fy,fz), agx::Vec3(px,py,pz) );
1671  }
1672 
1674  {
1675  addForceAtLocalPosition( agx::Vec3(fx,fy,fz), agx::Vec3(px,py,pz) );
1676  }
1677 
1679  {
1680  addForceAtLocalCmPosition( agx::Vec3(fx,fy,fz), agx::Vec3(px,py,pz) );
1681  }
1682 
1684  {
1685  addTorque( agx::Vec3(tx,ty,tz) );
1686  }
1687 
1689  {
1690  addLocalTorque( agx::Vec3(tx, ty, tz) );
1691  }
1692 
1694  {
1695  setForce( agx::Vec3(fx,fy,fz) );
1696  }
1697 
1699  {
1700  setTorque( agx::Vec3(tx,ty,tz) );
1701  }
1702 
1703  inline bool RigidBody::isPowerlineBody() const
1704  {
1705  return m_entity.state().powerline();
1706  }
1707 
1708  inline void RigidBody::setIsPowerlineBody(bool isHydraulicBody)
1709  {
1710  m_entity.state().setPowerline(isHydraulicBody);
1711  }
1712 
1713 } // namespace agx
1714 
1715 #ifdef _MSC_VER
1716 # pragma warning(pop)
1717 #endif
1718 
1719 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Class that will investigate bodies to see if they are resting, that is if linear/angular velocity and...
Definition: AutoSleep.h:41
The complete physical system with bodies, interactions, data layout, time stepper,...
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Definition: EulerAngles.h:70
The object defining a frame of reference and providing transformations operations.
Definition: agx/Frame.h:68
Internal data for any object, ObjT, with methods: agx::Referenced* ObjT::getInternalData() const; voi...
Definition: InternalData.h:33
Inheritance with partial specialization due to bug with ref_ptr containers.
Class for rigid body inertia tensor and mass.
Book keeping of a body which can be merged with other bodies.
Class which will go through contacting/separating bodies and determine if the bodies can be merged (g...
Definition: MergeSplit.h:38
Representation of a name string.
Definition: Name.h:33
Specialized types of matrices for holding orthogonal transformation matrices.
Pointer to a entity instance of type Physics.Geometry.
Pointer to a entity instance of type Physics.RigidBody.
Class that is a container of named properties.
Definition: Property.h:129
void getRotate(T &angle, T &x, T &y, T &z) const
Get the angle and vector components represented by the quaternion.
Base class providing referencing counted objects.
Definition: Referenced.h:114
Data holder for auto-sleep properties.
Definition: RigidBody.h:1230
State
Specifies the state of auto sleep for this body.
Definition: RigidBody.h:1235
void setEnable(bool flag)
Enable/Disable auto sleep functionality for this body.
AutoSleepProperties(RigidBody *body=nullptr)
void setSleeping(bool flag)
Put the body into sleep or wake it up.
Data holder for merge-split properties.
Definition: RigidBody.h:1164
MergeSplitProperties()
Default constructor.
void setEnableSplit(bool flag)
Enable split.
void setEnableMerge(bool flag)
Enable merge.
void setMergeOnlyWithStatic(bool flag)
Enable merge only with static.
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
Definition: RigidBody.h:66
@ DYNAMICS
This body moves from the influence of forces.
Definition: RigidBody.h:69
void setLocalPosition(agx::Real x, agx::Real y, agx::Real z)
Set the position of the body relative to its model frame's parent frame.
agx::MergeSplitThreshold * getMergeSplitThreshold()
Returns custom merge-split parameters for this rigid body.
Definition: RigidBody.h:1474
void setLocalRotation(const agx::Quat &q)
Set the rotation of the body relative to its model frame's parent frame.
bool hasValidEntityIndex() const
agx::Vec3 getAngularAcceleration() const
Will always be 0 for KINEMATIC and STATIC bodies.
Definition: RigidBody.h:1613
void setLocalTransform(const agx::AffineMatrix4x4 &matrix)
Assign the local transformation matrix for this body, ignoring any eventual parent transformation.
const agx::AffineMatrix4x4 & getTransform() const
Current model frame transform, given in world coordinate frame.
Definition: RigidBody.h:1633
RigidBody * clone(bool shallowCopyRenderData=false) const
Create a clone of the rigid body.
void addForceAtLocalPosition(const agx::Vec3 &force, const agx::Vec3 &position)
Add a force, given in the world coordinate frame, applied at a point specified in the local Model coo...
void setPosition(agx::Real x, agx::Real y, agx::Real z)
Set the position of the model frame in world coordinates.
bool getHandleAsParticle() const
Definition: RigidBody.h:1544
agx::Quat getCmRotation() const
Definition: RigidBody.h:1529
agx::UInt32 getId() const
Internal method.
Definition: RigidBody.h:1459
agx::Frame * getCmFrame()
Return the center of mass (CM) frame of this rigid body.
Definition: RigidBody.h:1494
void setBodyStorage(agx::MergeSplitBodyStorage *bodyStorage)
Give this body a storage for merge-split.
void setRotation(const agx::Quat &q)
Set the rotation of the body relative to world frame.
void setAngularVelocity(const agx::Vec3 &angularVelocity)
Set the angular velocity of the center of mass of this rigid body.
void addForceAtPosition(const agx::Vec3 &force, const agx::Vec3 &position)
Add a force, given in the World coordinate frame, applied at a point specified in world coordinate fr...
void setSystem(agx::DynamicsSystem *system)
Assign dynamics system where this body belongs to.
bool isEnabled() const
Access the state enable flag.
Definition: RigidBody.h:1432
void addForce(const agx::Vec3 &force)
Add the specified force, given in world coordinate frame, that will be affecting this body in the nex...
agx::Vec3 getAngularVelocity() const
Angular velocity in world coordinate frame.
Definition: RigidBody.h:1514
agx::Quat getRotation() const
Current model frame rotation, given in world coordinate frame.
Definition: RigidBody.h:1643
void setVelocity(const agx::Vec3 &velocity)
Set the linear velocity of the center of mass of this rigid body.
void clearBodyStorage()
Clear the BodyStorage for this RigidBody.
void addForceAtLocalCmPosition(const agx::Vec3 &force, const agx::Vec3 &position)
Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass...
bool hasPropertyContainer() const
Definition: RigidBody.h:1442
agx::Physics::RigidBodyPtr getEntity() const
Internal method.
Definition: RigidBody.h:1454
agx::PropertyContainer * getPropertyContainer() const
Access property container of this rigid body.
Definition: RigidBody.h:1447
void incrementalMassPropertyUpdate(agx::UInt32 mask, int sign, const agxCollide::Geometry *geometry)
Will calculate new mass properties for this rigid body as the previously calculated one +/- the speci...
RigidBody(agxCollide::Geometry *geometry)
Construct given geometry.
agx::UInt16 getNumConstraints() const
Definition: RigidBody.h:1623
void setTransform(const agx::AffineMatrix4x4 &matrix)
Set the transform of the body.
void setTorque(const agx::Vec3 &torque)
Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the n...
agx::RigidBody::MergeSplitProperties & getMergeSplitProperties()
Definition: RigidBody.h:1564
void setRotation(const agx::OrthoMatrix3x3 &m)
Set the rotation of the body relative to world frame.
agx::Vec3 getPosition() const
Current model frame position, given in world coordinate frame.
Definition: RigidBody.h:1638
RigidBody(const agx::Name &name, agx::Physics::RigidBodyPtr entity)
agx::Vec3 getVelocity() const
Velocity of center of mass frame origin, in world coordinate frame.
Definition: RigidBody.h:1509
bool setParentFrame(agx::Frame *frame)
Set the parent frame of this body's model frame.
void setPosition(const agx::Vec3 &p)
Set the position of the model frame in world coordinates.
void setRotation(const agx::EulerAngles &e)
Set the rotation of the body relative to world frame.
void setId(agx::UInt32 id)
Assign dynamics system unique id to this rigid body.
const agx::AffineMatrix4x4 & getLocalTransform() const
const agx::Frame * getParentFrame() const
RigidBody(const agx::Name &name="")
Construct given name.
void addLocalTorque(agx::Real tx, agx::Real ty, agx::Real tz)
Adds the specified torque, given in Center of Mass coordinate frame that will be affecting this body ...
Definition: RigidBody.h:1688
void setLocalPosition(const agx::Vec3 &p)
Set the position of the body relative to its model frame's parent frame.
static bool shouldIgnoreGravity(agx::RigidBodyState state)
Definition: RigidBody.h:1151
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position,...
Definition: RigidBody.h:1484
const agx::MassProperties * getMassProperties() const
Definition: RigidBody.h:1539
agx::Vec3 getCmPosition() const
Definition: RigidBody.h:1524
virtual ~RigidBody()
bool isPowerlineBody() const
Definition: RigidBody.h:1703
void setForce(const agx::Vec3 &force)
Explicitly set the force, given in world coordinate frame, that will be affecting this body in the ne...
void setLocalRotation(const agx::EulerAngles &e)
Set the rotation of the body relative to its model frame's parent frame.
agx::Frame * getParentFrame()
agx::Referenced * getCustomData() const
Definition: RigidBody.h:1628
RigidBody(const agx::RigidBody &)
agx::Vec3 getCmLocalTranslate() const
Definition: RigidBody.h:1519
bool hasConstraints() const
Definition: RigidBody.h:1618
agx::Vec3 getLocalPosition() const
void addTorque(const agx::Vec3 &torque)
Adds the specified torque, given in world coordinate frame, that will be affecting this body in the n...
agx::AutoSleepThreshold * getAutoSleepThreshold()
Returns custom auto-sleep parameters for this rigid body.
Definition: RigidBody.h:1464
agx::Vec3 getAcceleration() const
Will always be 0 for KINEMATIC and STATIC bodies.
Definition: RigidBody.h:1608
agx::Quat getLocalRotation() const
const agx::AffineMatrix4x4 & getCmTransform() const
Convenience methods for center of mass frame.
Definition: RigidBody.h:1504
void setIsPowerlineBody(bool isHydraulicBody)
Internal method.
Definition: RigidBody.h:1708
agx::RigidBody::AutoSleepProperties & getAutoSleepProperties()
Definition: RigidBody.h:1599
agx::RigidBody::MotionControl getMotionControl() const
Definition: RigidBody.h:1437
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:49
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:38
#define AGX_DEPRECATED(since)
Definition: macros.h:89
#define CALLABLE_UNIT(param)
Definition: macros.h:73
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
agx::Vector< agx::ref_ptr< Geometry > > GeometryRefVector
Contains classes for low level data storage for AGX.
Definition: Container.h:23
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.
AGXPHYSICS_EXPORT void setMotionControl(agx::RigidBodyPtrVector &bodies, agx::RigidBody::MotionControl motionControl)
Utility function to set motion control for a vector of rigid bodies.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint16_t UInt16
Definition: Integer.h:39
T sign(T v)
Definition: Math.h:328
uint32_t UInt32
Definition: Integer.h:40
double Real
Definition: Real.h:42
uint8_t UInt8
Definition: Integer.h:38
agx::SetVector< ref_ptr< RigidBody > > RigidBodyRefSetVector
Definition: RigidBody.h:49
void AGXPHYSICS_EXPORT init()
Initialize agx.