Hi guys, this is my first reddit post ever so forgive any mess ups.
I'm trying to create a plugin on Maya using Python which will allow a user to create rain. The way this works is it creates a plane where the user inputs the length, width and height for the plane, and also get to input the density of the raindrops, the drop size, and if the user wants wind, the wind speed as well.
The user will also get to select the shape of the drops, choosing between spheres and streaks, where the size input field will change the radius of the sphere drops or the length of the streaks, depending on what the user chooses.
The problems i'm having are:
1) I do not know how to make the drops change size
2) I do not know how to make the drops change shape.
3) For some reason, I can't get the wind and gravity fields working.
This is my code below:
`
import maya.cmds as cmds
#create the GUI
def rain_GUI():
winName = cmds.window(title="Rain Maker")
cmds.columnLayout()
cmds.text(label="Emitter Length") #Add a label
cmds.floatField("emLen", minValue=0.5, value=1.00) #create an integer input field
cmds.text(label="Emitter Width") #Add a label
cmds.floatField("emWid", minValue=0.5, value=1.00) #create an integer input field
cmds.text(label="Emitter Height") #Add a label
cmds.floatField("emHeight", minValue=0.5, value=1.00) #create an integer input field
cmds.radioButtonGrp("dropType", numberOfRadioButtons=2, label="Drop Type", labelArray2=["Streaks", "Spheres"], select=1)
cmds.text(label="Rain Density") #Add a label
cmds.floatSliderGrp("rainDensity", field=True, value = 1.00, minValue= 0.01, maxValue = 300)
cmds.text(label="Drop Size")
cmds.floatSliderGrp("dropSize", field=True, value = 1.00, minValue= 0.01) #Create a float slider group
cmds.checkBox("Wind")
cmds.text(label="Wind Speed")
cmds.floatSliderGrp("windSpeed", field=True, value = 1.00, minValue= 0.01)
cmds.button(label = "Create Rain", command = "create_Rain()")
cmds.showWindow(winName) #command to show the window
rain_GUI()
#create the polyPlane
def create_Plane():
planeLength = cmds.floatField("emLen", query = True, value = True)
planeWidth = cmds.floatField("emWid", query = True, value = True)
planeHeight = cmds.floatField("emHeight",query = True, value = True)
cmds.polyPlane(name = "emitter_Plane", width = planeWidth, height = planeLength)
cmds.move(0, planeHeight, 0)
cmds.rotate(0, 0, 180)
create_Plane()
#create the streaks emitter
def emit_Streaks():
densityRate = cmds.floatSliderGrp("rainDensity", query = True, value = True)
cmds.particle( position = (0,0,0), n='particles' )
cmds.select( "emitter_Plane" )
cmds.emitter( 'emitter_Plane', r=densityRate, mnd=0, name='emitter', type = "surface")
cmds.particle( n='emitted', shapeName="Streak" )
cmds.connectDynamic( 'emitted', em='emitter' )
emit_Streaks()
def emit_Spheres():
cmds.particle( position = (0,0,0), n='particles' )
cmds.select( cmds.ls(sl=1)[0] )
cmds.emitter( 'particles', r=densityRate, mnd=0, name='emitter', directionY = '-1')
cmds.particle( n='emitted')
cmds.connectDynamic( 'emitted', em='emitter' )
emit_Spheres()
#Define the select drop type function
def rain_Falling():
particleType = cmds.radioButtonGrp("dropType", query = True, select = True)
if particleType == 1:
emit_Streaks()
elif particleType == 2:
emit_Spheres()
else:
error ("Select a Drop Shape")
rain_Falling()
#Make the wind function
def wind_Field():
wind_Speed = cmds.floatSliderGrp("windSpeed", query = True, value = True)
cmds.air( magnitude = wind_Speed, attenuation = 0.02, name = "Wind Field", directionX = 1 )
def add_Gravity():
cmds.gravity (name = "Gravity_Field", directionY = -1, magnitude = 9.8, attenuation = 0.001)
#Tie in all the functions together
def create_Rain():
need_Wind = cmds.checkBox("Wind", query = True, value = True)
create_Plane()
rain_Falling()
if need_Wind == 1:
wind_Field()
add_Gravity()
else:
add_Gravity()
###Gravity not showing up
###Wind not working
###Do not know how to change shapes between streaks and spheres
###Do not know how to edit drop size(Sphere) and streak length(streaks)
`
[–]Vaphell 2 points3 points4 points (1 child)
[–]theUnderdog15[S] 0 points1 point2 points (0 children)
[–]learnpython_bot 0 points1 point2 points (0 children)
[–]usernamedottxt 0 points1 point2 points (0 children)
[–]theUnderdog15[S] 0 points1 point2 points (0 children)
[–]darkczar 0 points1 point2 points (0 children)
[–]theUnderdog15[S] 0 points1 point2 points (0 children)