1
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\begingroup\$ 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? \$\endgroup\$ Commented Feb 4, 2012 at 21:02

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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? \$\endgroup\$
    – lacas
    Commented Feb 5, 2012 at 9:26
  • \$\begingroup\$ 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. \$\endgroup\$
    – Ali1S232
    Commented Feb 5, 2012 at 12:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .