|
AGXDynamics
2.31.1.0
|
The object defining a frame of reference and providing transformations operations. More...
#include <Frame.h>
Inheritance diagram for agx::Frame:Public Member Functions | |
| Frame () | |
| Default constructor. More... | |
| Frame (const agxData::AttributePtr< AffineMatrix4x4 > &localTransform, const agxData::AttributePtr< AffineMatrix4x4 > &globalTransform) | |
| Frame with existing matrix storage. More... | |
| Frame (const agx::AffineMatrix4x4 matrix) | |
| Instantiate a frame with relative transformation matrix. More... | |
| Frame (const agx::Frame &frame) | |
| Copy constructor. More... | |
| bool | allowTransferDataIntoChildren () const |
| template<typename T > | |
| T * | as () |
| Subclass casting. More... | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. More... | |
| template<typename T > | |
| const T * | asSafe () const |
| const char * | getClassName () const override |
| bool | getEnableSerialization () const |
| bool | getEnableUuidGeneration () |
| agx::UInt32 | getIndex () const |
| This index is given at creation of this object. More... | |
| const agx::AffineMatrix4x4 & | getLocalMatrix () const |
| Quat | getLocalRotate () const |
| agx::Vec3 | getLocalTranslate () const |
| const agx::AffineMatrix4x4 & | getMatrix () const |
| agx::Frame * | getParent () |
| const agx::Frame * | getParent () const |
| int | getReferenceCount () const |
| agx::RigidBody * | getRigidBody () |
| const agx::RigidBody * | getRigidBody () const |
| agx::Quat | getRotate () const |
| agxStream::StorageAgent * | getStorageAgent () const override |
| agx::Vec3 | getTranslate () const |
| agx::Uuid | getUuid () const |
| bool | hasChildren () const |
| bool | hasParent () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. More... | |
| bool | isFinished () const |
| bool | isFinite () const |
| Frame & | operator= (const agx::Frame &frame) |
| Assignment operator. More... | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| void | removeAllChildren () |
| Remove all children of this frame. More... | |
| bool | removeChild (agx::Frame *frame) |
| Remove a specified frame from the list of children. More... | |
| virtual void | restore (agxStream::InputArchive &in) override |
| void | setAllowTransferIntoChildren (bool allow) |
| Specifies whether a transferDataIntoLeaves() operation will go into this frames children (including any attached bodies) and concatenating transformations. More... | |
| void | setEnableSerialization (bool flag) |
| Set to false to disable serialization of this object. More... | |
| void | setEntityData (agxData::AttributePtr< agx::AffineMatrix4x4 > localTransform, agxData::AttributePtr< agx::AffineMatrix4x4 > globalTransform) |
| Assign entity data. More... | |
| void | setFinished () |
| Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More... | |
| void | setLocalMatrix (const agx::AffineMatrix4x4 &matrix) |
| Assign the local transformation matrix for this frame ignoring any eventual parent transformation. More... | |
| void | setLocalRotate (const agx::Quat &rotation) |
| Assign the parent relative rotation of this frame. More... | |
| void | setLocalRotate (const agx::EulerAngles &rotation) |
| Assign the parent relative rotation of this frame. More... | |
| void | setLocalTranslate (const agx::Vec3 &translate) |
| Assign the parent relative translate of this frame. More... | |
| void | setLocalTranslate (agx::Real x, agx::Real y, agx::Real z) |
| Assign the parent relative translate of this frame. More... | |
| void | setMatrix (const agx::AffineMatrix4x4 &matrix) |
This method will set the local matrix of this frame to be the matrix m multiplied with the inverse of the parents matrix: M = m * inv(parent) I.e., assign the final (world) transform of this frame. More... | |
| void | setMatrixPointers (const agxData::AttributePtr< agx::AffineMatrix4x4 > &localTransform, const agxData::AttributePtr< agx::AffineMatrix4x4 > &globalTransform) |
| Internal method. More... | |
| bool | setParent (agx::Frame *frame) |
| Set the parent of this Frame. More... | |
| void | setRotate (const agx::Quat &rotation) |
| Assign the final (world) rotation of this frame. More... | |
| void | setRotate (const agx::OrthoMatrix3x3 &rotation) |
| Assign the final (world) rotation of this frame. More... | |
| void | setRotate (const agx::EulerAngles &euler) |
| Assign the final (world) rotation of this frame. More... | |
| void | setTranslate (const agx::Vec3 &translate) |
| Assign the final (world) translate of this frame. More... | |
| void | setTranslate (agx::Real x, agx::Real y, agx::Real z) |
| Assign the final (world) translate of this frame. More... | |
| void | setUuid (const agx::Uuid &uuid) |
| Explicitly set a Uuid on a serializable object. More... | |
| virtual void | store (agxStream::OutputArchive &out) const override |
| void | transferChildren (agx::Frame *newParent) |
Move all the frame children of this frame to the new parent while retaining the original global transformation. More... | |
| void | transferDataIntoLeaves (bool keepLocalVelocity=true, bool clearTransform=true) |
| This method takes the transformation stored in this frame, and concatenates it to all of its children. More... | |
| agx::Vec3 | transformPointToLocal (const agx::Vec3 &pointWorld) const |
| Transform point from the world coordinate frame to this frame. More... | |
| agx::Vec3 | transformPointToLocal (agx::Real px, agx::Real py, agx::Real pz) const |
| Transform point from the world coordinate frame to this frame. More... | |
| agx::Vec3 & | transformPointToLocal (const agx::Vec3 &pointWorld, agx::Vec3 &pointLocal) const |
| Transform point from the world coordinate frame to this frame. More... | |
| agx::Vec3 | transformPointToWorld (const agx::Vec3 &pointLocal) const |
| Transform point from this frame to the world frame. More... | |
| agx::Vec3 | transformPointToWorld (agx::Real px, agx::Real py, agx::Real pz) const |
| Transform point from this frame to the world frame. More... | |
| agx::Vec3 & | transformPointToWorld (const agx::Vec3 &localPoint, agx::Vec3 &worldPoint) const |
| Transform point from this frame to the world frame. More... | |
| agx::Vec3 | transformVectorToLocal (const agx::Vec3 &worldVector) const |
| Transform vector from the world coordinate frame to this frame. More... | |
| agx::Vec3 | transformVectorToLocal (agx::Real vx, agx::Real vy, agx::Real vz) const |
| Transform vector from the world coordinate frame to this frame. More... | |
| agx::Vec3 & | transformVectorToLocal (const agx::Vec3 &vectorWorld, agx::Vec3 &vectorLocal) const |
| Transform vector from the world coordinate frame to this frame. More... | |
| agx::Vec3 | transformVectorToWorld (const agx::Vec3 &vectorLocal) const |
| Transform vector from this frame to the world frame. More... | |
| agx::Vec3 | transformVectorToWorld (agx::Real vx, agx::Real vy, agx::Real vz) const |
| Transform vector from this frame to the world frame. More... | |
| agx::Vec3 & | transformVectorToWorld (const agx::Vec3 &localVector, agx::Vec3 &worldVector) const |
| Transform vector from this frame to the world frame. More... | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | updateLocalMatrix () |
| Internal method. More... | |
| void | updateLocalMatrixSSE () |
| Internal method. More... | |
Static Public Member Functions | |
| static agxStream::Serializable * | create () |
| static agxStream::Serializable * | create (agxStream::InputArchive &) |
| static const char * | getConstructClassId () |
| static void | setEnableUuidGeneration (bool flag) |
| Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More... | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Protected Member Functions | |
| virtual | ~Frame () |
| Protected destructor - reference counted object. More... | |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
| void | generateUuid () |
Static Protected Member Functions | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More... | |
Protected Attributes | |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
The object defining a frame of reference and providing transformations operations.
A frame can have a parent. If so, localToWorld transformation is the concatenation of this frames transformation with the parents.
A frame can convert vectors and points into its parents coordinate system.
A frame of reference can be kinematic in which case the velocity and angular velocities are important objects.
A frame can internally be set to static, which means that getVelocity will always return zero.
| agx::Frame::Frame | ( | ) |
Default constructor.
| agx::Frame::Frame | ( | const agxData::AttributePtr< AffineMatrix4x4 > & | localTransform, |
| const agxData::AttributePtr< AffineMatrix4x4 > & | globalTransform | ||
| ) |
Frame with existing matrix storage.
|
explicit |
Instantiate a frame with relative transformation matrix.
| matrix | - transformation matrix that will be this frame's local matrix |
| agx::Frame::Frame | ( | const agx::Frame & | frame | ) |
Copy constructor.
| frame | - other frame |
|
protectedvirtual |
Protected destructor - reference counted object.
|
protectedinherited |
| bool agx::Frame::allowTransferDataIntoChildren | ( | ) | const |
|
inherited |
Subclass casting.
Template type must match actual type, dynamic_cast assertion will fail otherwise.
Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
|
inlinestatic |
|
inlinestatic |
|
protectedinherited |
|
protectedinherited |
|
inlineoverridevirtual |
Reimplemented from agxStream::Serializable.
|
inlinestatic |
|
staticprotectedinherited |
|
inherited |
Definition at line 273 of file Serializable.h.
|
inherited |
|
inherited |
This index is given at creation of this object.
It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.
Definition at line 247 of file Serializable.h.
| const AffineMatrix4x4 & agx::Frame::getLocalMatrix | ( | ) | const |
| Quat agx::Frame::getLocalRotate | ( | ) | const |
| Vec3 agx::Frame::getLocalTranslate | ( | ) | const |
| const agx::AffineMatrix4x4& agx::Frame::getMatrix | ( | ) | const |
Referenced by getTranslate(), setMatrix(), setTranslate(), transformPointToLocal(), transformPointToWorld(), transformVectorToLocal(), and transformVectorToWorld().
| Frame * agx::Frame::getParent | ( | ) |
Definition at line 506 of file Frame.h.
Referenced by setMatrix(), and setTranslate().
| const Frame * agx::Frame::getParent | ( | ) | const |
|
inherited |
| agx::RigidBody * agx::Frame::getRigidBody | ( | ) |
Definition at line 680 of file Frame.h.
References agx::observer_ptr< T >::get().
| const agx::RigidBody * agx::Frame::getRigidBody | ( | ) | const |
| agx::Quat agx::Frame::getRotate | ( | ) | const |
|
inlineoverridevirtual |
Implements agxStream::Serializable.
| Vec3 agx::Frame::getTranslate | ( | ) | const |
Definition at line 532 of file Frame.h.
References getMatrix(), and agx::Matrix4x4T< T >::getTranslate().
|
inherited |
Definition at line 268 of file Serializable.h.
| bool agx::Frame::hasChildren | ( | ) | const |
Definition at line 655 of file Frame.h.
References agx::SetVector< DataT, HashT >::empty().
| bool agx::Frame::hasParent | ( | ) | const |
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::Buffer::getElement(), and agx::Object::getResource().
|
inherited |
Definition at line 252 of file Serializable.h.
| bool agx::Frame::isFinite | ( | ) | const |
| Frame& agx::Frame::operator= | ( | const agx::Frame & | frame | ) |
Assignment operator.
| frame | - other frame |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
This method should be used with care, always balanced with the same number of calls to unreference.
Referenced by agxData::Val< UInt >::Val().
| void agx::Frame::removeAllChildren | ( | ) |
Remove all children of this frame.
Definition at line 660 of file Frame.h.
References agx::SetVector< DataT, HashT >::begin(), agx::SetVector< DataT, HashT >::clear(), and agx::SetVector< DataT, HashT >::end().
| bool agx::Frame::removeChild | ( | agx::Frame * | frame | ) |
Remove a specified frame from the list of children.
| frame | - the child frame to remove |
Definition at line 670 of file Frame.h.
References agx::SetVector< DataT, HashT >::erase().
|
overridevirtual |
| void agx::Frame::setAllowTransferIntoChildren | ( | bool | allow | ) |
Specifies whether a transferDataIntoLeaves() operation will go into this frames children (including any attached bodies) and concatenating transformations.
Frames are usually setup in a hierarchy, a root->transferDataIntoLeaves() will take the transformation from the root concatenate transformation on the way down to the leave, where the transformation will be stored, in a body, or a leaf frame. If you call child->setAllowTransferDataIntoChildren( false ); the concatenated transformation will stop at the child, leaving its children untouched.
| allow | - true if transfer is allowed |
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
|
inherited |
Set to false to disable serialization of this object.
It will just be ignored during serialization (writing). It is still possible to restore TO this object.
|
staticinherited |
Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
| void agx::Frame::setEntityData | ( | agxData::AttributePtr< agx::AffineMatrix4x4 > | localTransform, |
| agxData::AttributePtr< agx::AffineMatrix4x4 > | globalTransform | ||
| ) |
Assign entity data.
|
inherited |
Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
| void agx::Frame::setLocalMatrix | ( | const agx::AffineMatrix4x4 & | matrix | ) |
Assign the parent relative rotation of this frame.
| rotation | - parent relative rotation |
| void agx::Frame::setLocalRotate | ( | const agx::EulerAngles & | rotation | ) |
Assign the parent relative rotation of this frame.
| rotation | - parent relative rotation |
Assign the parent relative translate of this frame.
| translate | - parent relative translate |
Definition at line 557 of file Frame.h.
Referenced by setLocalTranslate().
Assign the parent relative translate of this frame.
| x | - parent relative x translate |
| y | - parent relative y translate |
| z | - parent relative z translate |
Definition at line 563 of file Frame.h.
References setLocalTranslate().
| void agx::Frame::setMatrix | ( | const agx::AffineMatrix4x4 & | matrix | ) |
This method will set the local matrix of this frame to be the matrix m multiplied with the inverse of the parents matrix: M = m * inv(parent) I.e., assign the final (world) transform of this frame.
| matrix | - final transform for this frame (leads to local transform = matrix * inv(parent)) |
Definition at line 490 of file Frame.h.
References getMatrix(), getParent(), and agx::AffineMatrix4x4T< T >::inverse().
| void agx::Frame::setMatrixPointers | ( | const agxData::AttributePtr< agx::AffineMatrix4x4 > & | localTransform, |
| const agxData::AttributePtr< agx::AffineMatrix4x4 > & | globalTransform | ||
| ) |
Internal method.
Assign transforms to this frame with existing matrix storage.
| bool agx::Frame::setParent | ( | agx::Frame * | frame | ) |
Set the parent of this Frame.
This means that getTranslate, getRotate, getTransform 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 |
Assign the final (world) rotation of this frame.
| rotation | - final (world) rotate |
| void agx::Frame::setRotate | ( | const agx::OrthoMatrix3x3 & | rotation | ) |
Assign the final (world) rotation of this frame.
| rotation | - final (world) rotate |
| void agx::Frame::setRotate | ( | const agx::EulerAngles & | euler | ) |
Assign the final (world) rotation of this frame.
| euler | - final (world) rotate |
Assign the final (world) translate of this frame.
| translate | - final (world) translate of this frame |
Definition at line 537 of file Frame.h.
References getMatrix(), getParent(), and agx::AffineMatrix4x4T< T >::inverse().
Referenced by setTranslate().
Assign the final (world) translate of this frame.
| x | - final (world) x translate of this frame |
| y | - final (world) y translate of this frame |
| z | - final (world) z translate of this frame |
Definition at line 547 of file Frame.h.
References setTranslate().
Explicitly set a Uuid on a serializable object.
Use this method with great care, as it can result in non-unique identifiers in the system!
|
overridevirtual |
| void agx::Frame::transferChildren | ( | agx::Frame * | newParent | ) |
Move all the frame children of this frame to the new parent while retaining the original global transformation.
That is, the matrix (getMatrix()) of all children will be the same after the move. Can Throw exception if newFrame is child of this frame, because we cannot have frames being parents to them self.
| newParent | - parent frame |
| void agx::Frame::transferDataIntoLeaves | ( | bool | keepLocalVelocity = true, |
| bool | clearTransform = true |
||
| ) |
This method takes the transformation stored in this frame, and concatenates it to all of its children.
The transform for all frames between this and the leaf will be set to identity. So you can safely call transferDataIntoLeaves on a parent frame to a rigid body, and then remove the rigid body as a child of this frame. The transformation of the rigid body will be the same.
The local velocity of bodies will be retained. So If you have a body moving along positive Y, add parent frame which rotates 90deg negative around Y, the body keep moving along positive Y (in World coordinates). But if you call parent->transferDataIntoLeaves( true ) the body will keep its local velocity, which means that it will start moving along positive X.
| keepLocalVelocity | - if true, any bodies (which are leaves) will keep their local velocity (velocity will be transformed). If not, they will keep their current velocity (in world coordinates), i.e., velocities will NOT be transformed. |
| clearTransform | - If true, then the transformation of this local frame will be set to identity at the end of this method. Otherwise this has to be done explicitly. |
Transform point from the world coordinate frame to this frame.
| pointWorld | - point to transform, given in the world coordinate frame |
Definition at line 626 of file Frame.h.
Referenced by agxModel::NodeAttachment::createFromWorld(), agxCable::SegmentAttachment::createFromWorld(), and transformPointToLocal().
Transform point from the world coordinate frame to this frame.
| px | - x-component to transform, given in the world coordinate frame |
| py | - y-component to transform, given in the world coordinate frame |
| pz | - z-component to transform, given in the world coordinate frame |
Definition at line 632 of file Frame.h.
References transformPointToLocal().
| Vec3 & agx::Frame::transformPointToLocal | ( | const agx::Vec3 & | pointWorld, |
| agx::Vec3 & | pointLocal | ||
| ) | const |
Transform point from the world coordinate frame to this frame.
| pointWorld | - point to transform, given in the world coordinate frame |
| pointLocal | - transformed point given in this frame |
Definition at line 637 of file Frame.h.
References getMatrix(), agx::AffineMatrix4x4T< T >::inverse(), and agx::AffineMatrix4x4T< T >::preMult().
Transform point from this frame to the world frame.
| pointLocal | - point to transform, given in this frame |
Definition at line 587 of file Frame.h.
Referenced by transformPointToWorld().
Transform point from this frame to the world frame.
| px | - x-component to transform, given in this frame |
| py | - y-component to transform, given in this frame |
| pz | - z-component to transform, given in this frame |
Definition at line 593 of file Frame.h.
References transformPointToWorld().
| Vec3 & agx::Frame::transformPointToWorld | ( | const agx::Vec3 & | localPoint, |
| agx::Vec3 & | worldPoint | ||
| ) | const |
Transform point from this frame to the world frame.
| localPoint | - point to transform, given in this frame |
| worldPoint | - the transformed point given in the world coordinate frame |
worldPoint point Definition at line 598 of file Frame.h.
References getMatrix(), and agx::AffineMatrix4x4T< T >::preMult().
Transform vector from the world coordinate frame to this frame.
| worldVector | - vector to transform, given in the world coordinate world frame |
Definition at line 606 of file Frame.h.
Referenced by transformVectorToLocal().
Transform vector from the world coordinate frame to this frame.
| vx | - x-component to transform, given in the world coordinate world frame |
| vy | - y-component to transform, given in the world coordinate world frame |
| vz | - z-component to transform, given in the world coordinate world frame |
Definition at line 612 of file Frame.h.
References transformVectorToLocal().
| Vec3 & agx::Frame::transformVectorToLocal | ( | const agx::Vec3 & | vectorWorld, |
| agx::Vec3 & | vectorLocal | ||
| ) | const |
Transform vector from the world coordinate frame to this frame.
| vectorWorld | - vector to transform, given in the world coordinate frame |
| vectorLocal | - transformed vector given in this frame |
Definition at line 617 of file Frame.h.
References getMatrix(), agx::AffineMatrix4x4T< T >::postMult(), and agx::AffineMatrix4x4T< T >::setTranslate().
Transform vector from this frame to the world frame.
| vectorLocal | - vector to transform, given in this frame |
Definition at line 568 of file Frame.h.
Referenced by transformVectorToWorld().
Transform vector from this frame to the world frame.
| vx | - x-component to transform, given in this frame |
| vy | - y-component to transform, given in this frame |
| vz | - z-component to transform, given in this frame |
Definition at line 574 of file Frame.h.
References transformVectorToWorld().
| Vec3 & agx::Frame::transformVectorToWorld | ( | const agx::Vec3 & | localVector, |
| agx::Vec3 & | worldVector | ||
| ) | const |
Transform vector from this frame to the world frame.
| localVector | - vector to transform, given in this frame |
| worldVector | - the transformed vector given in the world coordinate frame |
worldVector vector Definition at line 579 of file Frame.h.
References getMatrix(), and agx::Matrix4x4T< T >::transform3x3().
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
This method should be used with care, always balanced with the same number of calls to reference.
|
inherited |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.
| void agx::Frame::updateLocalMatrix | ( | ) |
| void agx::Frame::updateLocalMatrixSSE | ( | ) |
Internal method.
Performs the same operation as updateLocalMatrix but will use SSE implementation instead. It is important that the data is aligned correctly and it is the callers responsibility to know if this method can be used.
If in doubt, pick updateLocalMatrix instead.
|
staticinherited |
|
mutableprotectedinherited |
Definition at line 240 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.