Game Development Reference
A cable is a constraint that forces two objects to be no more than its length apart. If
we have two objects connected by a light cable, they will feel no effects as long as they
are close together. When the cable is pulled taut, the objects cannot separate further.
Depending on the characteristics of the cable, the objects may appear to bounce off
this limit, in the same way that objects colliding might bounce apart. The cable has a
characteristic coefficient of restitution that controls this bounce effect.
We can model cables by generating contacts whenever the ends of the cable sep-
arate too far. The contact is very much like those used for collisions, except that its
contact normal is reversed: it pulls the objects together rather than bouncing them
apart. The interpenetration depth of the contact corresponds to how far the cable has
been stretched beyond its limit.
We can implement a contact generator for a cable in this way:
Excerpt from include/cyclone/plinks.h
* Links connect two particles together, generating a contact if
* they violate the constraints of their link. It is used as a
* base class for cables and rods, and could be used as a base
* class for springs with a limit to their extension.
* Holds the pair of particles that are connected by this link.
* Returns the current length of the cable.
real currentLength() const;
* Fills the given contact structure with the contact needed
* to keep the link from violating its constraint. The contact
* pointer should point to the first available contact in a
* contact array, where limit is the maximum number of
* contacts in the array that can be written to. The method
* returns the number of contacts that have been written. This
* format is common to contact-generating functions, but this