NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgBulletSpringCableAnchor Class Reference

#include <tgBulletSpringCableAnchor.h>

Inheritance diagram for tgBulletSpringCableAnchor:
Collaboration diagram for tgBulletSpringCableAnchor:

Public Member Functions

 tgBulletSpringCableAnchor (btRigidBody *body, btVector3 pos, btVector3 cn=btVector3(0.0, 0.0, 0.0), bool perm=true, bool slide=false, btPersistentManifold *m=NULL)
 
virtual ~tgBulletSpringCableAnchor ()
 
virtual btVector3 getWorldPosition () const
 
virtual bool setWorldPosition (btVector3 &newPos)
 
virtual btVector3 getRelativePosition () const
 
virtual btVector3 getContactNormal () const
 
bool updateManifold (btPersistentManifold *m)
 
btPersistentManifold * getManifold () const
 
std::pair< btScalar, btVector3 > getManifoldDistance (btPersistentManifold *m) const
 
const btVector3 & getForce () const
 

Public Attributes

btRigidBody *const attachedBody
 
const bool permanent
 
const bool sliding
 

Protected Attributes

btVector3 force
 

Friends

class tgBulletContactSpringCable
 

Detailed Description

A class that allows tgBulletSpringCable and tgBulletContactSpringCable to attach to btRigidBodies Anchors track a specific point on a body as that body translates and rotates. They can either be 'non-sliding' which typically means a pin jointed anchor (and are typically permanent), or sliding, which means they track a specific contact point within a btPersistentManifold.

Definition at line 53 of file tgBulletSpringCableAnchor.h.

Constructor & Destructor Documentation

tgBulletSpringCableAnchor::tgBulletSpringCableAnchor ( btRigidBody *  body,
btVector3  pos,
btVector3  cn = btVector3(0.0, 0.0, 0.0),
bool  perm = true,
bool  slide = false,
btPersistentManifold *  m = NULL 
)

The only constructor. At a minimum requires a body and a position on that body to track. Sliding anchors require additional data

Parameters
[in]body- a pointer to the btRigidBody this is attached to
[in]pos- The position in world coordinates where this attaches
[in]cn- A btVector3 that specifies the direction of contact Only requried for sliding anchors
[in]perm- Whether or not this anchor can be deleted in the middle of a simulation
[in]slide- Whether this represents a pin joint or a sliding contact
[in]m- a btPersistenManifold that is used to track contacts

Definition at line 44 of file tgBulletSpringCableAnchor.cpp.

tgBulletSpringCableAnchor::~tgBulletSpringCableAnchor ( )
virtual

Destructor, nothing to delete

Definition at line 69 of file tgBulletSpringCableAnchor.cpp.

Member Function Documentation

btVector3 tgBulletSpringCableAnchor::getContactNormal ( ) const
virtual

Return an up to date contact normal based on the rigid body's btTransform

Returns
the contact normal, accounting for any rotation from when the body was first contacted.

Implements tgSpringCableAnchor.

Definition at line 203 of file tgBulletSpringCableAnchor.cpp.

const btVector3& tgSpringCableAnchor::getForce ( ) const
inlineinherited
Returns
a const reference to the force we just applied (or are about to apply)

Definition at line 107 of file tgSpringCableAnchor.h.

btPersistentManifold* tgBulletSpringCableAnchor::getManifold ( ) const
inline

Return a pointer to our btPersistentManifold (typically so something can compare getManifoldDistance with a new manifold)

Definition at line 126 of file tgBulletSpringCableAnchor.h.

std::pair< btScalar, btVector3 > tgBulletSpringCableAnchor::getManifoldDistance ( btPersistentManifold *  m) const

A pair of the distance between the current world position and this manifolds contact point, as well as the contact normal of this manifold

Returns
distance to the contact, contact normal

Definition at line 273 of file tgBulletSpringCableAnchor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

btVector3 tgBulletSpringCableAnchor::getRelativePosition ( ) const
virtual

Get the position of the point in body coordinaates

Returns
a btVector3 in body coordinates

Implements tgSpringCableAnchor.

Definition at line 76 of file tgBulletSpringCableAnchor.cpp.

Here is the caller graph for this function:

btVector3 tgBulletSpringCableAnchor::getWorldPosition ( ) const
virtual

Return the current position of the anchor in world coordinates Uses attachedRelativeOriginalPosition and the attachedBody's btTransform

Implements tgSpringCableAnchor.

Definition at line 83 of file tgBulletSpringCableAnchor.cpp.

bool tgBulletSpringCableAnchor::setWorldPosition ( btVector3 &  newPos)
virtual

Update attachedRelativeOriginalPosition based on the sliding of the string. This also checks if the new sliding position is still on the body.

Returns
bool returns if this point is actually on the body. The body should be deleted if this returns false
Todo:
  • this is very similar to getManifoldDistance. Is there a good way to combine them??

Implements tgSpringCableAnchor.

Definition at line 89 of file tgBulletSpringCableAnchor.cpp.

Here is the call graph for this function:

bool tgBulletSpringCableAnchor::updateManifold ( btPersistentManifold *  m)

Update our manifold pointer. This memory is often reassigned so the new manifold is accepted if our old manifold no longer contains our rigid body. It is also accepted if its contact point is closer than our manifold's

Returns
a bool that is true if the new manifold was accepted

Definition at line 218 of file tgBulletSpringCableAnchor.cpp.

Here is the call graph for this function:

Member Data Documentation

btRigidBody* const tgBulletSpringCableAnchor::attachedBody

The rigid body we affect Address should never be changed, body is not const

Todo:
Create applyForce functions so this doesn't have to be exposed

Definition at line 137 of file tgBulletSpringCableAnchor.h.

btVector3 tgSpringCableAnchor::force
protectedinherited

Store force so we can normalize it appropreately. Set and accessed directly by MuscleNP

Definition at line 132 of file tgSpringCableAnchor.h.

const bool tgSpringCableAnchor::permanent
inherited

A boolean value indicating whether this a temporary or permanent contact if permanent do not delete it until teardown!!

Definition at line 116 of file tgSpringCableAnchor.h.

const bool tgSpringCableAnchor::sliding
inherited

How the force is applied to the rigid body. True applies along the contact normal, false is applied towards the next anchor. Application depends on other classes

Todo:
Do we want an internal apply force function? May simplify things (prevent Muscles from needing to include rigid bodies??)

Definition at line 124 of file tgSpringCableAnchor.h.


The documentation for this class was generated from the following files: