Saturday 18 April 2015

Storm Script - Wind Gusts

Something I wanted to include in the storm script are events like random gusts of wind, or gradual increases of turbulence and moving fog.

I began with implementing a random gust of wind. With the storm slider activated (anything over 0) I knew there would be a constant wind speed. I wanted the wind at a certain point to accelerate quickly then peak off and return to the constant speed.

To activate the event, a random number is generated at every frame and if that number is higher than a set number, then the event activates. I picked random numbers and played through the simulation a few times until I got a frequency I was initially happy with.


I knew the result I wanted and I was confident I'd be able to code it out but was initially stumped on how to implement it.

I discussed this with Computer Games Technology student Michael Daltrey who helped me to take my idea and apply a logical coder's approach to each step needed. I drew out a speed curve over time to suggest ways I could attempt to add the wind. Michael drew an acceleration curve as this variable would be the main change which would affect the speed at each frame. We decided the first curve type (out of the three drawn) was the easiest to approach and we worked out the pseudocode.

From here, I tackled this in Python, initially getting a triangular peak (as shown on the bottom right of the image) as I was using a constant acceleration and deceleration. After changing the rate at which the acceleration changes (to match the acceleration curve) and after contending with a few Maya freakouts I was getting promising results.


This is a screenshot from the script editor which prints out variable data each frame. This gust of wind was activated on frame 114. Note at frame 124 the acceleration is displayed as a very small number. This should be 0 but Maya doesn't quite agree, this was one of the freakouts I mentioned earlier, I had 2 lines of code which helped to work with that number.

Now I just need to link this variable to a wind field within the scene. That will then affect the particles of dust and smoke within the scene.

No comments:

Post a Comment