# 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.

## 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 on other sites
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).

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]

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
633346
• Total Posts
3011450
• ### Who's Online (See full list)

There are no registered users currently online

×