17 #ifndef AGX_RIGIDBODY_H
18 #define AGX_RIGIDBODY_H
36 # pragma warning(push)
37 # pragma warning(disable:4355)
44 class MergeSplitBodyStorage;
267 void setVelocity( const
agx::
Vec3& velocity );
293 void setAngularVelocity( const
agx::
Vec3& angularVelocity );
321 agx::
Vec3 getAngularVelocity() const;
348 void setEnable(
bool enable );
354 bool getEnable() const;
360 bool isEnabled() const;
419 bool hasPropertyContainer() const;
522 agx::
Vec3 getCmLocalTranslate() const;
528 void setCmLocalTranslate(const
agx::
Vec3& translate);
533 agx::
Vec3 getCmPosition() const;
541 void setCmPosition( const
agx::
Vec3& p,
bool synchronizeModel = true );
546 agx::
Quat getCmRotation() const;
712 void addForceAtLocalPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
728 void addForceAtLocalCmPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
764 void addLocalTorque( const
agx::
Vec3& torque );
810 bool add(
agxCollide::Geometry* geometry,
bool incrementalMassCalculation = false );
822 bool remove(
agxCollide::Geometry* geometry,
bool incrementalMassCalculation = false );
879 void updateMassProperties();
914 void setLinearVelocityZeroDamping( const
agx::
Vec3f& dir );
921 void setAngularVelocityZeroDamping( const
agx::
Vec3f& dir );
941 void setLinearVelocityDamping(
float damping );
949 void setLinearVelocityDamping( const
agx::
Vec3f& damping );
957 void setAngularVelocityDamping(
float damping );
965 void setAngularVelocityDamping( const
agx::
Vec3f& damping );
972 void setVelocityDamping(
float damping );
1024 void setHandleAsParticle(
bool handleAsParticle );
1029 bool getHandleAsParticle() const;
1035 agx::
Vec3 getAcceleration() const;
1041 agx::
Vec3 getAngularAcceleration() const;
1049 bool hasConstraints() const;
1086 void setEntity(
agx::Physics::RigidBodyPtr entity );
1121 bool hasBodyStorage() const;
1126 bool isPowerlineBody() const;
1131 void setIsPowerlineBody(
bool isHydraulicBody);
1147 bool isMerged() const;
1153 return !state.enabled() ||
1181 bool getEnableMerge()
const;
1192 bool getEnableSplit()
const;
1203 bool getMergeOnlyWithStatic()
const;
1210 ENABLE_MERGE_WITH_STATIC,
1256 State getState()
const;
1261 bool isSleeping( )
const;
1273 bool getEnable( )
const;
1278 float getRestTime()
const;
1296 void setSleeping(
bool flag,
State state );
1302 void setState(
State state );
1309 void setRestTime(
float t );
1330 friend class GeometryListener;
1377 void incrementNumConstraints();
1378 void decrementNumConstraints();
1379 void resetNumConstraints();
1381 void removeAllGeometries();
1429 return m_entity.state().enabled();
1434 return m_entity.state().enabled();
1444 return ( m_propertyContainer.isValid() );
1449 if ( m_propertyContainer ==
nullptr )
1451 return m_propertyContainer;
1461 return m_entity.id();
1466 return m_autoSleepThreshold;
1471 return m_autoSleepThreshold;
1476 return m_mergeSplitThreshold;
1481 return m_mergeSplitThreshold;
1486 return m_frame.get();
1491 return m_frame.get();
1496 return m_cmFrame.get();
1501 return m_cmFrame.get();
1506 return m_entity.cmTransform();
1511 return m_entity.velocity();
1516 return m_entity.angularVelocity();
1521 return getCmFrame()->getLocalTranslate();
1526 return getCmTransform().getTranslate();
1536 return &m_massProperties;
1541 return &m_massProperties;
1546 return m_entity.state().handleAsParticle();
1551 return m_flags[ENABLE_MERGE];
1556 return m_flags[ENABLE_SPLIT];
1561 return m_flags[ENABLE_MERGE_WITH_STATIC];
1566 return m_msProperties;
1571 return m_msProperties;
1576 return (
State)m_state;
1586 return getState() == ASLEEP;
1594 AGX_FORCE_INLINE void RigidBody::AutoSleepProperties::setRestTime(
float t )
1601 return m_autoSleepProperties;
1605 return m_autoSleepProperties;
1610 return m_entity.linearAcceleration();
1615 return m_entity.angularAcceleration();
1620 return m_entity.numConstraints() > 0;
1625 return m_entity.numConstraints();
1630 return m_customData.get();
1635 return m_entity.modelTransform();
1640 return m_entity.modelTransform().getTranslate();
1645 return m_entity.modelTransform().
getRotate();
1648 inline Referenced* RigidBody::getInternalData()
const
1650 return m_internalData;
1660 setAngularVelocity(
agx::Vec3(vx,vy,vz));
1690 addLocalTorque(
agx::Vec3(tx, ty, tz) );
1705 return m_entity.state().powerline();
1710 m_entity.state().setPowerline(isHydraulicBody);
1716 # pragma warning(pop)
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
The geometry representation used by the collision detection engine.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Class that will investigate bodies to see if they are resting, that is if linear/angular velocity and...
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...
The object defining a frame of reference and providing transformations operations.
Internal data for any object, ObjT, with methods: agx::Referenced* ObjT::getInternalData() const; voi...
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...
Representation of a name string.
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.
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.
Data holder for auto-sleep properties.
float getRestTime() const
State
Specifies the state of auto sleep for this body.
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.
MergeSplitProperties()
Default constructor.
void setEnableSplit(bool flag)
Enable split.
void setEnableMerge(bool flag)
Enable merge.
void setMergeOnlyWithStatic(bool flag)
Enable merge only with static.
bool getEnableSplit() const
bool getMergeOnlyWithStatic() const
bool getEnableMerge() const
The rigid body class, combining a geometric model and a frame of reference.
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
@ DYNAMICS
This body moves from the influence of forces.
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.
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.
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.
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
agx::Quat getCmRotation() const
agx::UInt32 getId() const
Internal method.
agx::Frame * getCmFrame()
Return the center of mass (CM) frame of this rigid body.
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.
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.
agx::Quat getRotation() const
Current model frame rotation, given in world coordinate frame.
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
agx::Physics::RigidBodyPtr getEntity() const
Internal method.
agx::PropertyContainer * getPropertyContainer() const
Access property container of this rigid body.
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
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()
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.
RigidBody(const agx::Name &name, agx::Physics::RigidBodyPtr entity)
agx::Vec3 getVelocity() const
Velocity of center of mass frame origin, in world coordinate frame.
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 ...
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)
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position,...
const agx::MassProperties * getMassProperties() const
agx::Vec3 getCmPosition() const
bool isPowerlineBody() const
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
RigidBody(const agx::RigidBody &)
agx::Vec3 getCmLocalTranslate() const
bool hasConstraints() const
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.
agx::Vec3 getAcceleration() const
Will always be 0 for KINEMATIC and STATIC bodies.
agx::Quat getLocalRotation() const
const agx::AffineMatrix4x4 & getCmTransform() const
Convenience methods for center of mass frame.
void setIsPowerlineBody(bool isHydraulicBody)
Internal method.
agx::RigidBody::AutoSleepProperties & getAutoSleepProperties()
agx::RigidBody::MotionControl getMotionControl() const
Specialized type of matrices for holding symmetric positive definite matrices.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
#define AGX_DEPRECATED(since)
#define CALLABLE_UNIT(param)
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
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.
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.
agx::SetVector< ref_ptr< RigidBody > > RigidBodyRefSetVector
void AGXPHYSICS_EXPORT init()
Initialize agx.