Collision of nParticles based on the normal of the surface?


Hi, i am looking for an expression or a technique where i could use one same surface, but let the particles go through it if they are hitting it from one side, and collide with it if they are hitting it from another.
I believe it could have to do with collisionNormal attribute, but i am just not sure exactly how to set it up, so if anyone can answer, or point me to a relevant thread, i’d appreciatte it.

i tried with something like this, but probably i am making some obvious mistake, since it's not working :) 
if (nParticleShape1.collisionNormal == -1)
     nParticleShape1.collideStrengthPP = 0;
     nParticleShape1.collideStrengthPP = 1;


I think you can’t do it the that way.

I don’t know what you really need here , this is example based on particle position.

//check is custom per particle float attr
vector $wPos=(position);
if(($wPos.y) > 0 && check==0){check=1;}

Basicly i have plane at position 0 0 0 . My emiter is below plane , and particles pass through plane on way up , but on way down they collide.
This is with nParticles.

Maybe you have more complicated model i need this to work with surface normal , that is when particles is in volume , and when get out of volume?


This thread seems to get where you are looking to go…hope it helps.


You might try the following:

On the nRigid for the collision object turn off “collide” and instead set forceField to Along normal. Adjust the field distance to be relatively small, but not so small your particles don’t collide at all.
It is not the same as collisions, but might work for you depending on your needs.



Thnx a lot for your answers, i have a few way i’ll use this, but i really think it would be so useful to all of us to have that option like we have in RealFlow.

Ginodauri, that’s one good way, but unfortunately i have a bit deformed surface, so this is not gonna work for me on this one. It’s perfect for a plane, and flat surfaces, but just not for this one. Anyway, thnx for interest.

@aniamtedfox Yes, that thread is also very helpful, just the idea of using the black and white image is something i am gonna use this. It’s very good idea by KM. thnx for pointing me there.

Duncan, thnx a lot for taking interest in this one, and i hope that new Maya will have this kind of an option…maybe you can share that info with us now? :slight_smile:


I don’t know , i can’t get above example(texture based) to work , because first collision is happen and then in next frame you can manipulate particles.

This is solution based on mesh normal.

float $pos[]=p.position;
vector $closNormal= python(“closestNormal([”+$pos[0]+","+$pos[1]+","+$pos[2]+"])");
float $dot=dot((p.velocity),$closNormal);
if ($dot<0)

/*pymel proc
def closestNormal(point):
return mesh.getClosestNormal(point)[0]

basicly run this pymel procedure , and put mel code in particle expression.

If particle is on other side expression constanly checks for normals , if particle pass other side it assigns collideStrengthPP=1.

You can optimize this code to only check for normals when particle is in certain distance range.


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.