17 #ifndef AGX_RIGIDBODY_H 18 #define AGX_RIGIDBODY_H 35 # pragma warning(push) 36 # pragma warning(disable:4355) //Disable 'this' : used in base member initializer list warning 43 class MergeSplitBodyStorage;
132 void setLocalPosition(
const agx::Vec3& p );
169 void setLocalRotation(
const agx::Quat& q );
265 void setVelocity( const
agx::
Vec3& velocity );
291 void setAngularVelocity( const
agx::
Vec3& angularVelocity );
319 agx::
Vec3 getAngularVelocity() const;
346 void setEnable(
bool enable );
352 bool getEnable() const;
358 bool isEnabled() const;
391 agx::
Vec3 getLastForce() const;
400 agx::
Vec3 getLastTorque() const;
417 bool hasPropertyContainer() const;
428 const
agx::
Name& getName() const;
434 void setName( const
agx::
Name& name );
515 void setCmTransform( const
agx::
AffineMatrix4x4& matrix,
bool synchronizeModel = true );
520 agx::
Vec3 getCmLocalTranslate() const;
526 void setCmLocalTranslate(const
agx::
Vec3& translate);
531 agx::
Vec3 getCmPosition() const;
539 void setCmPosition( const
agx::
Vec3& p,
bool synchronizeModel = true );
544 agx::
Quat getCmRotation() const;
554 void setCmRotation( const
agx::
Quat& q);
607 void setInertiaTensor( const
agx::
Vec3& inertiaDiagonal, const
agx::AffineMatrix4x4& cmLocalTransform =
agx::AffineMatrix4x4(),
bool autogenerateCmOffset = false,
bool autogenerateInertia = false );
619 bool removeAttachment( const
agx::
String& name );
645 void setForce( const
agx::
Vec3& force );
663 void setTorque( const
agx::
Vec3& torque );
679 void addForce( const
agx::
Vec3& force );
694 void addForceAtPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
710 void addForceAtLocalPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
726 void addForceAtLocalCmPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
741 void addTorque( const
agx::
Vec3& torque );
762 void addLocalTorque( const
agx::
Vec3& torque );
783 bool add(
agxCollide::Geometry* geometry , const
agx::AffineMatrix4x4& localTransform,
bool incrementalMassCalculation = false );
808 bool add(
agxCollide::Geometry* geometry,
bool incrementalMassCalculation = false );
820 bool remove(
agxCollide::Geometry* geometry,
bool incrementalMassCalculation = false );
857 void moveTo( const
agx::AffineMatrix4x4& target,
agx::
Real t );
877 void updateMassProperties();
889 void updateMassProperties(
agx::
UInt32 mask );
897 agx::
Real calculateMass() const;
912 void setLinearVelocityZeroDamping( const
agx::
Vec3f& dir );
919 void setAngularVelocityZeroDamping( const
agx::
Vec3f& dir );
925 agx::
Vec3f getLinearVelocityZeroDamping() const;
931 agx::
Vec3f getAngularVelocityZeroDamping() const;
939 void setLinearVelocityDamping(
float damping );
947 void setLinearVelocityDamping( const
agx::
Vec3f& damping );
955 void setAngularVelocityDamping(
float damping );
963 void setAngularVelocityDamping( const
agx::
Vec3f& damping );
970 void setVelocityDamping(
float damping );
975 agx::
Vec3f getLinearVelocityDamping() const;
980 agx::
Vec3f getAngularVelocityDamping() const;
985 agx::
Vec3 getLinearMomentum() const;
990 agx::
Vec3 getAngularMomentum() const;
996 agx::
Real getPotentialEnergy() const;
1002 agx::
Real getTranslationalEnergy() const;
1008 agx::
Real getRotationalEnergy() const;
1014 agx::
Real getTotalEnergy() const;
1022 void setHandleAsParticle(
bool handleAsParticle );
1027 bool getHandleAsParticle() const;
1033 agx::
Vec3 getAcceleration() const;
1039 agx::
Vec3 getAngularAcceleration() const;
1047 bool hasConstraints() const;
1084 void setEntity(
agx::Physics::RigidBodyPtr entity );
1090 void transfer(
agxData::EntityStorage* storage );
1119 bool hasBodyStorage() const;
1124 bool isPowerlineBody() const;
1129 void setIsPowerlineBody(
bool isHydraulicBody);
1140 agx::AffineMatrix4x4 getMergedWorldTransform() const;
1145 bool isMerged() const;
1148 inline static bool shouldIgnoreGravity(agx::RigidBodyState state)
1151 return !state.enabled() ||
1174 void setEnableMerge(
bool flag );
1179 bool getEnableMerge()
const;
1185 void setEnableSplit(
bool flag );
1190 bool getEnableSplit()
const;
1196 void setMergeOnlyWithStatic(
bool flag );
1201 bool getMergeOnlyWithStatic()
const;
1208 ENABLE_MERGE_WITH_STATIC,
1249 void setSleeping(
bool flag );
1254 State getState()
const;
1259 bool isSleeping( )
const;
1266 void setEnable(
bool flag );
1271 bool getEnable( )
const;
1276 float getRestTime()
const;
1294 void setSleeping(
bool flag,
State state );
1300 void setState(
State state );
1307 void setRestTime(
float t );
1326 friend class GeometryListener;
1360 void clearBodyStorage();
1373 void incrementNumConstraints();
1374 void decrementNumConstraints();
1375 void resetNumConstraints();
1377 void removeAllGeometries();
1413 FrameTable m_namedAttachments;
1425 return m_entity.state().enabled();
1430 return m_entity.state().enabled();
1440 return ( m_propertyContainer.isValid() );
1445 if ( m_propertyContainer ==
nullptr )
1447 return m_propertyContainer;
1457 return m_entity.id();
1462 return m_autoSleepThreshold;
1467 return m_autoSleepThreshold;
1472 return m_mergeSplitThreshold;
1477 return m_mergeSplitThreshold;
1482 return m_frame.get();
1487 return m_frame.get();
1492 return m_cmFrame.get();
1497 return m_cmFrame.get();
1502 return m_entity.cmTransform();
1507 return m_entity.velocity();
1512 return m_entity.angularVelocity();
1517 return getCmFrame()->getLocalTranslate();
1522 return getCmTransform().getTranslate();
1532 return &m_massProperties;
1537 return &m_massProperties;
1542 return m_entity.state().handleAsParticle();
1547 return m_flags[ENABLE_MERGE];
1552 return m_flags[ENABLE_SPLIT];
1557 return m_flags[ENABLE_MERGE_WITH_STATIC];
1562 return m_msProperties;
1567 return m_msProperties;
1572 return (
State)m_state;
1582 return getState() == ASLEEP;
1590 AGX_FORCE_INLINE void RigidBody::AutoSleepProperties::setRestTime(
float t )
1597 return m_autoSleepProperties;
1601 return m_autoSleepProperties;
1606 return m_entity.linearAcceleration();
1611 return m_entity.angularAcceleration();
1616 return m_entity.numConstraints() > 0;
1621 return m_entity.numConstraints();
1626 return m_customData.get();
1631 return m_entity.modelTransform();
1636 return m_entity.modelTransform().getTranslate();
1641 return m_entity.modelTransform().
getRotate();
1644 inline Referenced* RigidBody::getInternalData()
const 1646 return m_internalData;
1656 setAngularVelocity(
agx::Vec3(vx,vy,vz));
1686 addLocalTorque(
agx::Vec3(tx, ty, tz) );
1701 return m_entity.state().powerline();
1706 m_entity.state().setPowerline(isHydraulicBody);
1712 # pragma warning(pop) bool getEnableSplit() const
agx::RigidBody::AutoSleepProperties & getAutoSleepProperties()
void getRotate(T &angle, T &x, T &y, T &z) const
Get the angle and vector components represented by the quaternion.
float getRestTime() const
bool getHandleAsParticle() const
void AGXPHYSICS_EXPORT init()
Initialize agx.
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::UInt32 getId() const
Internal method.
agx::Referenced * getCustomData() const
void setIsPowerlineBody(bool isHydraulicBody)
Internal method.
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position...
agx::Quat getCmRotation() const
agxCollide namespace consists of a set of classes for handling geometric intersection tests including...
bool getMergeOnlyWithStatic() const
Data holder for merge-split properties.
agx::Physics::RigidBodyPtr getEntity() const
Internal method.
bool hasConstraints() const
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...
agx::RigidBody::MotionControl getMotionControl() const
agx::RigidBody::MergeSplitProperties & getMergeSplitProperties()
bool getEnableMerge() const
const agx::AffineMatrix4x4 & getCmTransform() const
Convenience methods for center of mass frame.
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 ...
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
agx::Vec3 getVelocity() const
Velocity of center of mass frame origin, in world coordinate frame.
Representation of a name string.
agx::Quat getRotation() const
Current model frame rotation, given in world coordinate frame.
const agx::AffineMatrix4x4 & getTransform() const
Current model frame transform, given in world coordinate frame.
bool getEnable() const
Access the state enable flag.
void setForce(const agx::Vec3 &force)
Explicitly set the force, given in world coordinate frame, that will be affecting this body in the ne...
Base class providing referencing counted objects.
agx::Vec3 getPosition() const
Current model frame position, given in world coordinate frame.
The geometry representation used by the collision detection engine.
agx::Vec3 getCmPosition() const
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
agx::MergeSplitThreshold * getMergeSplitThreshold()
Returns custom merge-split parameters for this rigid body.
Pointer to a entity instance of type Physics.RigidBody.
Class which will go through contacting/separating bodies and determine if the bodies can be merged (g...
agx::Vec3 getAngularAcceleration() const
Will always be 0 for KINEMATIC and STATIC bodies.
Class that is a container of named properties.
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
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...
agx::AutoSleepThreshold * getAutoSleepThreshold()
Returns custom auto-sleep parameters for this rigid body.
Pointer to a entity instance of type Physics.Geometry.
#define CALLABLE_UNIT(param)
Specialized type of matrices for holding symmetric positive definite matrices.
Data holder for auto-sleep properties.
agx::Vec3 getAngularVelocity() const
Angular velocity in world coordinate frame.
void addForce(const agx::Vec3 &force)
Add the specified force, given in world coordinate frame, that will be affecting this body in the nex...
Contains classes for low level data storage for AGX.
Class for rigid body inertia tensor and mass.
bool hasPropertyContainer() const
bool isPowerlineBody() const
agx::UInt16 getNumConstraints() const
agx::Frame * getCmFrame()
Return the center of mass (CM) frame of this rigid body.
agx::Vec3 getCmLocalTranslate() const
The rigid body class, combining a geometric model and a frame of reference.
Internal data for any object, ObjT, with methods: agx::Referenced* ObjT::getInternalData() const; voi...
AGXPHYSICS_EXPORT void setMotionControl(agx::RigidBodyPtrVector &bodies, agx::RigidBody::MotionControl motionControl)
Utility function to set motion control for a vector of rigid bodies.
This body moves from the influence of forces.
Book keeping of a body which can be merged with other bodies.
The complete physical system with bodies, interactions, data layout, time stepper, and solver.
State
Specifies the state of auto sleep for this body.
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...
The object defining a frame of reference and providing transformations operations.
Class that will investigate bodies to see if they are resting, that is if linear/angular velocity and...
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
void setTorque(const agx::Vec3 &torque)
Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the n...
bool isEnabled() const
Access the state enable flag.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
agx::PropertyContainer * getPropertyContainer() const
Access property container of this rigid body.
agx::Vec3 getAcceleration() const
Will always be 0 for KINEMATIC and STATIC bodies.
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
agx::Vector< agx::ref_ptr< Geometry > > GeometryRefVector
#define AGX_DEPRECATED(since)
Inheritance with partial specialization due to bug with ref_ptr containers.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.
void setAngularVelocity(const agx::Vec3 &angularVelocity)
Set the angular velocity of the center of mass of this rigid body.
Specialized types of matrices for holding orthogonal transformation matrices.
const agx::MassProperties * getMassProperties() const
AGX_DECLARE_VECTOR_TYPES(Clock)
void setVelocity(const agx::Vec3 &velocity)
Set the linear velocity of the center of mass of this rigid body.