Game Development Reference
In-Depth Information
if (!body->hasFiniteMass()) return;
// Apply the mass-scaled force to the body
body->addForce(gravity * body->getMass());
The spring force generator now needs to know where the spring is attached on
each object, and it should generate an appropriate force with its application point.
Excerpt from include/cyclone/fgen.h
* A force generator that applies a Spring force.
class Spring : public ForceGenerator
/** The point of connection of the spring, in local coordinates. */
Vector3 connectionPoint;
* The point of connection of the spring to the other object,
* in that object's local coordinates.
Vector3 otherConnectionPoint;
/** The particle at the other end of the spring. */
RigidBody *other;
/** Holds the spring constant. */
real springConstant;
/** Holds the rest length of the spring. */
real restLength;
/** Creates a new spring with the given parameters. */
Spring(const Vector3 &localConnectionPt,
RigidBody *other,
const Vector3 &otherConnectionPt,
real springConstant,
real restLength);
/** Applies the spring force to the given particle. */
Search Nedrilad ::

Custom Search