Sign in to follow this  

spring and damping effect

This topic is 2334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I would like implement this spring and damping effect to my project. I looked into spring equations and Hooke's law (I'm in the exploratory phase) but the info I found doesn't really address the rotation of a vector. The quicktime shows a positional offset but also imagine a rotation influencing the sway and drag of the vector.

Can the vets out their point me in the right direction? What subjects should I google? Is there a good book you recommend? Do you have the working equation that achieves this? I'll take anything. Thanks.

Nikos

Share this post


Link to post
Share on other sites
if you have a rigid body system in place, adding a spring/damper is just adding forces to a rigid body... the rotations will be handled by that automatically.

if you dont have a rigid body system in place... get one [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img] .
You can code it yourself (good fun and learning experience) or just grab ODE, PhysX, Bullet, Havok and use theirs.

Share this post


Link to post
Share on other sites
[quote name='kunos' timestamp='1311613805' post='4840059']
if you have a rigid body system in place, adding a spring/damper is just adding forces to a rigid body... the rotations will be handled by that automatically.

if you dont have a rigid body system in place... get one [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img] .
You can code it yourself (good fun and learning experience) or just grab ODE, PhysX, Bullet, Havok and use theirs.
[/quote]

Using those engines is not an option :( All I have to work with are 2 vectors. Using these nominal vectors, I would like to calculate a third that represents those spring and drag forces. I thought about doing a simple weighted average of the two using their magnitudes as a weight but it seemed too much like a hack. So I'm appealing to the math gurus on this one. I'll take anything :blink:

Share this post


Link to post
Share on other sites
You could apply three one dimensional damped springs, one for each axis. This would give you the "swaying grass" effect you seem to be looking for. Also, this method does not requre a call to sqrt() or other cpu-expensive functions. For each axis, the force F would be F = -x*k - v*d, where x is displacement from rest position along given axis, k is spring stiffnes coefficient, v is velocity relative to rest position along given axis, and d is spring damping coefficient. Along the vertical axis, force would be F = -(x-xr)*k - v*d, where xr is rest distance above ground.

Alternatively, you could apply an angular or rotational spring, but this is considerably more complicated.

Cheers,
Mike

Share this post


Link to post
Share on other sites
[quote name='h4tt3n' timestamp='1311619260' post='4840115']
You could apply three one dimensional damped springs, one for each axis. This would give you the "swaying grass" effect you seem to be looking for. Also, this method does not requre a call to sqrt() or other cpu-expensive functions. For each axis, the force F would be F = -x*k - v*d, where x is displacement from rest position along given axis, k is spring stiffnes coefficient, v is velocity relative to rest position along given axis, and d is spring damping coefficient. Along the vertical axis, force would be F = -(x-xr)*k - v*d, where xr is rest distance above ground.

Alternatively, you could apply an angular or rotational spring, but this is considerably more complicated.

Cheers,
Mike
[/quote]

That is exactly what I was looking for. Thanks Mike!

Share this post


Link to post
Share on other sites
[quote name='h4tt3n' timestamp='1311619260' post='4840115']
You could apply three one dimensional damped springs, one for each axis. This would give you the "swaying grass" effect you seem to be looking for. Also, this method does not requre a call to sqrt() or other cpu-expensive functions. For each axis, the force F would be F = -x*k - v*d, where x is displacement from rest position along given axis, k is spring stiffnes coefficient, v is velocity relative to rest position along given axis, and d is spring damping coefficient. Along the vertical axis, force would be F = -(x-xr)*k - v*d, where xr is rest distance above ground.

Alternatively, you could apply an angular or rotational spring, but this is considerably more complicated.

Cheers,
Mike
[/quote]


BEAUTIFUL. thanks h4tt3n. works great!

Share this post


Link to post
Share on other sites

This topic is 2334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this