Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Batch Script Part

 

Code Block
themeEclipse
languagepython
linenumberstrue
emitterList = []
colourList  = ["Red","Orange","Purple","White","Yellow"]
rgbList     = ((200,0,25),(255,150,0),(180,0,180),(255,255,255),(255,225,0))
emitters    = scene.get_PB_Emitters()

for emitter in emitters:
    emitterList.append(emitter.getName())

guiForm = GUIFormDialog.new()

guiForm.addListField("Source Emitter", emitterList, 0)
guiForm.addListField("Target Emitter", emitterList, 1)
guiForm.addListField("Colour", colourList, 3)
guiForm.addFloatField("Threshold Value", 2.0)
guiForm.addFloatField("Tolerance", 1.0)
guiForm.addFloatField("Speed", 2.0)

if (guiForm.show() == GUI_DIALOG_ACCEPTED):
    emitter1  = guiForm.getFieldValue("Source Emitter")
    emitter2  = guiForm.getFieldValue("Target Emitter")
    colour    = guiForm.getFieldValue("Colour")
    threshold = guiForm.getFieldValue("Threshold Value")
    tolerance = guiForm.getFieldValue("Tolerance")
    speed     = guiForm.getFieldValue("Speed")

# Process the source emitter's properties and set speed to the given value

source       = scene.getEmitter(emitterList[emitter1])
s_resolution = source.getParameter("Resolution")

source.setParameter("Speed", speed)
source.setParameter("Color", Vector.new(128,128,128))


# Attach colour, parameters and set speed/volume to 0.0 

e_colour = rgbList[colour]
rgb      = Vector.new(e_colour[0], e_colour[1], e_colour[2])
target   = scene.getEmitter(emitterList[emitter2])

target.setParameter("Color", rgb)
target.setParameter("Resolution", s_resolution)
target.setParameter("Speed", 0.0)
target.setParameter("Volume", 0.0)


# Define the global variables

scene.setGlobalVariableValue("source", emitterList[emitter1])
scene.setGlobalVariableValue("target", emitterList[emitter2])
scene.setGlobalVariableValue("threshold", threshold)
scene.setGlobalVariableValue("tolerance", tolerance)
 

# Reset and start the simulation automatically, abort with ESC!

scene.reset()
scene.simulate(0,200)

...