View Full Version : Introducing "wander" to particle movement
StefanAlbertz 10202009, 01:58 PM Craig Reynolds came up with the wander movement in his boidsystems... how to do it with particles?
IŽve a firework shot to do and i thought that i could use that wander behaviour to make the flightpath a bit more natural (without using a field). imagine a rocket that explodes, split into 10 parts, each part flying away (inherited velocity + own initial thrust) and while flying, starting to leave the path, like spinning a bit of. Those fireworks look a bit like flyes. Like as if they inherit a life of their own when they are released from the main rocket.
I tried to find a way to use noise to manipulate the velocity vector, but my math knowledge has some flaws here. If i construct a vector vertical to the velocity vector and add it to it to create a new velocity then appliying the stored length of the original velvector back onto the new one the problem would be solved. The problem is: setting up the vector vertically onto the original velvector. Since there is the "circular freedom" around the vector, there are too many unknown variables to solve the solution .. Reynolds solved it  his flockofbirds to 3d movements that "slowly" change their direction in 3d space .. i "only" need that code part ...
any help on that would be appreciated!!
Stefan


stooch
10202009, 05:23 PM
you could use velocityPP += sphrand()
this will ADDITIVELY blend a random vector into your velocity
if you want more control you could do this positionPP += <<noise(time()), noise(time()), noise(time())>>
this gives you more control, for example i could reduce how much vertical drift my particle experience by reducing the Y vector. notice how im using a noise instead of random. random will generate discrete values each step, while noise will introduce more consistent variations between substeps.
of course you should familiarise and experiment with controlling the noise command to adjust its frequency and range...
p.s. the mag() command will take a vector and give you its magnitude as a scalar.
so for example mag(velocityPP) will give you a value of 3 if the velocity is <<3,3,3>>
this is useful to reduce the amount of noise you are useing to offset your velocity, as your particle slows down, the magnitude could be used to calm down the particles:
$mag = mag(velocityPP)
positionPP += <<noise(time())*$mag, noise(time())*$mag, noise(time())*$mag>>
this will result in a willd particle at birth but its noisy flight will calm down as its overall speed is reduced with drag.
if you use a command like linstep or clamp on your $mag you can make sure that the overall magnitude multiplier stays within a certain range to keep things stable. for example i might not want my $mag to be higher than 2, or remap the $mag to a custom range entirely. For example i could create a PP variable at birth that finds out the initial speed of that particle and then use linstep to remap the particles noise to a desired range in the runtime section.
also initially i had velocityPP as the modified attribute, but you really dont want to use += on velocity because it will end up constantly increasing it, you would be better off using a * on velocity, combined with the clamping or remapping functions.
Craig Reynolds came up with the wander movement in his boidsystems... how to do it with particles?
IŽve a firework shot to do and i thought that i could use that wander behaviour to make the flightpath a bit more natural (without using a field). imagine a rocket that explodes, split into 10 parts, each part flying away (inherited velocity + own initial thrust) and while flying, starting to leave the path, like spinning a bit of. Those fireworks look a bit like flyes. Like as if they inherit a life of their own when they are released from the main rocket.
I tried to find a way to use noise to manipulate the velocity vector, but my math knowledge has some flaws here. If i construct a vector vertical to the velocity vector and add it to it to create a new velocity then appliying the stored length of the original velvector back onto the new one the problem would be solved. The problem is: setting up the vector vertically onto the original velvector. Since there is the "circular freedom" around the vector, there are too many unknown variables to solve the solution .. Reynolds solved it  his flockofbirds to 3d movements that "slowly" change their direction in 3d space .. i "only" need that code part ...
any help on that would be appreciated!!
Stefan
StefanAlbertz
10262009, 03:15 PM
thanks for that idea. after reading through the boids wander a bit more, it seems that reynolds took the same approch: he put a random spherical vector on top of the velocity vector. But what he added was some kind of reduction of that vector so that the sphere resulted in just a circle oriented around the top of the velocity vector. Thus preventing a orientation against or along the vector itself  just some steer movement. He then added this steering via a noise, so that the steering wasnt always at complete power.
iŽll try to put this into the formula also ..  for my current job i used the way you described  it did the job.
stooch
10262009, 06:50 PM
thanks for that idea. after reading through the boids wander a bit more, it seems that reynolds took the same approch: he put a random spherical vector on top of the velocity vector. But what he added was some kind of reduction of that vector so that the sphere resulted in just a circle oriented around the top of the velocity vector. Thus preventing a orientation against or along the vector itself  just some steer movement. He then added this steering via a noise, so that the steering wasnt always at complete power.
iŽll try to put this into the formula also ..  for my current job i used the way you described  it did the job.
you can sample vector by comparing the current position of a particle with its previous one.
I would toggle the vector calculation with a boolean on the control shape though, so that you can turn it off on demand.
CGTalk Moderation
10262009, 06:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.