-
Random, Intermittent Wind Gusting – Bending with Pauses
Hello, I’m working on making a tree sway in the wind in a realistic manner with expressions, so it can be applied to many without manual keyframing required. I’m using CC Bend It and am trying to get it to simulate gusts of wind that come only periodically.
I found an old Dan Ebberts expression that has gotten me part of the way, but what I’m struggling with is how to get the tree to return back to center (zero bend) after each gust, before pausing. (Also trying to understand the % percent sign operator) Any help would be appreciated!
moveMin = 0.5; // minimum move time (initial wind gust)
moveMax = 1; // maximum move time
moveBackMin = 1.5; // minimum move time to return to zero (slower than the initial gust)
moveBackMax = 2; // maximum move time to return to zero
pauseMin = 1; // minimum pause time
pauseMax = 2; // maximum pause time
minVal = -20; // minimum move amount <-
maxVal = 20; // maximum move amount ->
seedRandom(index,true); // set pre-run for endT
endT = - random(moveMax);
j = 0;
k = 0;
while ( time >= endT){
j += 1;
seedRandom(j,true);
startT = endT;
if (j%2){
endT += random(moveMin,moveMax);
k++;
}else{
endT += random(pauseMin,pauseMax);
}
}
if (j%2){
seedRandom(k,true);
endVal = random(minVal,maxVal);
seedRandom(k-1,true);
startVal = 0;
ease(time,startT,endT,startVal,endVal);
//ease(time+endT,startT+endT,endT+endT,endVal,0);// Return to zero?
}else{
seedRandom(k,true);
random(minVal,maxVal)
}