edited:
Hi!!!
I repled again, but put it now here too for anyone interested ...
>how do you simulate spring?
>
>That's what I do:
>
> _______ -----'car'
> |
> |
> |
> |
> end of the spring (mass=1kg)
>
>When I calculate force acting along the spring, I get acceleration,velocity and
>displacement
>of the end of spring. Is it similiar to yours?
Ok, I put here tyre structure I use:
struct Tyre
{
vec3 m_tyre_pos; // Tyre pos in car's local coordinates
float m_radius; // Tyre radius
vec3 m_pos, m_front, m_right, m_up; // tyre pos & orientation axes in world coordinates (computed every frame)
vec3 m_touch_pos; // tyre-ground touch pos
struct Susp { // suspension data
float m_len; // Spring length
float m_cur_len; // Current spring length
float m_force[2]; // force[0] when compressed (up), force[1] when released (down)
float m_damp_force;
float m_touch_force;
} m_susp;
};
I try to explain how I do it:
You can see I have variable Tyre.m_susp.m_len that is the length of spring.
First thing I need to get is distance from tyre base to ground.
Let that distance be float T.
Then I limit T value to range[0..Tyre.m_susp.m_len]:
if(T<0) T=0;
if(T>t.m_susp.m_len) T=t.m_susp.m_len;
Now T is the current length of spring.
Next thing to do is to calculate how big force spring does give when compressed T length.
float m_force[2]; // force[0] when compressed (up), force[1] when released (down)
float f = T / t.m_susp.m_len; // f presents T scaled to range [0..1]
float force = (1-f)*t.m_susp.m_force[0] + (f)*t.m_susp.m_force[1];
(Note that m_force[0] is currently 0. It is just there because I thought later to try using
non linear spring adding more force values m_force[3] for example.)
But now float force is the force that supports the car not falling down.
Did that answer your question how do I simulate spring?
Not wery elegant way I asked physicians, but I'm not one

Next I calculate the spring velocity (knowing how much it has changed since las frame).
And then apply damping:
force -= velocity * t.m_susp.m_damp_force;
if( force<0 ) force=0; // Force newer pulls car downwards
// Now here I apply the force to rigid body system (based on Heckers tutorial)
addForce(Configuration,t.m_pos,t.m_up*force);
// save touch force & pos
t.m_susp.m_touch_force = force;
t.m_touch_pos = t.m_pos - t.m_up * (t.m_susp.m_cur_len + t.m_radius);
>Which mass of the end do you use?
I don't really understand this question, sorry? Propably my poor english

My springs are currently weightless. I try to keep thing simple at first.
Could please you explain very shortly that mass thing? Maybe I'll learn something

>
>Did you implement collision response?
I don't have collision response in spring system. You see the red dots in my demo? They are collision check points (althought not positioned yet there). I resolve collisions later with all the collision points and apply collision response when necessary

>
>How do you keep springs from running away from your car?
>
I think this is in the code above where I just limit spring length. These lines:
if(T<0) T=0;
if(T>t.m_susp.m_len) T=t.m_susp.m_len;
I got feeling my suspension system is very simple to yours

Maybe I'm working more on it when the game starts to shape out more.
Sorry if I couldn't help, as I said, I'm not (yet) physician :D
Do you have got anything working yet?
- Stefu
[edited by - stefu on August 31, 2002 12:59:20 PM][edited by - stefu on August 31, 2002 1:00:56 PM]