NTRT Simulator
v1.1
|
#include <tgBulletContactSpringCable.h>
Public Member Functions | |
tgBulletContactSpringCable (btPairCachingGhostObject *ghostObject, tgWorld &world, const std::vector< tgBulletSpringCableAnchor * > &anchors, double coefK, double dampingCoefficient, double pretension=0.0, double thickness=0.001, double resolution=0.1) | |
virtual | ~tgBulletContactSpringCable () |
virtual void | step (double dt) |
virtual const btScalar | getActualLength () const |
virtual const double | getTension () const |
virtual const std::vector < const tgSpringCableAnchor * > | getAnchors () const |
virtual const double | getRestLength () const |
virtual void | setRestLength (const double newRestLength) |
virtual const double | getCoefK () const |
virtual const double | getCoefD () const |
virtual const double | getVelocity () const |
virtual const double | getDamping () const |
Protected Attributes | |
btPairCachingGhostObject * | m_ghostObject |
const double | m_thickness |
const double | m_resolution |
std::vector < tgBulletSpringCableAnchor * > | m_anchors |
tgBulletSpringCableAnchor *const | anchor1 |
tgBulletSpringCableAnchor *const | anchor2 |
double | m_damping |
double | m_velocity |
const double | m_coefK |
const double | m_dampingCoefficient |
double | m_restLength |
double | m_prevLength |
An extension of tgBulletSpringCable that places a ghostObject into the bullet world and then uses that object to generate collision dynamics. The ghost object is updated every time step to account for the new shape of the string. Anchors track their associated btPersistentManifold to determine whether they are still in contact with the rigid object. The string is massless, but collision handling should conserve momentum (see unit tests)
This could eventually be merged with Corde for a massive, low node string. Merging with Corde could also address some of the current issues with rotational energy
Definition at line 60 of file tgBulletContactSpringCable.h.
tgBulletContactSpringCable::tgBulletContactSpringCable | ( | btPairCachingGhostObject * | ghostObject, |
tgWorld & | world, | ||
const std::vector< tgBulletSpringCableAnchor * > & | anchors, | ||
double | coefK, | ||
double | dampingCoefficient, | ||
double | pretension = 0.0 , |
||
double | thickness = 0.001 , |
||
double | resolution = 0.1 |
||
) |
The only constructor. Requires a number of parameters typically provided by the builder tools, in this case tgMultiPointStringInfo
[in] | ghostObject | - the btPairCashingGhostObject that this interacts with |
[in] | world | - the tgWorld - we need to keep access to the bullet dynamics world's broadphase so that we can determine collisions and contact points |
[in] | anchors | - a reference to a list of anchors. Will be passed to tgBulletSpringCable and form the initial (likely permanent) anchor list. Size must be 2 or greater (enforced in tgBulletSpringCable) |
[in] | coefK | - The stiffness of this cable. Units are mass / sec^2, sets a member variable of tgBulletSpringCable |
[in] | dampingCofefficient | - The damping coefficient of the force application equation. Units are mass / sec, sets a member variable of tgBulletSpringCable |
[in] | The | pretension on the string, units are force. Must be small enough (based on stiffness) such that rest length > 0; |
[in] | thickness,the | radius of the cylinder used for the btCollisionObject |
[in] | resolution,the | spatial resultion used to prune new contacts. also affects runtime (lower corresponds to longer runtime) |
Definition at line 57 of file tgBulletContactSpringCable.cpp.
|
virtual |
The destructor. Removes the ghost object from the world, deletes its collision shape, and then deletes the object. tgBulletSpringCable ensures all anchors are deleted
Definition at line 74 of file tgBulletContactSpringCable.cpp.
|
virtual |
Reimplemented from tgBulletSpringCable.
Definition at line 84 of file tgBulletContactSpringCable.cpp.
|
virtualinherited |
Returns a const vector of const anchors. Currently casts from tgBulletSpringCableAnchors, which makes it impossible to return a reference
Implements tgSpringCable.
Definition at line 157 of file tgBulletSpringCable.cpp.
|
inlinevirtualinherited |
Get the coefficent of damping
Definition at line 103 of file tgSpringCable.h.
|
inlinevirtualinherited |
Get the coefficent of stiffness
Definition at line 95 of file tgSpringCable.h.
|
inlinevirtualinherited |
Get the last value of the damping force
Definition at line 119 of file tgSpringCable.h.
|
virtualinherited |
Returns m_restLength
Definition at line 66 of file tgSpringCable.cpp.
|
virtualinherited |
Returns the tension currently in the string by multiplying the difference between the actual length and the rest length by the stiffness coefficient
Implements tgSpringCable.
Definition at line 150 of file tgBulletSpringCable.cpp.
|
inlinevirtualinherited |
Get the last change in length / time
Definition at line 111 of file tgSpringCable.h.
|
virtualinherited |
Sets m_restLength to newRestLength.
[in] | newRestLength,must | be non-negative |
Definition at line 71 of file tgSpringCable.cpp.
|
virtual |
The "update" function for tgBulletContactSpringCable. In addition to calculating and applying the force, this calls: updateManifolds() pruneAnchors() updateAnchorList() pruneAnchors() calculateAndApplyForce(dt) finally updateCollisionObject()
Reimplemented from tgBulletSpringCable.
Definition at line 97 of file tgBulletContactSpringCable.cpp.
|
protectedinherited |
The first attachement point for this spring cable. Storing it seperately makes a number of functions easier
Definition at line 111 of file tgBulletSpringCable.h.
|
protectedinherited |
The other permanent attachment for this spring cable.
Definition at line 116 of file tgBulletSpringCable.h.
|
protectedinherited |
The list of contact points. tgBulletSpringCable typically has two whereas tgBulletContactSpringCable will have more. Needs to be stored here for consistent rendering. Vector has the convienence of tgCast functions, and we used to need a random iterator to sort
Definition at line 105 of file tgBulletSpringCable.h.
|
protectedinherited |
The stiffness coefficient Units of mass / sec ^2 Must be positive
Definition at line 149 of file tgSpringCable.h.
|
protectedinherited |
The previous value of the damping force. Stored so we can get it without passing a dt
Definition at line 136 of file tgSpringCable.h.
|
protectedinherited |
The damping coefficient. Units of mass / sec. Must be non-negative
Definition at line 156 of file tgSpringCable.h.
|
protected |
A btPairCachingGhostObject that exists in the dynamics world and provides us information about what it collides with. We own this.
Definition at line 247 of file tgBulletContactSpringCable.h.
|
protectedinherited |
The previous actual length of the string. Used when calculating force and velocity
Definition at line 168 of file tgSpringCable.h.
|
protected |
The spatial resolution used in collision detection Units of length
Definition at line 259 of file tgBulletContactSpringCable.h.
|
protectedinherited |
The rest length of the string. Must be non negative
Definition at line 162 of file tgSpringCable.h.
|
protected |
The radius of the ghost object Units of length
Definition at line 253 of file tgBulletContactSpringCable.h.
|
protectedinherited |
The velocity of the string at the last update step. Stored so we can get it without passing a dt
Definition at line 142 of file tgSpringCable.h.