# Leaf movement simulation in a 3d world

I am using opengl, and a simple texture or mesh to draw a leaf.

Can somebody show me a nice movement method to simulating leafs in a 3d world?

thanks, Leslie

-
Do you mean leaves moving while attached to a tree (e.g. rustling and swaying in the wind), or individual leaves floating through the air? – Nathan Reed Feb 4 '12 at 21:02

I guess it really depend on what type of leafs you want to simulate. for each type go out and check how it's moving in the air. there is no need for an actual physical simulation just find a function that has an output similar to what the leaf moves.

here are some sample function:

``````Vec3 LeafAPosition(Vec3 lastPosition, time now, time lastTime)
{
Vec3 result;
result.z = lastPosition.z - constant_value1 * (now - lastTime);
result.x = lastPosition.x - constant_value2 * cos(lasttime) + constant_value2 * cos(now);
result.y = lastPosition.y - constant_value2 * sin(lasttime) + constant_value2 * sin(now);

return result;
}

Vec3 LeafBPosition(Vec3 lastPosition, time now, time lastTime)
{
Vec3 result;
result.z = lastPosition.z - constant_value1 * (now - lastTime);
result.x = lastPosition.x - constant_value2 * (now - lastTime);
result.y = lastPosition.y - constant_value3 * (now - lastTime);

return result;
}
``````

I'll post more functions as soon as they came to my head.

-
I d like to rotate the leaf too in the 3d world...so not just moving it. How cna I use your algorithms? When can I call this method? – lacas Feb 5 '12 at 9:26
for rotating use similar method, some leafs just rotate always with same speed or some will rotate randomly and so on. just try changing your algorithm until it feels okay. beside you have to move leafs in every cycle, so you just have to call these functions in every cycle while updating each leaf. – Ali.S Feb 5 '12 at 12:49