NTRT Simulator
Version: Master
|
#include <tgBoxMoreAnchorsInfo.h>
Public Member Functions | |
tgBoxMoreAnchorsInfo (const tgBox::Config &config) | |
tgBoxMoreAnchorsInfo (const tgBox::Config &config, tgTags tags) | |
tgBoxMoreAnchorsInfo (const tgBox::Config &config, const tgPair &pair) | |
tgBoxMoreAnchorsInfo (const tgBox::Config &config, tgTags tags, const tgPair &pair) | |
virtual | ~tgBoxMoreAnchorsInfo () |
tgRigidInfo * | createRigidInfo (const tgPair &pair) |
virtual tgModel * | createModel (tgWorld &world) |
virtual std::set< tgRigidInfo * > | getLeafRigids () |
virtual bool | containsNode (const btVector3 &nodeVector) const |
virtual tgRigidInfo * | createRigidInfo (const tgNode &node) |
virtual tgRigidInfo * | createRigidInfo (const tgNode &node, const tgTagSearch &tagSearch) |
virtual tgRigidInfo * | createRigidInfo (const tgPair &pair, const tgTagSearch &tagSearch) |
virtual void | initRigidBody (tgWorld &world) |
const tgBox::Config & | getConfig () const |
const btVector3 & | getFrom () const |
const btVector3 & | getTo () const |
virtual btCollisionShape * | getCollisionShape (tgWorld &world) const |
virtual btTransform | getTransform () const |
virtual double | getMass () const |
virtual btVector3 | getCenterOfMass () const |
virtual btVector3 | getConnectionPoint (const btVector3 &referencePoint, const btVector3 &destinationPoint) const |
virtual btVector3 | getConnectionPoint (const btVector3 &referencePoint, const btVector3 &destinationPoint, const double rotation) const |
virtual tgCompoundRigidInfo * | getCompound () |
virtual const tgCompoundRigidInfo * | getCompound () const |
virtual std::set< btVector3 > | getContainedNodes () const |
double | getLength () const |
virtual std::vector < tgRigidInfo * > | createRigidInfos (const tgNodes &nodes, const tgTagSearch &tagSearch) |
virtual std::vector < tgRigidInfo * > | createRigidInfos (const tgPairs &pairs, const tgTagSearch &tagSearch) |
void | setCollisionShape (btCollisionShape *p_btCollisionShape) |
virtual tgRigidInfo * | getRigidInfoGroup () |
virtual const tgRigidInfo * | getRigidInfoGroup () const |
virtual void | setRigidInfoGroup (tgRigidInfo *rigidInfoGroup) |
virtual btRigidBody * | getRigidBody () |
virtual const btRigidBody * | getRigidBody () const |
virtual void | setRigidBody (btRigidBody *rigidBody) |
virtual btCollisionObject * | getCollisionObject () |
virtual const btCollisionObject * | getCollisionObject () const |
virtual void | setCollisionObject (btCollisionObject *collisionObject) |
bool | isCompound () const |
virtual bool | sharesNodesWith (const tgRigidInfo &other) const |
void | addTags (const std::string &space_separated_tags) |
void | addTags (const tgTags &tags) |
bool | hasTag (const std::string tag) const |
bool | hasAllTags (std::string tags) |
bool | hasAnyTags (const std::string tags) |
bool | hasNoTags () |
tgTags & | getTags () |
const tgTags & | getTags () const |
void | setTags (tgTags tags) |
std::string | getTagStr (std::string delim=" ") const |
Protected Member Functions | |
bool | isNodeOnBoxSurface (const btVector3 &nodeVector) const |
btVector3 | getHalfExtents () const |
std::string | getBoxOrientation () const |
btVector3 | getHalfExtentsOrientedX () const |
btVector3 | getHalfExtentsOrientedY () const |
btVector3 | getHalfExtentsOrientedZ () const |
Protected Attributes | |
btCollisionShape * | m_collisionShape |
tgRigidInfo * | m_rigidInfoGroup |
btCollisionObject * | m_collisionObject |
Implementation of a box shape as defined by a 'from' point and a 'to' point. It also has length, width and density. This 'info' class will also detect and add nodes that are along the outside edge of the box (as of 2016-08-31, actually adds nodes on or INSIDE the box, which is not the behavior we want, but is good enough for the ForcePlateModel
NOTE THAT THIS CLASS DOES NOT WORK WELL AT THE MOMENT. A discussion on the limitations of NTRT's creation of boxes is present in tgBoxMoreAnchors.cpp, but briefly: since NTRTsim does not specify an orientation for a box, the width and height directions currently are chosen ARBITRARILY by the underlying Bullet Physics methods. As a result, this class will sometimes break for no reason. That would occur if Bullet chooses which parameter is width and which is height in a different way than is assumed here. To fix this, we'd want to change how boxes are specified, but that means changing tgBox, which may affect other code...
Definition at line 63 of file tgBoxMoreAnchorsInfo.h.
tgBoxMoreAnchorsInfo::tgBoxMoreAnchorsInfo | ( | const tgBox::Config & | config | ) |
Construct a tgBoxMoreAnchorsInfo with just a config. The pair must be filled in later, or factory methods can be used to create instances with pairs. note that this class is using the config from tgBox since that's easier. A bit messy, but works for now.
Definition at line 43 of file tgBoxMoreAnchorsInfo.cpp.
tgBoxMoreAnchorsInfo::tgBoxMoreAnchorsInfo | ( | const tgBox::Config & | config, |
tgTags | tags | ||
) |
Construct a tgBoxMoreAnchorsInfo with just a config and tags. The pair must be filled in later, or factory methods can be used to create instances with pairs.
Definition at line 47 of file tgBoxMoreAnchorsInfo.cpp.
tgBoxMoreAnchorsInfo::tgBoxMoreAnchorsInfo | ( | const tgBox::Config & | config, |
const tgPair & | pair | ||
) |
Construct a tgBoxMoreAnchorsInfo from its endpoints, radius and density.
[in] | from | one endpoint |
[in] | to | the other endpoint |
[in] | config | contains the radius and density |
Definition at line 52 of file tgBoxMoreAnchorsInfo.cpp.
tgBoxMoreAnchorsInfo::tgBoxMoreAnchorsInfo | ( | const tgBox::Config & | config, |
tgTags | tags, | ||
const tgPair & | pair | ||
) |
Construct a tgBoxInfo from its endpoints, radius and density.
[in] | from | one endpoint |
[in] | to | the other endpoint |
[in] | config | contains the radius and density |
Definition at line 57 of file tgBoxMoreAnchorsInfo.cpp.
|
inlinevirtual |
World will destroy the rigid body
Definition at line 105 of file tgBoxMoreAnchorsInfo.h.
|
virtual |
This function determines if a node is on the surface (ON THE INSIDE) of this box. This is the big difference from tgBoxInfo! In that class, this function just checked if the nodeVector was either of the two endpoints.
This function has been enhanced to include checking of either endpoints or inclusion inside the box.
Reimplemented from tgBoxInfo.
Definition at line 331 of file tgBoxMoreAnchorsInfo.cpp.
This method needs to be re-defined to create a tgBoxMoreAnchors instead of just a tgBox.
Reimplemented from tgBoxInfo.
Definition at line 73 of file tgBoxMoreAnchorsInfo.cpp.
|
virtual |
Create a tgRigidInfo* from a tgPair. Needs to be re-declared and re-defined in this class so that a tgBoxMoreAnchorsInfo will be returned, not a tgBoxInfo.
Re-define this function to return a tgBoxMoreAnchorsInfo. Compare to parent. Note that getConfig() must be called instead of directly trying to access m_config, since that's a private variable of the parent class.
Reimplemented from tgBoxInfo.
Definition at line 67 of file tgBoxMoreAnchorsInfo.cpp.
|
protected |
This function is a helper inside getHalfExtents. It returns the orientation of the box.
a | string with the axis along which this box exists. This should be enough to determine how to orient the half extents. |
Returns a string: "x", "y", or "z". TO-DO: FIX THIS! This method shouldn't be needed. But, at the moment, it's used as a fix to the arbitrary orientation assignment of tgBox. A better solution is to have tgBox specify an orientation (ex., maybe a unit vector in the "width" direction so that a set of axes can be applied to the box.) This will require changing tgBox in major ways, though.
Definition at line 109 of file tgBoxMoreAnchorsInfo.cpp.
|
inlinevirtualinherited |
Return the Box's center of mass. The center of mass is a point halfway between the endpoints.
Implements tgRigidInfo.
Definition at line 141 of file tgBoxInfo.h.
|
inlinevirtualinherited |
Return a pointer to the collisionObject without upcasting
Reimplemented in tgCompoundRigidInfo.
Definition at line 190 of file tgRigidInfo.h.
|
inlinevirtualinherited |
Return a pointer to the collisionObject without upcasting
Reimplemented in tgCompoundRigidInfo.
Definition at line 199 of file tgRigidInfo.h.
|
virtualinherited |
Return a pointer to the corresponding btCollisionShape, lazily creating it if it does not exist.
Implements tgRigidInfo.
Definition at line 100 of file tgBoxInfo.cpp.
|
inlinevirtualinherited |
Since a Box is not a compound shape, there is no compound shape object to return.
NULL |
Implements tgRigidInfo.
Definition at line 176 of file tgBoxInfo.h.
|
inlinevirtualinherited |
Since a Box is not a compound shape, there is no compound shape object to return.
NULL |
Implements tgRigidInfo.
Definition at line 183 of file tgBoxInfo.h.
|
inlineinherited |
Return a const reference to the container of the radius and density.
Definition at line 107 of file tgBoxInfo.h.
|
virtualinherited |
Return the surface point closest to the reference point in the direction of the destination point.
[in] | referencePoint | a btVector |
[in] | destinationPoint | a btVector |
Implements tgRigidInfo.
Definition at line 135 of file tgBoxInfo.cpp.
|
virtualinherited |
Return the surface point closest to the reference point in the direction of the destination point.
[in] | referencePoint | a btVector |
[in] | destinationPoint | a btVector |
Reimplemented from tgRigidInfo.
Definition at line 142 of file tgBoxInfo.cpp.
|
virtualinherited |
Return a set contiaining the two endpoints.
Implements tgRigidInfo.
Definition at line 195 of file tgBoxInfo.cpp.
|
inlineinherited |
Return a const reference to the first endpoint.
Definition at line 110 of file tgBoxInfo.h.
|
protected |
This function is a helper to isNodeOnBoxSurface. It returns the correct geometry of the box around which to check for nodes. This is needed because it's unclear what direction is width and which is height for a box. We fix this by testing and hard-coding the width/height ordering for different orientations of the box. This is done because the Bullet Physics object is not created yet: containsNode is called before the methods that create the Bullet object. : can this program determine what orientation and rotations will be used by Bullet, and do that instead of hard-coding?
a | btVector3 of half extents, just like Bullet uses for btBoxShape. |
The dimensions of the box (its half extents, in Bullet terminology) depend on its orientation. NOTE that width and height are used in btBoxShape in the same way that radius is used for rods: they are from the center to the outside of the box, NOT from one side of the box to another.
Definition at line 200 of file tgBoxMoreAnchorsInfo.cpp.
|
protected |
The following three functions are helpers to getHalfExtents. They each assign the half extents according to the specific orientation of the box.
The following three functions return the half extents of the box, depending on its orientation. These are hard-coded by trial and error, and CHANGE ARBITRARILY. Also, note that since NTRT assumes that length is the full length of the box (unlike width and height, which are half-extents), length has to be halved here. TO-DO: we shouldn't need these functions if tgBox is changed to incorporate orientation explicitly.
Definition at line 169 of file tgBoxMoreAnchorsInfo.cpp.
|
virtual |
The following three functions are part of tgBoxInfo. This just makes it so that tgBoxMoreAnchorsInfo does not own the pair. But that's fine. In the implementation of tgBoxMoreAnchorsInfo, we'll just call these functions instead of addressing m_pair directly. So, these are listed here for your reference, do not re-implement them. const tgBox::Config& getConfig() const { return m_config; } const btVector3& getFrom() const { return m_pair.getFrom(); } const btVector3& getTo() const { return m_pair.getTo(); } This class uses the parent's getCollisionShape method, since the underlying Bullet Physics object for a box is still the same. For reference, here's the line that does that creation: new btBoxShape(btVector3(width, length / 2.0, height)); Return a set containing only a pointer to this Box.
a | set containing only a pointer to this Box |
Reimplemented from tgBoxInfo.
Definition at line 93 of file tgBoxMoreAnchorsInfo.cpp.
|
inlineinherited |
Return the distance between the two endpoints.
Definition at line 213 of file tgBoxInfo.h.
|
virtualinherited |
Return the Box's mass. The mass is the volume times the density.
Implements tgRigidInfo.
Definition at line 119 of file tgBoxInfo.cpp.
|
virtualinherited |
Return a pointer to the corresponding btRigidBody.
Reimplemented in tgCompoundRigidInfo.
Definition at line 124 of file tgRigidInfo.cpp.
|
virtualinherited |
Return a const pointer to the corresponding btRigidBody.
Reimplemented in tgCompoundRigidInfo.
Definition at line 130 of file tgRigidInfo.cpp.
|
inlinevirtualinherited |
Get the tgRigidInfo that represents the compound rigid that this rigid belongs to. If it doesn't share nodes with any other rigids (determined during auto-compounding), it will point to itself.
Definition at line 149 of file tgRigidInfo.h.
|
inlineinherited |
Return a const reference to the second endpoint.
Definition at line 113 of file tgBoxInfo.h.
|
inlinevirtualinherited |
Return a btTransform that maps the from endpoint to the to endpoint
Implements tgRigidInfo.
Definition at line 125 of file tgBoxInfo.h.
|
virtualinherited |
Call tgRigidInfo init rigid, then apply config to the rigid body.
Reimplemented from tgRigidInfo.
Reimplemented in tgGhostInfo.
Definition at line 73 of file tgBoxInfo.cpp.
|
inlineinherited |
Is this tgRigidInfo a compound?
true | if this tgRigidInfo is a compound |
false | if this tgRigidInfo is not a compound |
Definition at line 273 of file tgRigidInfo.h.
|
protected |
Return a set containing all the nodes in this box. Note that tgBoxInfo has this same function, and we're redefining it here so that the returned set will include the additional nodes after they're added to additionalNodes by the containsNode method. : actually implement this. right now, just use the parent's function. This function checks if a node is on the surface of the tgBox that will be created with this tgBoxInfo. NOTE that it does NOT work for boxes that start off rotated: unless a box is orthogonal to the axes of the world, this function will always return false. It is protected so that only children of this class could call or re-define.
[in] | nodeVector | a btVector3 that is to be checked against this box. |
result,true | if the node is on or inside the box, false else. |
This function is used in containsNode to check if a node is on the surface of the box that will be created by this tgBoxMoreAnchorsInfo. NOTE that is should only work right now for boxes that are orthogonal to the axes of the world: it "should" return false for all rotated boxes. This function is a close copy of Bullet Physics' btBoxShape::isInside.
Definition at line 243 of file tgBoxMoreAnchorsInfo.cpp.
|
inlinevirtualinherited |
Set the collision object to a new collision object
Reimplemented in tgCompoundRigidInfo.
Definition at line 208 of file tgRigidInfo.h.
|
inlineinherited |
Set the corresponding btCollisionShape.
[in,out] | a | pointer to a btCollisionShape |
Definition at line 137 of file tgRigidInfo.h.
|
virtualinherited |
Set the corresponding btRigidBody.
[in,out] | a | pointer to a btRigidBody |
Reimplemented in tgCompoundRigidInfo.
Definition at line 135 of file tgRigidInfo.cpp.
|
inlinevirtualinherited |
Set the tgRigidInfo that represents the compound rigid that this may belong to. This will be set during auto-compounding.
Definition at line 163 of file tgRigidInfo.h.
|
virtualinherited |
Does this rigid have any nodes in common with the given tgRigidInfo object?
in] | other a reference to a tgRigidInfo object |
true | if any node in this sphere is also in other |
false | if no node in this sphere is also in other |
Reimplemented in tgCompoundRigidInfo.
Definition at line 141 of file tgRigidInfo.cpp.
|
mutableprotectedinherited |
A pointer to the corresponding btCollisionObject. Typically a btRigidBody, but can also be a btGhostObject
Definition at line 347 of file tgRigidInfo.h.
|
mutableprotectedinherited |
A pointer to the corresponding btCollisionShape.
Definition at line 332 of file tgRigidInfo.h.
|
mutableprotectedinherited |
A pointer to a group of rigids to which this rigid belongs. This is set during the rigid grouping step by a StructureInfo. If this is not set, getRigidGroup() will return a pointer to this (effectively, "I'm in my own group")
Definition at line 341 of file tgRigidInfo.h.