Jump to content
  • Advertisement
Sign in to follow this  
Blueberry

Particle Wind

This topic is 3495 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

Hello. I'm new here, please move this if it's posted in the wrong section. I've been working on a basic 2d particle system i XNA and so far things have gone pretty smoothly. (The problem I'm having isn't related to any part of XNA so I decided to post it here) I wanted to have "local" wind on the particles, not the same wind on the entire area. So I made a 2d array called "windMap" that is the screen-height/10 in "Y"-size and screen-width/10 in "X"-size, so every value in the array can be used to represent a 10x10 area. The values in the windmap adds it's wind-speed to the particles in that area and that part works well. My problem is with the movement of the wind in the "windMap". I've made something basic that transfers wind from left to right and spreads it out vertically. (The X is the X-speed and the Y is the Y-speed) for (int i = 1; i < windSizeX-1; i++) { for (int ii = 1; ii < windSizeY-1; ii++) { //slowdown windMap[i, ii].X = windMap[i, ii].X *0.5f; windMap[i, ii].Y = windMap[i, ii].Y * 0.5f; //transfer 100% of the remaining windpower windMap[i + 1, ii + 1].X += windMap[i, ii].X * 0.25f; windMap[i + 1, ii + 1].Y += windMap[i, ii].Y * 0.25f; windMap[i + 1, ii].X += windMap[i, ii].X * 0.5f; windMap[i + 1, ii].Y += windMap[i, ii].Y * 0.5f; windMap[i + 1, ii - 1].X += windMap[i, ii].X * 0.25f; windMap[i + 1, ii - 1].Y += windMap[i, ii].Y * 0.25f; //more wind slowdown windMap[i, ii].X *= 0.95f; windMap[i, ii].Y *= 0.95f; } } http://img529.imageshack.us/img529/5020/screenshotlowq.jpg (it "blows" from one point at the top of the blue thing) It works pretty well but the wind can only spread from left to right. I need the wind to spread correctly according to the angle it blows at. I can get the direction of the wind (not shown in the code). Does anybody have any suggestions? [Edited by - Blueberry on April 22, 2009 7:48:40 AM]

Share this post


Link to post
Share on other sites
Advertisement
Here's a general response.

x,y | x,y
---------
-,+ | +,+
---------
-,- | +,-


If your wind only blows left to right, it might be due to only adding positive offsets to the position of the particles. That would be the upper right hand quadrant of the above map (+,+). If this is the case, then adding negative offsets (-,-) should result in wind that blows right to left and adding a mixture of positive and negative (+,-), (-,+) should result in wind that blows crosswise in either direction depending on whether a negative offset is applied to x or y.

If you want to direct the wind using an angle (e.g. rotating a steering wheel).

double radians = angle * 0.01745f; // convert degrees to radians
x += (mx * cos(radians));
y += (my * sin(radians));

where mx,my is the speed of the particle on either axis. See The Unit Circle.




[Edited by - LessBread on April 22, 2009 1:09:31 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!