Jump to content
  • Advertisement
Sign in to follow this  
heron3d

spring and damping effect

This topic is 2552 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
Advertisement
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 tongue.gif .
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

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 tongue.gif .
You can code it yourself (good fun and learning experience) or just grab ODE, PhysX, Bullet, Havok and use theirs.


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
that doesn't make any sense.

you need to formulate your problem properly or no guru is ever going to be able to help you.

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

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


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

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



BEAUTIFUL. thanks h4tt3n. works great!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!