Game Development Reference
An important caution here concerns the location of the application of a force.
It should be expressed in world coordinates. If you have a spring attached at a fixed
point on an object, you need to recalculate the position of the attachment point at
each frame. You can do this simply by transforming the object coordinates' position
by the transform matrix, to get a position in world coordinates. Because this is such
a useful thing to be able to do, I provide an additional force-accumulation method to
Excerpt from include/cyclone/body.h
// ... Other RigidBody code as before ...
* Adds the given force to the given point on the rigid body.
* The direction of the force is given in world coordinates,
* but the application point is given in body space. This is
* useful for spring forces, or other forces fixed to the
* @param force The force to apply.
* @param point The location at which to apply the force, in
* body coordinates.
void addForceAtBodyPoint(const Vector3 &force,
const Vector3 &point);
Excerpt from src/body.cpp
void RigidBody::addForceAtBodyPoint(const Vector3 &force,
const Vector3 &point)
// Convert to coordinates relative to the center of mass.
Vector3 pt = getPointInWorldSpace(point);