AGX Dynamics 2.38.0.0
|
The rigid body class, combining a geometric model and a frame of reference. More...
#include <RigidBody.h>
Public Types | |
enum | MotionControl { STATIC = 1 , KINEMATICS = 2 , DYNAMICS = 3 } |
The MotionControl enumeration indicates what makes a RigidBody move. More... | |
Public Member Functions | |
RigidBody (agxCollide::Geometry *geometry) | |
Construct given geometry. | |
RigidBody (const agx::Name &name="") | |
Construct given name. | |
bool | add (agxCollide::Geometry *geometry, bool incrementalMassCalculation=false) |
Add a geometry to this rigid body. | |
bool | add (agxCollide::Geometry *geometry, const agx::AffineMatrix4x4 &localTransform, bool incrementalMassCalculation=false) |
Connect a geometry to this rigid body. | |
bool | addAttachment (agx::Frame *frame, const agx::String &name) |
Add a named attachment frame to this rigid body. | |
void | addForce (agx::Real fx, agx::Real fy, agx::Real fz) |
Add the specified force, fx fy fz , given in world coordinate frame, that will be affecting this body in the next solve. | |
void | addForce (const agx::Vec3 &force) |
Add the specified force , given in world coordinate frame, that will be affecting this body in the next solve. | |
void | addForceAtLocalCmPosition (agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz) |
Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass coordinate frame. | |
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 coordinate frame. | |
void | addForceAtLocalPosition (agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz) |
Add a force given in world coordinate frame, applied at a point specified in local coordinate model frame. | |
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 coordinate frame. | |
void | addForceAtPosition (agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz) |
Add a force, given in the world coordinate frame, applied at a point specified in the world coordinate frame. | |
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 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 in the next solve. | |
void | addLocalTorque (const agx::Vec3 &torque) |
Adds the specified torque , given in Center of Mass coordinate frame that will be affecting this body in the next solve. | |
void | addTorque (agx::Real tx, agx::Real ty, agx::Real tz) |
Adds the specified torque , given in world coordinate frame, that will be affecting this body in the next solve. | |
void | addTorque (const agx::Vec3 &torque) |
Adds the specified torque , given in world coordinate frame, that will be affecting this body in the next solve. | |
AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agx::RigidBody) | |
agx::Vec3 | calculateCenterOfMassOffset (agx::Real mass=agx::Real()) const |
Calculate the center of mass offset of this rigid body using the volume and density of the added geometries. | |
agx::Real | calculateMass () const |
Calculate the mass of this rigid body using the volume and density of added geometries. | |
RigidBody * | clone (bool shallowCopyRenderData=false) const |
Create a clone of the rigid body. | |
agx::Vec3 | getAcceleration () const |
Will always be 0 for KINEMATIC and STATIC bodies. | |
agx::Vec3 | getAngularAcceleration () const |
Will always be 0 for KINEMATIC and STATIC bodies. | |
agx::Vec3 | getAngularMomentum () const |
agx::Vec3 | getAngularVelocity () const |
Angular velocity in world coordinate frame. | |
agx::Vec3f | getAngularVelocityDamping () const |
agx::Vec3f | getAngularVelocityZeroDamping () const |
Frame * | getAttachment (const agx::String &name) |
Access a named attachment frame. | |
agx::Frame * | getCmFrame () |
Return the center of mass (CM) frame of this rigid body. | |
const agx::Frame * | getCmFrame () const |
Return the center of mass (CM) frame of this rigid body. | |
agx::Vec3 | getCmLocalTranslate () const |
agx::Vec3 | getCmPosition () const |
agx::Quat | getCmRotation () const |
const agx::AffineMatrix4x4 & | getCmTransform () const |
Convenience methods for center of mass frame. | |
agx::Referenced * | getCustomData () const |
bool | getEnable () const |
Access the state enable flag. | |
agx::Physics::RigidBodyPtr | getEntity () const |
Internal method. | |
agx::Vec3 | getForce () const |
agx::Frame * | getFrame () |
Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc. | |
const agx::Frame * | getFrame () const |
Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc. | |
const agxCollide::GeometryRefVector & | getGeometries () const |
agxCollide::Geometry * | getGeometry (const agx::Name &name) |
Find (linear search) the first Geometry in the RigidBody with a matching name. | |
const agxCollide::Geometry * | getGeometry (const agx::Name &name) const |
Find (linear search) the first Geometry in the RigidBody with a matching name. | |
bool | getHandleAsParticle () const |
agx::UInt32 | getId () const |
Internal method. | |
agx::Vec3 | getLastForce () const |
Access the summed force applied to this rigid body last time the system was integrated. | |
agx::Vec3 | getLastTorque () const |
Access the summed torque applied to this rigid body last time the system was integrated. | |
agx::Vec3 | getLinearMomentum () const |
agx::Vec3f | getLinearVelocityDamping () const |
agx::Vec3f | getLinearVelocityZeroDamping () const |
agx::Vec3 | getLocalPosition () const |
agx::Quat | getLocalRotation () const |
const agx::AffineMatrix4x4 & | getLocalTransform () const |
agx::MassProperties * | getMassProperties () |
const agx::MassProperties * | getMassProperties () const |
agx::Vec3 | getModelAcceleration (const agx::Vec3 &relPos=agx::Vec3()) const |
Calculates the linear acceleration at the given point relPos . | |
agx::Vec3 | getModelVelocity (const agx::Vec3 &relPos=agx::Vec3()) const |
Calculates the linear velocity at the given point relPos . | |
agx::RigidBody::MotionControl | getMotionControl () const |
const agx::Name & | getName () const |
agx::UInt16 | getNumConstraints () const |
agx::Frame * | getParentFrame () |
const agx::Frame * | getParentFrame () const |
agx::Vec3 | getPosition () const |
Current model frame position, given in world coordinate frame. | |
agx::PropertyContainer * | getPropertyContainer () const |
Access property container of this rigid body. | |
agx::Quat | getRotation () const |
Current model frame rotation, given in world coordinate frame. | |
agx::DynamicsSystem * | getSystem () |
const agx::DynamicsSystem * | getSystem () const |
agx::Vec3 | getTorque () const |
const agx::AffineMatrix4x4 & | getTransform () const |
Current model frame transform, given in world coordinate frame. | |
agx::Vec3 | getVelocity () const |
Velocity of center of mass frame origin, in world coordinate frame. | |
bool | hasConstraints () const |
bool | hasPropertyContainer () const |
bool | hasValidEntityIndex () const |
bool | isEnabled () const |
Access the state enable flag. | |
bool | isPowerlineBody () const |
void | moveTo (const agx::AffineMatrix4x4 &target, agx::Real t) |
Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there. | |
void | moveTo (const agx::Vec3 &targetPosition, const agx::Quat &targetRotation, agx::Real t) |
Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there. | |
bool | remove (agxCollide::Geometry *geometry, bool incrementalMassCalculation=false) |
Remove geometry if geometry is part of this rigid body. | |
bool | removeAttachment (const agx::String &name) |
Remove an attachment from the rigid body. | |
void | setAngularVelocity (agx::Real vx, agx::Real vy, agx::Real vz) |
Set the angular velocity of the center of mass of this rigid body. | |
void | setAngularVelocity (const agx::Vec3 &angularVelocity) |
Set the angular velocity of the center of mass of this rigid body. | |
void | setAngularVelocityDamping (const agx::Vec3f &damping) |
Give angular velocity damping in each direction, given in local body coordinate frame. | |
void | setAngularVelocityDamping (float damping) |
Set angular velocity damping for the body in all directions x, y and z. | |
void | setAngularVelocityZeroDamping (const agx::Vec3f &dir) |
Specify a vector (in body coordinates) along which no angular velocity damping should occur. | |
void | setCmLocalTranslate (const agx::Vec3 &translate) |
Sets the local offset of the center of mass position to the model origin (in model frame coordinates). | |
void | setCmPosition (const agx::Vec3 &p, bool synchronizeModel=true) |
Assign new center of mass position, given in world coordinate frame. | |
void | setCmRotation (const agx::EulerAngles &e) |
Assign new center of mass rotation, given in world coordinate frame. | |
void | setCmRotation (const agx::OrthoMatrix3x3 &m) |
Assign new center of mass rotation, given in world coordinate frame. | |
void | setCmRotation (const agx::Quat &q) |
Assign new center of mass rotation, given in world coordinate frame. | |
void | setCmTransform (const agx::AffineMatrix4x4 &matrix, bool synchronizeModel=true) |
Assign new center of mass transform, given in world coordinate frame. | |
void | setCustomData (agx::Referenced *data) |
It's possible to derive from agx::Referenced and implement a reference counted object and associate it to this rigid body via this method. | |
void | setEnable (bool enable) |
Change state enable of this rigid body. | |
void | setEntity (agx::Physics::RigidBodyPtr entity) |
Internal method. | |
void | setForce (agx::Real fx, agx::Real fy, agx::Real fz) |
Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve. | |
void | setForce (const agx::Vec3 &force) |
Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve. | |
void | setHandleAsParticle (bool handleAsParticle) |
Set this, six degrees of freedom, rigid body to be handled as a three degrees of freedom particle (rotational degrees of freedom ignored). | |
void | setInertiaTensor (const agx::SPDMatrix3x3 &inertiaTensor, const agx::AffineMatrix4x4 &cmLocalTransform=agx::AffineMatrix4x4(), bool autogenerateCmOffset=false, bool autogenerateInertia=false) |
Convenience method for setting the inertia tensor from extern calculations given in local center of mass coordinate frame. | |
void | setInertiaTensor (const agx::Vec3 &inertiaDiagonal, const agx::AffineMatrix4x4 &cmLocalTransform=agx::AffineMatrix4x4(), bool autogenerateCmOffset=false, bool autogenerateInertia=false) |
Convenience method for setting the inertia tensor from extern calculations, in diagonal form, given in local center of mass coordinate frame. | |
void | setIsPowerlineBody (bool isHydraulicBody) |
Internal method. | |
void | setLinearVelocityDamping (const agx::Vec3f &damping) |
Give linear velocity damping in each direction, given in local body coordinate frame. | |
void | setLinearVelocityDamping (float damping) |
Set linear velocity damping for the body in all directions x, y and z. | |
void | setLinearVelocityZeroDamping (const agx::Vec3f &dir) |
Specify a vector (in body coordinates) along which no linear velocity damping should occur. | |
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. | |
void | setLocalPosition (const agx::Vec3 &p) |
Set the position of the body relative to its model frame's parent frame. | |
void | setLocalRotation (const agx::EulerAngles &e) |
Set the rotation of the body relative to its model frame's parent frame. | |
void | setLocalRotation (const agx::Quat &q) |
Set the rotation of the body relative to its model frame's parent frame. | |
void | setLocalTransform (const agx::AffineMatrix4x4 &matrix) |
Assign the local transformation matrix for this body, ignoring any eventual parent transformation. | |
void | setMotionControl (agx::RigidBody::MotionControl control) |
Assign new motion control state to this rigid body. | |
void | setName (const agx::Name &name) |
Assign new name to this rigid body. | |
bool | setParentFrame (agx::Frame *frame) |
Set the parent frame of this body's model frame. | |
void | setPosition (agx::Real x, agx::Real y, agx::Real z) |
Set the position of the model frame in world coordinates. | |
void | setPosition (const agx::Vec3 &p) |
Set the position of the model frame in world coordinates. | |
void | setPropertyContainer (agx::PropertyContainer *container) |
Assign new property container. | |
void | setRotation (const agx::EulerAngles &e) |
Set the rotation of the body relative to world frame. | |
void | setRotation (const agx::OrthoMatrix3x3 &m) |
Set the rotation of the body relative to world frame. | |
void | setRotation (const agx::Quat &q) |
Set the rotation of the body relative to world frame. | |
void | setTorque (agx::Real tx, agx::Real ty, agx::Real tz) |
Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve. | |
void | setTorque (const agx::Vec3 &torque) |
Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve. | |
void | setTransform (const agx::AffineMatrix4x4 &matrix) |
Set the transform of the body. | |
void | setVelocity (agx::Real vx, agx::Real vy, agx::Real vz) |
Set the linear velocity of the center of mass of this rigid body. | |
void | setVelocity (const agx::Vec3 &velocity) |
Set the linear velocity of the center of mass of this rigid body. | |
void | setVelocityDamping (float damping) |
Set both linear- and angular velocity damping in all directions. | |
void | transfer (agxData::EntityStorage *storage) |
Internal method. | |
void | updateMassProperties () |
Method to explicitly update mass properties. | |
void | updateMassProperties (agx::UInt32 mask) |
Method to explicitly update mass properties. | |
Public Member Functions inherited from agx::Referenced | |
Referenced () | |
Default constructor. | |
Referenced (const Referenced &) | |
template<typename T > | |
T * | as () |
Subclass casting. | |
template<typename T > | |
const T * | as () const |
template<typename T > | |
T * | asSafe () |
Safe subclass casting, return nullptr if template type does not match. | |
template<typename T > | |
const T * | asSafe () const |
int | getReferenceCount () const |
template<typename T > | |
bool | is () const |
Subclass test. | |
Referenced & | operator= (const Referenced &) |
Assignment operator. Will increment the number of references to the referenced object. | |
void | reference (void *ptr=nullptr) const |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. | |
void | unreference (void *ptr=nullptr) const |
Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
void | unreference_nodelete () const |
Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
Public Member Functions inherited from agxStream::Serializable | |
virtual | ~Serializable () |
Destructor for normal C++ use but hidden from SWIG bindings. | |
virtual const char * | getClassName () const |
bool | getEnableSerialization () const |
bool | getEnableUuidGeneration () |
agx::UInt32 | getIndex () const |
This index is given at creation of this object. | |
virtual StorageAgent * | getStorageAgent () const =0 |
agx::Uuid | getUuid () const |
bool | isFinished () const |
void | setEnableSerialization (bool flag) |
Set to false to disable serialization of this object. | |
void | setFinished () |
Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. | |
void | setUuid (const agx::Uuid &uuid) |
Explicitly set a Uuid on a serializable object. | |
Static Public Member Functions | |
static agxStream::Serializable * | create (agxStream::InputArchive &) |
static bool | shouldIgnoreGravity (agx::RigidBodyState state) |
Static Public Member Functions inherited from agx::Referenced | |
template<typename T > | |
static bool | ValidateCast (const Referenced *object) |
Static Public Member Functions inherited from agxStream::Serializable | |
static void | setEnableUuidGeneration (bool flag) |
Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. | |
Protected Member Functions | |
RigidBody (const agx::Name &name, agx::Physics::RigidBodyPtr entity) | |
RigidBody (const agx::RigidBody &) | |
virtual | ~RigidBody () |
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 specified geometry . | |
RigidBody & | operator= (const agx::RigidBody &) |
void | setId (agx::UInt32 id) |
Assign dynamics system unique id to this rigid body. | |
void | setSystem (agx::DynamicsSystem *system) |
Assign dynamics system where this body belongs to. | |
Protected Member Functions inherited from agx::Referenced | |
virtual | ~Referenced () |
Destructor. | |
void | allocateObserverVector () const |
void | deleteUsingDeleteHandler () const |
Protected Member Functions inherited from agxStream::Serializable | |
Serializable () | |
Default constructor. | |
Serializable (const Serializable &other) | |
Copy constructor. | |
void | generateUuid () |
Additional Inherited Members | |
Static Protected Member Functions inherited from agx::Referenced | |
static DeleteHandler * | getDeleteHandler () |
static void | setDeleteHandler (DeleteHandler *handler) |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
Protected Attributes inherited from agx::Referenced | |
Mutex | m_mutex |
ObserverContainer | m_observers |
AtomicValue | m_refCount |
The rigid body class, combining a geometric model and a frame of reference.
Definition at line 51 of file RigidBody.h.
The MotionControl enumeration indicates what makes a RigidBody move.
There are three forms of motion allowed:
Definition at line 62 of file RigidBody.h.
agx::RigidBody::RigidBody | ( | const agx::Name & | name = "" | ) |
Construct given name.
Default: mass = 1, inertia diagonal = (1, 1, 1), geometries = 0, position = (0, 0, 0), linear velocity = (0, 0, 0), angular velocity = (0, 0, 0), enable = true, motion control = DYNAMICS.
name | - name of this rigid body (default: "") |
agx::RigidBody::RigidBody | ( | agxCollide::Geometry * | geometry | ) |
Construct given geometry.
Mass properties will be updated given geometry
.
geometry | - first geometry to add to this rigid body |
|
protectedvirtual |
|
protected |
|
protected |
bool agx::RigidBody::add | ( | agxCollide::Geometry * | geometry, |
bool | incrementalMassCalculation = false |
||
) |
Add a geometry to this rigid body.
The frame of the geometry will be attached as a child to the model frame of this rigid body. The inertia, mass, and center of mass offset will be automatically recalculated using the material and volume of the geometry. However, any parameter explicitly set in the MassProperties (with auto generation flag disabled) will not be recalculated/updated. The local transformation in the geometry (geometry->getLocalTransform()) will be used to transform the geometry relative to the RigidBody.
incrementalMassCalculation:
Incremental mass properties calculation is computationally less expensive but may cause numerical drift if this method is used many times. If false, the current set of geometries will be used to calculate the mass properties, which in some extreme cases can be more computationally expensive (or cause general overhead). geometry | - the geometry to add |
incrementalMassCalculation | - false for full recalculation of mass properties, true for incremental calculation (see note) |
bool agx::RigidBody::add | ( | agxCollide::Geometry * | geometry, |
const agx::AffineMatrix4x4 & | localTransform, | ||
bool | incrementalMassCalculation = false |
||
) |
Connect a geometry to this rigid body.
The frame of the geometry will be attached as a child to the model frame of the rigid body. The inertia, mass, and center of mass offset will be automatically recalculated using the material and volume of the geometry. However, any parameter explicitly set in the MassProperties (with auto generation flag disabled) will not be recalculated/updated.
incrementalMassCalculation:
Incremental mass properties calculation is computationally less expensive but may cause numerical drift if this method is used many times. If false, the current set of geometries will be used to calculate the mass properties, which in some extreme cases can be more computationally expensive (or cause general overhead). geometry | - the geometry to add |
localTransform | - the relative transform to where the geometry should be placed relative model coordinate frame of this rigid body |
incrementalMassCalculation | - false for full recalculation of mass properties, true for incremental calculation (see note) |
Referenced by agxVehicle::utils::createGeometryBox().
bool agx::RigidBody::addAttachment | ( | agx::Frame * | frame, |
const agx::String & | name | ||
) |
Add a named attachment frame to this rigid body.
Add the specified force, fx
fy
fz
, given in world coordinate frame, that will be affecting this body in the next solve.
The force will be applied to the Center of Mass.
fx,fy,fz | - the force, given in world coordinate frame |
Definition at line 1286 of file RigidBody.h.
void agx::RigidBody::addForce | ( | const agx::Vec3 & | force | ) |
Add the specified force
, given in world coordinate frame, that will be affecting this body in the next solve.
The force will be applied to the Center of Mass.
force | - the force, given in world coordinate frame |
|
inline |
Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass coordinate frame.
If the position is different from (0,0,0) (CoM), this method will also introduce a torque.
fx,fy,fz | - the force, given in world coordinate frame, to be added to the already previously added forces |
px,py,pz | - the position in local center of mass coordinate frame where the force should be applied |
Definition at line 1301 of file RigidBody.h.
void agx::RigidBody::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 coordinate frame.
If the position is different from (0,0,0) (CoM), this method will also introduce a torque.
force | - the force, given in world coordinate frame, to be added to the already previously added forces |
position | - the position in local center of mass coordinate frame where the force should be applied |
|
inline |
Add a force given in world coordinate frame, applied at a point specified in local coordinate model frame.
If the position is different from the center of mass, a torque will be calculated and added as well.
fx,fy,fz | - the force, given in world coordinate frame, to be added to the already previously added forces |
px,py,pz | - the position given in local coordinate frame where the force should be applied |
Definition at line 1296 of file RigidBody.h.
void agx::RigidBody::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 coordinate frame.
If the position is different from the center of mass, a torque will be calculated and added as well.
force | - the force, given in world coordinate frame, to be added to the already previously added forces |
position | - the position given in local coordinate frame where the force should be applied |
|
inline |
Add a force, given in the world coordinate frame, applied at a point specified in the world coordinate frame.
If the position is different from the center of mass, a torque will be calculated and added as well.
fx,fy,fz | - the force, given in world coordinate frame, to be added to the already previously added forces |
px,py,pz | - the position given in world coordinate frame where the force should be applied |
Definition at line 1291 of file RigidBody.h.
Add a force, given in the World coordinate frame, applied at a point specified in world coordinate frame.
If the position is different from the center of mass, a torque will be calculated and added as well.
force | - the force, given in world coordinate frame, to be added to the already previously added forces |
position | - the position given in world coordinate frame where the force should be applied |
Adds the specified torque, given in Center of Mass coordinate frame that will be affecting this body in the next solve.
tx,ty,tz | - the torque, given in local coordinate frame |
Definition at line 1311 of file RigidBody.h.
void agx::RigidBody::addLocalTorque | ( | const agx::Vec3 & | torque | ) |
Adds the specified torque
, given in Center of Mass coordinate frame that will be affecting this body in the next solve.
torque | - the torque |
Adds the specified torque
, given in world coordinate frame, that will be affecting this body in the next solve.
tx,ty,tz | - the torque, given in world coordinate frame |
Definition at line 1306 of file RigidBody.h.
void agx::RigidBody::addTorque | ( | const agx::Vec3 & | torque | ) |
Adds the specified torque
, given in world coordinate frame, that will be affecting this body in the next solve.
torque | - the torque, given in world coordinate frame |
agx::RigidBody::AGXSTREAM_DECLARE_SERIALIZABLE_BASE | ( | agx::RigidBody | ) |
Calculate the center of mass offset of this rigid body using the volume and density of the added geometries.
mass | - if 0, the mass will be recalculated given the added geometries density and volume |
agx::Real agx::RigidBody::calculateMass | ( | ) | const |
Calculate the mass of this rigid body using the volume and density of added geometries.
RigidBody * agx::RigidBody::clone | ( | bool | shallowCopyRenderData = false | ) | const |
Create a clone of the rigid body.
|
inlinestatic |
Definition at line 1047 of file RigidBody.h.
Vec3 agx::RigidBody::getAcceleration | ( | ) | const |
Will always be 0 for KINEMATIC and STATIC bodies.
Definition at line 1231 of file RigidBody.h.
Vec3 agx::RigidBody::getAngularAcceleration | ( | ) | const |
Will always be 0 for KINEMATIC and STATIC bodies.
Definition at line 1236 of file RigidBody.h.
agx::Vec3 agx::RigidBody::getAngularMomentum | ( | ) | const |
Vec3 agx::RigidBody::getAngularVelocity | ( | ) | const |
Angular velocity in world coordinate frame.
Definition at line 1196 of file RigidBody.h.
Referenced by agxCollide::GeometryContact::calculateRelativeVelocity().
agx::Vec3f agx::RigidBody::getAngularVelocityDamping | ( | ) | const |
agx::Vec3f agx::RigidBody::getAngularVelocityZeroDamping | ( | ) | const |
Frame * agx::RigidBody::getAttachment | ( | const agx::String & | name | ) |
Access a named attachment frame.
name | - name of the attachment |
name
if it exist - otherwise null Frame * agx::RigidBody::getCmFrame | ( | ) |
Return the center of mass (CM) frame of this rigid body.
The CM frame is a child frame of the model frame. The center of mass offset is automatically calculated as geometries are added/removed, but this can be disabled in the mass properties of the rigid body.
Definition at line 1176 of file RigidBody.h.
const Frame * agx::RigidBody::getCmFrame | ( | ) | const |
Return the center of mass (CM) frame of this rigid body.
The CM frame is a child frame of the model frame. The center of mass offset is automatically calculated as geometries are added/removed, but this can be disabled in the mass properties of the rigid body.
Definition at line 1181 of file RigidBody.h.
Vec3 agx::RigidBody::getCmLocalTranslate | ( | ) | const |
Definition at line 1201 of file RigidBody.h.
Vec3 agx::RigidBody::getCmPosition | ( | ) | const |
Definition at line 1206 of file RigidBody.h.
Referenced by agxCollide::GeometryContact::calculateRelativeVelocity().
Quat agx::RigidBody::getCmRotation | ( | ) | const |
Definition at line 1211 of file RigidBody.h.
References agx::QuatT< T >::getRotate().
const AffineMatrix4x4 & agx::RigidBody::getCmTransform | ( | ) | const |
Convenience methods for center of mass frame.
The bool flag of the mutator(set) methods indicates if the update should sync back to the model frame (i.e. the model is updated using the relative change in center of mass while the local center of mass values are unchanged), or if the update only affects the local center of mass frame (which is analogous to the normal frame interface).
Definition at line 1186 of file RigidBody.h.
Referenced by agxOSG::ContainerShapeBatchRenderer< ContainerType, TransformType >::findTransform().
Referenced * agx::RigidBody::getCustomData | ( | ) | const |
bool agx::RigidBody::getEnable | ( | ) | const |
Access the state enable flag.
Definition at line 1129 of file RigidBody.h.
Referenced by agxCollide::Space::canCollide().
|
inline |
Internal method.
Data access.
Definition at line 1156 of file RigidBody.h.
Referenced by agx::MergedBody::isRoot().
agx::Vec3 agx::RigidBody::getForce | ( | ) | const |
Frame * agx::RigidBody::getFrame | ( | ) |
Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc.
Definition at line 1166 of file RigidBody.h.
Referenced by agxModel::NodeAttachment::createFromWorld().
const Frame * agx::RigidBody::getFrame | ( | ) | const |
Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc.
Definition at line 1171 of file RigidBody.h.
const agxCollide::GeometryRefVector & agx::RigidBody::getGeometries | ( | ) | const |
agxCollide::Geometry * agx::RigidBody::getGeometry | ( | const agx::Name & | name | ) |
Find (linear search) the first Geometry in the RigidBody with a matching name.
name | - name of geometry to search for |
const agxCollide::Geometry * agx::RigidBody::getGeometry | ( | const agx::Name & | name | ) | const |
Find (linear search) the first Geometry in the RigidBody with a matching name.
name | - name of geometry to search for |
bool agx::RigidBody::getHandleAsParticle | ( | ) | const |
Definition at line 1226 of file RigidBody.h.
UInt32 agx::RigidBody::getId | ( | ) | const |
Internal method.
The id this rigid body has in a system. This value may change when any other body is removed from a system.
Definition at line 1161 of file RigidBody.h.
agx::Vec3 agx::RigidBody::getLastForce | ( | ) | const |
Access the summed force applied to this rigid body last time the system was integrated.
agx::Vec3 agx::RigidBody::getLastTorque | ( | ) | const |
Access the summed torque applied to this rigid body last time the system was integrated.
agx::Vec3 agx::RigidBody::getLinearMomentum | ( | ) | const |
agx::Vec3f agx::RigidBody::getLinearVelocityDamping | ( | ) | const |
agx::Vec3f agx::RigidBody::getLinearVelocityZeroDamping | ( | ) | const |
agx::Vec3 agx::RigidBody::getLocalPosition | ( | ) | const |
agx::Quat agx::RigidBody::getLocalRotation | ( | ) | const |
const agx::AffineMatrix4x4 & agx::RigidBody::getLocalTransform | ( | ) | const |
MassProperties * agx::RigidBody::getMassProperties | ( | ) |
Definition at line 1216 of file RigidBody.h.
const MassProperties * agx::RigidBody::getMassProperties | ( | ) | const |
Definition at line 1221 of file RigidBody.h.
Calculates the linear acceleration at the given point relPos
.
The point relPos
must be given in model coordinate frame. The resulting linear acceleration is given in world coordinate frame.
relPos | - relative position given in model frame coordinates |
relPos
Calculates the linear velocity at the given point relPos
.
The point relPos
must be given in model coordinate frame. The resulting linear velocity is given in world coordinate frame.
relPos | - relative position given in model frame coordinates |
relPos
RigidBody::MotionControl agx::RigidBody::getMotionControl | ( | ) | const |
Definition at line 1139 of file RigidBody.h.
const agx::Name & agx::RigidBody::getName | ( | ) | const |
UInt16 agx::RigidBody::getNumConstraints | ( | ) | const |
Definition at line 1246 of file RigidBody.h.
agx::Frame * agx::RigidBody::getParentFrame | ( | ) |
const agx::Frame * agx::RigidBody::getParentFrame | ( | ) | const |
agx::Vec3 agx::RigidBody::getPosition | ( | ) | const |
Current model frame position, given in world coordinate frame.
Definition at line 1261 of file RigidBody.h.
agx::PropertyContainer * agx::RigidBody::getPropertyContainer | ( | ) | const |
Access property container of this rigid body.
This method will create a new property container object if one hasn't been assigned before. Hence it is recommended to use hasPropertyContainer before calling this method.
Definition at line 1149 of file RigidBody.h.
agx::Quat agx::RigidBody::getRotation | ( | ) | const |
Current model frame rotation, given in world coordinate frame.
Definition at line 1266 of file RigidBody.h.
References agx::QuatT< T >::getRotate().
agx::DynamicsSystem * agx::RigidBody::getSystem | ( | ) |
const agx::DynamicsSystem * agx::RigidBody::getSystem | ( | ) | const |
agx::Vec3 agx::RigidBody::getTorque | ( | ) | const |
const agx::AffineMatrix4x4 & agx::RigidBody::getTransform | ( | ) | const |
Current model frame transform, given in world coordinate frame.
Definition at line 1256 of file RigidBody.h.
Referenced by agxVehicle::Wheel::attachConstraint(), agxModel::NodeAttachment::createFromWorld(), and agxCable::SegmentAttachment::createFromWorld().
Vec3 agx::RigidBody::getVelocity | ( | ) | const |
Velocity of center of mass frame origin, in world coordinate frame.
Definition at line 1191 of file RigidBody.h.
Referenced by agxCollide::GeometryContact::calculateRelativeVelocity().
bool agx::RigidBody::hasConstraints | ( | ) | const |
Definition at line 1241 of file RigidBody.h.
bool agx::RigidBody::hasPropertyContainer | ( | ) | const |
Definition at line 1144 of file RigidBody.h.
bool agx::RigidBody::hasValidEntityIndex | ( | ) | const |
|
protected |
Will calculate new mass properties for this rigid body as the previously calculated one +/- the specified geometry
.
mask | - Specifies what will be updated |
sign | - 1 means adding, -1 means removing the geometry. |
geometry | - The geometry for which the mass properties will be added/removed |
References agx::init().
bool agx::RigidBody::isEnabled | ( | ) | const |
Access the state enable flag.
Definition at line 1134 of file RigidBody.h.
|
inline |
Definition at line 1326 of file RigidBody.h.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
void agx::RigidBody::moveTo | ( | const agx::AffineMatrix4x4 & | target, |
agx::Real | t | ||
) |
Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there.
This is basically only valid if motion control is set to KINEMATICS.
target | - target transform given in world coordinate frame |
t | - time this rigid body has to reach the target |
void agx::RigidBody::moveTo | ( | const agx::Vec3 & | targetPosition, |
const agx::Quat & | targetRotation, | ||
agx::Real | t | ||
) |
Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there.
This is basically only valid if motion control is set to KINEMATICS.
targetPosition | - target position given in world coordinate frame |
targetRotation | - target rotation given in world coordinate frame |
t | - time this rigid body has to reach the target |
|
inlineprotected |
Definition at line 1061 of file RigidBody.h.
bool agx::RigidBody::remove | ( | agxCollide::Geometry * | geometry, |
bool | incrementalMassCalculation = false |
||
) |
Remove geometry if geometry
is part of this rigid body.
incrementalMassCalculation:
Incremental mass properties calculation is computationally less expensive but may cause numerical drift if this method is used many times. If false, the current set of geometries will be used to calculate the mass properties, which in some extreme cases can be more computationally expensive (or cause general overhead). geometry | - geometry to remove |
incrementalMassCalculation | - false for full recalculation of mass properties, true for incremental calculation (see note) |
bool agx::RigidBody::removeAttachment | ( | const agx::String & | name | ) |
Remove an attachment from the rigid body.
Set the angular velocity of the center of mass of this rigid body.
This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial angular velocity. If motion control is set to STATIC then the angular velocity will be set to zero - independent of the value of angularVelocity
. This method is seen as an instantaneous change in angular velocity (infinite acceleration), and will therefore not be represented by getAngularAcceleration().
vx,vy,vz | - angular velocity given in world coordinate frame |
Definition at line 1281 of file RigidBody.h.
void agx::RigidBody::setAngularVelocity | ( | const agx::Vec3 & | angularVelocity | ) |
Set the angular velocity of the center of mass of this rigid body.
This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial angular velocity. If motion control is set to STATIC then the angular velocity will be set to zero - independent of the value of angularVelocity
. This method is seen as an instantaneous change in angular velocity (infinite acceleration), and will therefore not be represented by getAngularAcceleration().
angularVelocity | - angular velocity given in world coordinate frame |
void agx::RigidBody::setAngularVelocityDamping | ( | const agx::Vec3f & | damping | ) |
Give angular velocity damping in each direction, given in local body coordinate frame.
The unit of this damping is mass over time. Default: (0, 0, 0) (no damping).
damping | - the damping |
void agx::RigidBody::setAngularVelocityDamping | ( | float | damping | ) |
Set angular velocity damping for the body in all directions x, y and z.
The unit of this damping is mass over time. Default: 0 (no damping)
damping | - the damping |
void agx::RigidBody::setAngularVelocityZeroDamping | ( | const agx::Vec3f & | dir | ) |
Specify a vector (in body coordinates) along which no angular velocity damping should occur.
Default: (0, 0, 0)
dir | - direction, given in local body coordinate frame, in which the angular damping should be zero |
void agx::RigidBody::setCmLocalTranslate | ( | const agx::Vec3 & | translate | ) |
Sets the local offset of the center of mass position to the model origin (in model frame coordinates).
translate | The new offset. |
void agx::RigidBody::setCmPosition | ( | const agx::Vec3 & | p, |
bool | synchronizeModel = true |
||
) |
Assign new center of mass position, given in world coordinate frame.
By default the model frame will be updated as well (synchronizeModel
).
p | - new center of mass position given in world coordinate frame |
synchronizeModel | - default true, if false the model frame will not be updated with this new position |
void agx::RigidBody::setCmRotation | ( | const agx::EulerAngles & | e | ) |
Assign new center of mass rotation, given in world coordinate frame.
e | - new center of mass rotation (Euler angles) |
void agx::RigidBody::setCmRotation | ( | const agx::OrthoMatrix3x3 & | m | ) |
Assign new center of mass rotation, given in world coordinate frame.
m | - new center of mass rotation (Orthonormal matrix) |
void agx::RigidBody::setCmRotation | ( | const agx::Quat & | q | ) |
Assign new center of mass rotation, given in world coordinate frame.
q | - new center of mass rotation (quaternion) |
void agx::RigidBody::setCmTransform | ( | const agx::AffineMatrix4x4 & | matrix, |
bool | synchronizeModel = true |
||
) |
Assign new center of mass transform, given in world coordinate frame.
By default the model frame will be updated as well (synchronizeModel
).
matrix | - new matrix transform given in world coordinate frame |
synchronizeModel | - default true, if false the model frame will not be updated with this new transform. |
void agx::RigidBody::setCustomData | ( | agx::Referenced * | data | ) |
It's possible to derive from agx::Referenced and implement a reference counted object and associate it to this rigid body via this method.
If this rigid body is the only one holding a reference to the data, the data will be deleted when this rigid body is deleted.
data | - custom data |
void agx::RigidBody::setEnable | ( | bool | enable | ) |
Change state enable of this rigid body.
Default: true.
enable | - true to enable, false to disable |
void agx::RigidBody::setEntity | ( | agx::Physics::RigidBodyPtr | entity | ) |
Internal method.
Data access.
entity | - new rigid body entity |
Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve.
force
. fx,fy,fz | - the force |
Definition at line 1316 of file RigidBody.h.
void agx::RigidBody::setForce | ( | const agx::Vec3 & | force | ) |
Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve.
force
. force | - the force |
void agx::RigidBody::setHandleAsParticle | ( | bool | handleAsParticle | ) |
Set this, six degrees of freedom, rigid body to be handled as a three degrees of freedom particle (rotational degrees of freedom ignored).
Default: false
handleAsParticle | - if true this rigid body will be handled as a particle |
|
protected |
Assign dynamics system unique id to this rigid body.
id | - index to this rigid body in dynamics system |
void agx::RigidBody::setInertiaTensor | ( | const agx::SPDMatrix3x3 & | inertiaTensor, |
const agx::AffineMatrix4x4 & | cmLocalTransform = agx::AffineMatrix4x4() , |
||
bool | autogenerateCmOffset = false , |
||
bool | autogenerateInertia = false |
||
) |
Convenience method for setting the inertia tensor from extern calculations given in local center of mass coordinate frame.
inertiaTensor | - the externally computed inertia tensor given in local center of mass frame |
cmLocalTransform | - the frame in which the inertia tensor is given (optional, default: Identity) |
autogenerateCmOffset | - if true, the center of mass offset will be recalculated when the geometry configuration of the body changes (optional, default: false) |
autogenerateInertia | - if set to true, the inertia tensor will be recalculated when the geometry configuration of the body changes (optional, default: false) |
void agx::RigidBody::setInertiaTensor | ( | const agx::Vec3 & | inertiaDiagonal, |
const agx::AffineMatrix4x4 & | cmLocalTransform = agx::AffineMatrix4x4() , |
||
bool | autogenerateCmOffset = false , |
||
bool | autogenerateInertia = false |
||
) |
Convenience method for setting the inertia tensor from extern calculations, in diagonal form, given in local center of mass coordinate frame.
inertiaDiagonal | - the externally computed inertia tensor in diagonal form given in local center of mass coordinate frame defined by cmLocalTransform |
cmLocalTransform | - the frame in which the inertia tensor is given (optional, default: Identity) |
autogenerateCmOffset | - if true, the center of mass offset will be recalculated when the geometry configuration of the body changes (optional, default: false) |
autogenerateInertia | - if set to true, the inertia tensor will be recalculated when the geometry configuration of the body changes (optional, default: false) |
|
inline |
Internal method.
Definition at line 1331 of file RigidBody.h.
void agx::RigidBody::setLinearVelocityDamping | ( | const agx::Vec3f & | damping | ) |
Give linear velocity damping in each direction, given in local body coordinate frame.
The unit of this damping is mass over time. Default: (0, 0, 0) (no damping).
damping | - the damping |
void agx::RigidBody::setLinearVelocityDamping | ( | float | damping | ) |
Set linear velocity damping for the body in all directions x, y and z.
The unit of this damping is mass over time. Default: 0 (no damping)
damping | - the damping |
void agx::RigidBody::setLinearVelocityZeroDamping | ( | const agx::Vec3f & | dir | ) |
Specify a vector (in body coordinates) along which no linear velocity damping should occur.
Default: (0, 0, 0)
dir | - direction, given in local body coordinate frame, in which the linear damping should be zero |
Set the position of the body relative to its model frame's parent frame.
x | - local x translate |
y | - local y translate |
z | - local z translate |
void agx::RigidBody::setLocalPosition | ( | const agx::Vec3 & | p | ) |
Set the position of the body relative to its model frame's parent frame.
p | - local translate of body as a 3D vector |
void agx::RigidBody::setLocalRotation | ( | const agx::EulerAngles & | e | ) |
Set the rotation of the body relative to its model frame's parent frame.
e | - rotation given as Euler angles |
void agx::RigidBody::setLocalRotation | ( | const agx::Quat & | q | ) |
Set the rotation of the body relative to its model frame's parent frame.
q | - rotation given as a quaternion |
void agx::RigidBody::setLocalTransform | ( | const agx::AffineMatrix4x4 & | matrix | ) |
Assign the local transformation matrix for this body, ignoring any eventual parent transformation.
matrix | - transformation matrix relative to parent transform for the body's model frame |
void agx::RigidBody::setMotionControl | ( | agx::RigidBody::MotionControl | control | ) |
Assign new motion control state to this rigid body.
If new state is STATIC - linear- and angular velocity will be set to zero. Default: DYNAMICS
control | - new motion control |
void agx::RigidBody::setName | ( | const agx::Name & | name | ) |
Assign new name to this rigid body.
Default: ""
bool agx::RigidBody::setParentFrame | ( | agx::Frame * | frame | ) |
Set the parent frame of this body's model frame.
This means that getLocalTranslate, getLocalRotate, getLocalTransform will be given in the parents coordinate frame. I.e., this frame's transformation will be concatenated with the parents.
frame | - new parent frame, 0 to remove parent |
Set the position of the model frame in world coordinates.
x | - desired x-coordinate in world frame |
y | - desired y-coordinate in world frame |
z | - desired z-coordinate in world frame |
void agx::RigidBody::setPosition | ( | const agx::Vec3 & | p | ) |
Set the position of the model frame in world coordinates.
p | - desired position in world coordinates. |
void agx::RigidBody::setPropertyContainer | ( | agx::PropertyContainer * | container | ) |
Assign new property container.
container | - property container |
void agx::RigidBody::setRotation | ( | const agx::EulerAngles & | e | ) |
Set the rotation of the body relative to world frame.
e | - rotation given as Euler angles |
void agx::RigidBody::setRotation | ( | const agx::OrthoMatrix3x3 & | m | ) |
Set the rotation of the body relative to world frame.
m | - rotation given as an orthogonal transformation matrix |
void agx::RigidBody::setRotation | ( | const agx::Quat & | q | ) |
Set the rotation of the body relative to world frame.
q | - rotation given as a quaternion |
|
protected |
Assign dynamics system where this body belongs to.
system | - dynamics system this body belongs to |
Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve.
torque
. tx,ty,tz | - the torque |
Definition at line 1321 of file RigidBody.h.
void agx::RigidBody::setTorque | ( | const agx::Vec3 & | torque | ) |
Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve.
torque
. torque | - the torque |
void agx::RigidBody::setTransform | ( | const agx::AffineMatrix4x4 & | matrix | ) |
Set the transform of the body.
The model frame will move to the specified transform, which is given in world coordinate frame.
matrix | - desired transform for the model frame in world coordinates. |
Set the linear velocity of the center of mass of this rigid body.
This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial velocity. If motion control is set to STATIC then the linear velocity will be set to zero - independent of the value of velocity
. This method is seen as an instantaneous change in velocity (infinite acceleration), and will therefore not be represented by getAcceleration().
vx,vy,vz | - velocity given in world coordinate frame |
Definition at line 1276 of file RigidBody.h.
void agx::RigidBody::setVelocity | ( | const agx::Vec3 & | velocity | ) |
Set the linear velocity of the center of mass of this rigid body.
This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial velocity. If motion control is set to STATIC then the linear velocity will be set to zero - independent of the value of velocity
. This method is seen as an instantaneous change in velocity (infinite acceleration), and will therefore not be represented by getAcceleration().
velocity | - velocity given in world coordinate frame |
void agx::RigidBody::setVelocityDamping | ( | float | damping | ) |
Set both linear- and angular velocity damping in all directions.
damping | - the damping |
|
inlinestatic |
state
should not be affected by a gravity field. Definition at line 1037 of file RigidBody.h.
References DYNAMICS.
void agx::RigidBody::transfer | ( | agxData::EntityStorage * | storage | ) |
Internal method.
Transfer data from one storage to another.
storage | - new storage |
void agx::RigidBody::updateMassProperties | ( | ) |
Method to explicitly update mass properties.
E.g., when the density is changed on a material which this rigid body depends on. This method uses the current mass property update mask. I.e., if this rigid body has an explicitly assigned mass, mass will not be updated during this call.
void agx::RigidBody::updateMassProperties | ( | agx::UInt32 | mask | ) |
Method to explicitly update mass properties.
E.g., when the density is changed on a material which this rigid body depends on. This method takes the mass property update mask as argument. I.e., if this rigid body has an explicitly assigned mass, and mask
contains agx::MassProperties::MASS, a new mass will be calculated and assigned.
mask | - bit mask of agx::MassProperties::AutoGenerateFlags which mass properties that should be updated |