To start the scripting off I used Notepad++ to create it on which I then started to create a simple UI to begin with so that I could get the weather states playing from a click of a button.
This script would bring up a small UI with the 4 buttons of Rain, Snow, Dry and a debug button on which the plan was to have that as the linear interpolation test.
To get this script running I had to make sure the script file was in the maya script directory and then in Maya with Python make a script for a button.
import DynamicWeatherSystem as dws
reload(dws)
UI = dws.WeatherSystem()
When creating this script I did some research first into how to get global variables to work because originally when I put them in the original place it wouldn't run the script and came up with errors.
After spending time fixing these and working out how to get the global variables working better I was able to get the script running.
The script as this point was so that when the button was pressed, it would created the UI with the buttons and then during play mode if you click on of the weather button it would change to that state and if it was currently another weather state it would stop that so never was it possible to have rain and snow at the same time, it was either one or the other.
Next was the linear interpolation, I was not sure how to get this type of effect to work so I requested help from one of the lecturers who gave me a base of a script to get working on.
With this Grant was able to get it so that with each button press the water amount would add a little each time till it was full (at the number 1 on the lerp).
The next part was a little more tricky for myself because I needed to work out how to get it to change at any point in the timeline due to a random number. I had no idea how I was going to do this right away so I tried to program it so that when I pushed a button it would lerp into that weather state.
To get it working with the timeline first I had to figure out how to get the expression editor to work with it, I tried some different ways of getting this to work. Each time and with each edit I kept running into issues, I tried so many ways originally but when I started of it was having a problem connecting to the notepad++ script that I had created.
One of the ways I tried was having this in the expression editor:
python("WeatherSystem(Frame_Counter("+frame+")");This was suppose to grab the class of weather system and get the frame counter that I had made.
The counter and expression editor was more of a headache than I originally anticipated, following the past tutorials was slightly helpful but I felt lost most of the time like I didn't know what I was doing and I couldn't understand what was doing what which I didn't not much like as I like to know what does what.
After trying many other different ways I went ahead and emailed the lecturer asking why it was not working.
Even though I wasn't sure the lecturer would email me back I kept trying different ways.
With a help of a friend it we came up with a solution of having a function in the maya python editor that would link both the Notepad++ script and expression editor together, we managed to get it working from that.
No comments:
Post a Comment