Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
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

1 Answer 1

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.