Face normals collision


#1

Hi guys!
Is there a way or a node able to solve the one-sided particle-object collision?
By default, particles in maya collide with connected surfaces on both sides not taking into account face normals or double-sided attribute. I would need to achieve something similar to realflow particles, where you choose which side of surface will particles be colliding with.
Thanks a lot!


#2

I have the same question, I only want one side of an objects faces to collide with particles. Is this possible?


#3

I only want one side of an objects faces to collide with particles. Is this possible?

Yes. You could do some fancy vector math, or you could be lazy and assign a white textire to one side of the object and black to the other side. Then use colorAtPoint and traceDepthPP. Like so:


 //upon collision
 if (particleShape1.collisionU != -1 )
 {
 // get collisionU
 float $colU = particleShape1.collisionU;
 //get collisionV
 float $colV = particleShape1.collisionV;
 // get the color at the UV
 vector $colRGB = `colorAtPoint -o RGB -u $colU  -v $colV ramp1`;
 
 if ($colRGB != <<1, 1, 1>>)
 	particleShape1.traceDepthPP = 0;
 else 
 	particleShape1.traceDepthPP = 10;
 
 }

#4

That’s a great idea, thank you.


#5

nice lateral thinking:thumbsup:


#6

I noticed that this works for all collisions, except the first one. Change the expression to this to fix that (thanks to Nigel for the tip):


//upon collision
if (particleShape1.collisionU != -1 )

{
// get collisionU
float $colU = particleShape1.collisionU;
//get collisionV
float $colV = particleShape1.collisionV;
// get the color at the UV
vector $colRGB = `colorAtPoint -o RGB -u $colU  -v $colV ramp1`;

if ($colRGB != <<1, 1, 1>>)
{
	//ADJUSTED
	particleShape1.velocity = particleShape1.collisionIncomingVelocity;
	particleShape1.traceDepthPP = 0;
}
else 
	particleShape1.traceDepthPP = 10;

}

#7

Just a question drGonzo, if I create a collision and make particles numeric, all my collisions are -1 I dont understand why this is the case here, can you explain?


#8

Assuming you are using collisionU as numeric: this attribute will always be -1, except at the exact time of a collision. Step through the sim to see that the number changes to the collisionU only when there is a collision.


#9

Ahh thankyou


#10

When I replied earlier I assumed that I’d be able to figure out how to implement it, it turns out I’m stupider than I thought. Basically I tried entering this expression into “Trace Depth PP” and got:

// Error: Attribute not found or variable missing '

: particleShape1.collisionV

 

I'm not too good with expressions :blush:. Could someone dumb it down for me please?

#11

Looks like you gotta add the attribute yourself under Add Dynamic Attribute, General, Particle.


#12

I added the attributes and didn’t get any errors now, but my particles are still colliding with my white plane.

Assuming you are using collisionU as numeric: this attribute will always be -1, except at the exact time of a collision. Step through the sim to see that the number changes to the collisionU only when there is a collision.

Mine are all numbered normally.


#13

Maybe you’re not using ramp1 as your texture.


#14

Yes, thank you. The only way I know how to make a surface double sided is to use two ramps with a condition and sampler info node. How did you make an object double sided with just one ramp?

Also, when the particles pass through they lose a lot of velocity.


#15

Well theorectically it wouldnt work if you had another ramp in there because the colorAtPoint is reading ramp1 only so i ditched that idea and just created one ramp with B/W color chips with no interpolation so half the ramp was black and the other half was white, then it works. You can have some fun with it if you make it a circular ramp and animate its offset or create a noisy ramp.


#16

But how did you assign black to one side and white to the other?


#17

I found a way to create collisions on one side and not the other using the following code…


 vector $goalNorm = particleShape1.goalWorldNormal0PP;
 if ($goalNorm.y != 1)
 traceDepthPP = 0;
 else
 traceDepthPP = 10;
 

Basically setup a goal between the particle and surface but set its weight to a value of .001 so it has no effect but is greater than 0. Then add goalWorldNormal0 per particle attribute with the above code.


#18

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.