View Full Version : Particles with charged (positive and negative) fields
10-18-2009, 02:05 AM
I am still kind of a noob with Maya, having been learning all I can the last five months.
Say I want to do some crazy stuff with Maya particles behaving like charged particles (ions for example). I managed once to make particles emit radial fields which faked collisions before I learned about nDynamics. Now I am trying to figure out some way I could use perhaps fields so that equal fields repel each other and opposite attract.
The goal is to simulate simple chemistry behaviour.
Any way without scripting you more veteran guys might remember about (fields emitted PP or something)? If its only possible with scripting it would be nice if someone knows a good direction to follow.
Thanks to all.
10-19-2009, 01:40 AM
You can do this, bit it will require a little bit of scripting - not much, but some.
You will also need to make it so that the field in question a child of the particle object so that you get a radial field made for each particle.
For the main part you are looking at needing a creation script which sets the magnitude of your radial fields to be either positive or negative on creation.
So this assumes you have a particle emitter already created and have made a radial field for the particles and have used the menu command Main Menu->Fields->Set Selected to be Source of Field.
Make a custom per-particle attribute for your particle shape to control the magnitude of the radial field. There is a special naming convention which you must follow for this to work properly. All that is needed is that you name the attribute so that it has the name of the field and the name of the attribute with an underscore between them.
FIELD_ATTR or radialField1_magnitude
So click on the General button on the Add Dynamic Attributes pane on the Particle Shape Attribute Editor and give your attribute the correct name (radialField1_magnitude) and set it to be a float and also set the Attribute Type to be Per particle (array) and click the OK button (the Add initial state attribute can be enabled).
Right-click in the newly created attribute field and choose "Creation script" and paste the following into it:
// Creation Script.
float $mag = 5.0 ; // Declare your initial magnitude.
if (noise(particleId) < 0)
$mag = -5.0 ; // Use a conditional statement to randomly set some to negative.
radialField1_magnitude = $mag ; // Sets your magnitude with the creation variable.
And click the create button.
You can adjust the falloff and attenuation values to suite.
Please let me know if this is not clear or you need further assistance.
10-19-2009, 11:59 PM
Thanks for the very detailed and fast reply Meesto. It really helps give a lot of control to the particle and its field.
And what if I would want to have two radial fields being emitted from a particle shape? One affecting itself, and the other affecting a second particle group? Also the second group with this same arrangement. I have tried this, but it seems that only one field emits from a particle at a time.
Somewhat seems that a connection is broken when I connect the second field to the particle shape node.
11-05-2009, 06:20 PM
Someone know the answer to my question?
Can we emit two fields (radial) from a particle source (emited from individual particles)?
One field is to affect the source particle group. The other is for affecting another particle group. One could be positive, the other negative. So Equal encountering particles repel and Different encountering particles attract each other.
Another solution would be perhaps to have only one field but affecting differently the source particles and non source particles. I think.
Is any of these scenarios doable?
11-05-2009, 10:46 PM
the answer of course is yes, you can pretty much do anything... the problem comes in how the solution is manifest..... scripting and complex maya dynamics go hand in hand. I would suggest looking through this forum and if you can getting your hands on the gnomon tutorials for dynamics they are a great starting point for anyone new to maya dynamics.
11-05-2009, 10:46 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.