Archived

This topic is now archived and is closed to further replies.

Influencing particles by wind

This topic is 5146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi i have coded a particle engine simulating fire, where the particle quads rise randomly up. the particles always face the camera (billboarding). now i have implemented wind influence, the wind linerarly changes between two vectors in random time slices. currently, i add the wind vector to the particle 3d point to simulate the influence. but i want to change the orientation of the particles according to the direction of the wind, but i have no idea how to do this.... can someone tell me how ? thanks for any answers! greets Gammastrahler

Share this post


Link to post
Share on other sites
Yeah, the whole idea of billboarding is that the sprite is always aligned with the camera. So how would you change the orientation? It seems that having the particles'' velocities change would be enough...

Share this post


Link to post
Share on other sites
Work out how the plane of the sprite (the one orthogonal to the camera view) is affected by wind (presumably it is rotated in some way) and then project this back into the plane of the camera lens. It''s a simple vector operation for each pixel in the sprite. Check out bitmap transformations.

Timkin

Share this post


Link to post
Share on other sites
I don''t think he means orientation, I think he means direction that the particles are travelling ie. velocity.

Gammastrahler, you will have to have a velocity vector for each particle too. Your code will then look something like this (under simple euler integration).

struct particle
{
vector position;
vector velocity;
rgba colour;
real mass;
};

and in your update loop you will have something like:

particle.position += particle.velocity * time;
particle.velocity += windvector * time;
particle.velocity += gravityvector * time;

The variable ''time'' in the above is the time elapsed from the previous run of the loop.

If I was wrong with my assumption and you want to be able to orient the particles differently (eg. leaves blowing in the wind), then you will have to add the following kinds of things to your particle structure:

real rotationvelocity
real rotation
vector rotationdirection

rotationvelocity is the angular velocity, rotation is the current angle and rotationdirection is the vector around which rotation takes place.

Now, your windvector will not only affect your particle''s linear velocity (ie. particle.velocity), it will affect your angular velocity as well as your rotationdirection. I don''t have the formulae for these changes, but I am fairly certain that they correspond to the same concepts in rigid-body physics.

In order to apply these rotations to the particle, you will have to do something like this in OpenGL.

glTranslatef(particle.position.x, particle.position.y, particle.position.y)
glRotate(particle.rotation, rotationdirection.x, rotationdirection.y, rotationdirection.z)
DrawParticle(particle)

and in your update loop
particle.rotation += particle.rotationvelocity * time

Hope that helped...

Share this post


Link to post
Share on other sites