Page 1 of 1
leaves falling from the tree and physically
Posted: Mon Oct 07, 2013 3:50 pm
by soullessbr
Hello everyone, okay?
I have no idea how I can get this effect leaves falling from the tree and physically rough terrain like in the video below. Could anyone give me some tips?
http://www.youtube.com/watch?v=bNmBGXaURx4
Thank you.
Re: leaves falling from the tree and physically
Posted: Mon Oct 07, 2013 4:17 pm
by micha
The leaves are subject to gravity and strong air resistance.
The first thing is to implement gravity. That means that each leaf needs a velocity vector and gravity acts on it as an acceleration. Have you done this before? Otherwise, please ask.
The second thing is to implement air resistance. The equation that describes this is the
drag equation. The factors rho, C_d and A are irrelevant here, because you only want it to look good (not necessarily to be physically exact). Just pick a fixed number for all these factors. In short: First calculate the relative velocity, that is the difference between the background velocity (wind) and the velocity of the leaf. Square this velocity and multiply it by the normalized vector that points in the opposite direction of the relative velocity. Last multiply this by a constant that you find by experimentation (until it looks good). The result is an acceleration vector that you let act on the leaf's velocity.
Edit: To get a more irregular behavior, you also have to add a bit of randomness. Ad hoc, I don't know how to do this in a reasonable way.
Re: leaves falling from the tree and physically
Posted: Mon Oct 07, 2013 5:15 pm
by soullessbr
First, thanks for the reply.
To be honest never shifted with games so I'm picking up a bit, but walking. I'm at work right now (I'm php developer) and when I get home I'll try to implement something.
Thank you in advance partner!