# Need MEL script to control Particle Collisions

#1

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.

Ideas?

#2

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.

http://www.olympusmicro.com/primer/java/refraction/criticalangle/index.html

#3

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?

/Risto

#4

Thanks!

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.

#5

Would this help?

http://www.3dkingdoms.com/weekly/weekly.php?a=2

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

I must ask, can you write MEL at all?

/risto

#6

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.

#7

So do you need help with this ?

/risto

#8

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.

Cheers,

/Risto

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

#9

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

#10

Just PM me if you need real help.

Cheers, mate

/Risto

#11

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.