Hi all.

I’m knocking together a spring simulation app in my spare time using OpenGL for the graphics. The graphics part is fine, thanks mainly th HeNes tutorials. However, I’m having a little trouble getting the springs to work in a believeable way.

The basic problem is that the blob of gelly that the springs make is made up of particles. Each particle has its own velocity, mass ect. Two particles are connected by a spring and this does all the calculations for adjusting the velocities of the two particles that it connects. Ok so far.

But spring damping is getting me down. In my app, I have a “Bar” of springs bounces of a ball and lands on the “ground”. The problem is that the spring damping acts on the velocity of the particles and this is also the particles velocity through the air when it is falling, bouncing, rebounding etc.

It looks as if the bar if falling though tar. Needless to say, this is not what I really want.

Does anyone knoe a way of damping the movement of the two particles without affecting the velocity that should be there. Here is the code for the spring

void CSpring::Update(float fTime)
vec3_t vPar1 = m_pStart->GetPos();
vec3_t vPar2 = m_pEnd->GetPos();
vec3_t vBond = vPar2 - vPar1;

// The magnitude of this extension
float fMagnitude = vBond.Length();

// get the eztension beyond the normal length
float fExtension = fMagnitude - m_fNaturalLength;

float ForceMag = (fExtension/fMagnitude) * STIFFNESS;
vec3_t ForceVect = (vBond * (ForceMag/fMagnitude));


m_pStart->SetVel(m_pStart->GetVel() * DAMPING);
m_pEnd->SetVel(m_pEnd->GetVel() * DAMPING);

As you can see. The DAMPING (Defined as 0.99f is applied to the velocity of the particles directly. Dont know what to do!!!

Thanks for any help you could give me on this.


Spring systems are quite a bit more complicated than that I’m sorry to say. Each particle attached to the spring has inertia that needs to be taken into account. In general this means that numerical integration is required to accurately model a system of particles and springs.
Check out this article for a detailed description of the work involved: Collision Response: Bouncy, Trouncy, Fun

[This message has been edited by DFrey (edited 10-25-2000).]