Snow Simulation
For the weather simulation I decided to go for a snow effect to fall down onto the city. The first thing I looked at was to generate directional emitters which did not work. So after going through the emitters available for use within python I just went with the normal particle emitter which would disperse the particles. After trying to just generate the emitters it still did not work so I had to generate a collective of spheres for them to attach to which originally acted like clouds and then dispersed the particles.
What I ended up with was this:
def Clouds(slider):
cloud_range = cmds.intSlider(slider, query = True, value = True)
Sphere_List = []
#creating the spheres for the emitters to attach to which act like clouds when the particles disperse.
for i in range(-cloud_range,cloud_range+1):
for j in range(-cloud_range,cloud_range+1):
cloud = cmds.polySphere(sx=20, sy=20, r=0.5)
cmds.move( j*4+15, 16, i*4+15 )
Sphere_List.append(cloud[0])
#the emitters that generate the particles in a dispersal pattern over a certain amount of keyframes down upon the generated buildings.
particles = cmds.particle( p=((-1, 5, 2), (2, 2, 2), (3, 3, 3)), n='particles' )
cmds.move( 0, 16, 0 )
emitters = cmds.emitter(Sphere_List, r=20, mxd=3, n='emitter', type = "surface" )
cmds.move( 0, 20, 0 )
cmds.connectDynamic( particles, em = emitters )
#This is a aide command to hide the clouds to make the snow generated particles look more natural while falling down.
cmds.hide(Sphere_List)
The final piece of script I decided to use to create the particle effect for snow, which generates a group of spheres which have emitters attached to it so it can generate a group of snow particles in a dispersal pattern over the generated buildings over set of key frames to match the pace of the other cycles within the city. Once this is generated the code also hides the spheres without affecting to emitters themselves so that the particles can still fall and look more natural instead of having random shapes in the sky.
Within the script I added a input so that if you change certain variables you can increase and decrease the amount of emitters, which I later want to incorporate into a slider system within the ui to generate the city.
Programming for Computer Animation and VFX - Maya Python City
Status | Released |
Author | Aronne_Monk |
More posts
- FunctionsApr 24, 2023
- UI (Buttons & Sliders)Apr 24, 2023
- BuildingsApr 24, 2023
- Day and Night CycleApr 24, 2023
Leave a comment
Log in with itch.io to leave a comment.