17 #ifndef AGX_RIGIDBODY_H 18 #define AGX_RIGIDBODY_H 36 # pragma warning(push) 37 # pragma warning(disable:4355) //Disable 'this' : used in base member initializer list warning 44 class MergeSplitBodyStorage;
91 RigidBody *clone(
bool shallowCopyRenderData=
false )
const;
134 void setLocalPosition(
const agx::Vec3& p );
171 void setLocalRotation(
const agx::Quat& q );
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;
393 agx::
Vec3 getLastForce() const;
402 agx::
Vec3 getLastTorque() const;
419 bool hasPropertyContainer() const;
430 const
agx::
Name& getName() const;
436 void setName( const
agx::
Name& name );
517 void setCmTransform( const
agx::
AffineMatrix4x4& matrix,
bool synchronizeModel = true );
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;
556 void setCmRotation( const
agx::
Quat& q);
609 void setInertiaTensor( const
agx::
Vec3& inertiaDiagonal, const
agx::AffineMatrix4x4& cmLocalTransform =
agx::AffineMatrix4x4(),
bool autogenerateCmOffset = false,
bool autogenerateInertia = false );
621 bool removeAttachment( const
agx::
String& name );
647 void setForce( const
agx::
Vec3& force );
665 void setTorque( const
agx::
Vec3& torque );
681 void addForce( const
agx::
Vec3& force );
696 void addForceAtPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
712 void addForceAtLocalPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
728 void addForceAtLocalCmPosition( const
agx::
Vec3& force, const
agx::
Vec3& position );
743 void addTorque( const
agx::
Vec3& torque );
764 void addLocalTorque( const
agx::
Vec3& torque );
785 bool add(
agxCollide::Geometry* geometry , const
agx::AffineMatrix4x4& localTransform,
bool incrementalMassCalculation = false );
810 bool add(
agxCollide::Geometry* geometry,
bool incrementalMassCalculation = false );
822 bool remove(
agxCollide::Geometry* geometry,
bool incrementalMassCalculation = false );
859 void moveTo( const
agx::AffineMatrix4x4& target,
agx::
Real t );
879 void updateMassProperties();
891 void updateMassProperties(
agx::
UInt32 mask );
899 agx::
Real calculateMass() const;
914 void setLinearVelocityZeroDamping( const
agx::
Vec3f& dir );
921 void setAngularVelocityZeroDamping( const
agx::
Vec3f& dir );
927 agx::
Vec3f getLinearVelocityZeroDamping() const;
933 agx::
Vec3f getAngularVelocityZeroDamping() const;
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 );
977 agx::
Vec3f getLinearVelocityDamping() const;
982 agx::
Vec3f getAngularVelocityDamping() const;
987 agx::
Vec3 getLinearMomentum() const;
992 agx::
Vec3 getAngularMomentum() const;
1000 void setHandleAsParticle(
bool handleAsParticle );
1005 bool getHandleAsParticle() const;
1011 agx::
Vec3 getAcceleration() const;
1017 agx::
Vec3 getAngularAcceleration() const;
1025 bool hasConstraints() const;
1062 void setEntity(
agx::Physics::RigidBodyPtr entity );
1068 void transfer(
agxData::EntityStorage* storage );
1097 bool hasBodyStorage() const;
1102 bool isPowerlineBody() const;
1107 void setIsPowerlineBody(
bool isHydraulicBody);
1118 agx::AffineMatrix4x4 getMergedWorldTransform() const;
1123 bool isMerged() const;
1126 inline static bool shouldIgnoreGravity(agx::RigidBodyState state)
1129 return !state.enabled() ||
1152 void setEnableMerge(
bool flag );
1157 bool getEnableMerge()
const;
1163 void setEnableSplit(
bool flag );
1168 bool getEnableSplit()
const;
1174 void setMergeOnlyWithStatic(
bool flag );
1179 bool getMergeOnlyWithStatic()
const;
1186 ENABLE_MERGE_WITH_STATIC,
1227 void setSleeping(
bool flag );
1232 State getState()
const;
1237 bool isSleeping( )
const;
1244 void setEnable(
bool flag );
1249 bool getEnable( )
const;
1254 float getRestTime()
const;
1272 void setSleeping(
bool flag,
State state );
1278 void setState(
State state );
1285 void setRestTime(
float t );
1302 bool hasValidEntityIndex()
const;
1306 friend class GeometryListener;
1340 void clearBodyStorage();
1353 void incrementNumConstraints();
1354 void decrementNumConstraints();
1355 void resetNumConstraints();
1357 void removeAllGeometries();
1393 FrameTable m_namedAttachments;
1405 return m_entity.state().enabled();
1410 return m_entity.state().enabled();
1420 return ( m_propertyContainer.isValid() );
1425 if ( m_propertyContainer ==
nullptr )
1427 return m_propertyContainer;
1437 return m_entity.id();
1442 return m_autoSleepThreshold;
1447 return m_autoSleepThreshold;
1452 return m_mergeSplitThreshold;
1457 return m_mergeSplitThreshold;
1462 return m_frame.get();
1467 return m_frame.get();
1472 return m_cmFrame.get();
1477 return m_cmFrame.get();
1482 return m_entity.cmTransform();
1487 return m_entity.velocity();
1492 return m_entity.angularVelocity();
1497 return getCmFrame()->getLocalTranslate();
1502 return getCmTransform().getTranslate();
1512 return &m_massProperties;
1517 return &m_massProperties;
1522 return m_entity.state().handleAsParticle();
1527 return m_flags[ENABLE_MERGE];
1532 return m_flags[ENABLE_SPLIT];
1537 return m_flags[ENABLE_MERGE_WITH_STATIC];
1542 return m_msProperties;
1547 return m_msProperties;
1552 return (
State)m_state;
1562 return getState() == ASLEEP;
1570 AGX_FORCE_INLINE void RigidBody::AutoSleepProperties::setRestTime(
float t )
1577 return m_autoSleepProperties;
1581 return m_autoSleepProperties;
1586 return m_entity.linearAcceleration();
1591 return m_entity.angularAcceleration();
1596 return m_entity.numConstraints() > 0;
1601 return m_entity.numConstraints();
1606 return m_customData.get();
1611 return m_entity.modelTransform();
1616 return m_entity.modelTransform().getTranslate();
1621 return m_entity.modelTransform().
getRotate();
1624 inline Referenced* RigidBody::getInternalData()
const 1626 return m_internalData;
1636 setAngularVelocity(
agx::Vec3(vx,vy,vz));
1666 addLocalTorque(
agx::Vec3(tx, ty, tz) );
1681 return m_entity.state().powerline();
1686 m_entity.state().setPowerline(isHydraulicBody);
1692 # 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 Dynamics API including thread resources and must be executed before using the AGX API...
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::Vector< agx::ref_ptr< Geometry > > GeometryRefVector
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position...
agx::SetVector< ref_ptr< RigidBody > > RigidBodyRefSetVector
agx::Quat getCmRotation() const
This namespace consists of a set of classes for handling geometric intersection tests including boole...
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.
The agx namespace 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.
#define AGX_DECLARE_VECTOR_TYPES(type)
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
Inheritance with partial specialization due to bug with ref_ptr containers.
#define DOXYGEN_END_INTERNAL_BLOCK()
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
#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
void setVelocity(const agx::Vec3 &velocity)
Set the linear velocity of the center of mass of this rigid body.