Need MEL script to control Particle Collisions


I’m using particles to simulate light and I need to set up a collision event that allows me to change the particle’s direction with an equation.

For this, I need to establish a variable equal to angle which the particle strikes the object at (or maybe multiple objects/impacts) but I don’t know how to get Maya to give up this information.



The Java applet on this page does exactly what I’d like to reproduce - but I’m not sure how to establish the incident angle.


Hi Kristian.

You can get what need with nearesPointOnMesh - node and your particle’s velocity.

Connect your mesh’s worldMesh -> nearesPointOnMesh.inMesh and you can query
the normal with providing a position on the mesh.

Does this help?




It’s a point in the right direction, but I’m going to have to do a lot of work to figure out how to structure that into a function which determines the direction.

I can see how with the object plane’s translate co-ordinates I should be able to calculate the direction it is facing in relation to my particles direction (past and current locations) but it seems like the long way around - and I’m not sure I have the skills to code all that together within my timeframe.

It strikes me however that Maya automatically calculates which direction to send the particle after impact, and this is equal to the angle with which it was struck. If I can find the var/attribute for that angle, I can multiply it by a new variable (determined by the index of refraction I assign to the object and an if/else statement to determine critical angle) to give me the resulting angle of refraction.

I’m not sure if this method is entirely possible, but it seems like the way to approach the problem.


Would this help?

Since you now have the velocity vector and a surface normal vector…

I must ask, can you write MEL at all?



I’ve changed the behaviour of the odd particle with it, but that’s about it. Pretty much all of my programming has been in ActionScript.


So do you need help with this ?



Might this help you, Kristian ?

There should be a maya 2011 ascii file attached.

You’ll find a refrValue - attribute in particle1-node, which acts as “refractive index” .

Look up the particle expression and you’ll get hang of it.

Ask me if you have more questions.



ps: and if you are getting paid for this, a little commission wouldn’t be so bad… ;-D just kidding


Haha - You’re awesome! Thanks for the help, it’s just student work but pass on your contact info - never know when a job might pop up that requires someone with your skills! It’s 2am here will open the file & let you know how I go tomorrow. Cheers


Just PM me if you need real help.

Cheers, mate



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.