View Full Version : Face normals collision

 maxtorag07 July 2008, 11:28 PMHi 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!
DimensionalPunk
07 July 2008, 09:33 PM
I have the same question, I only want one side of an objects faces to collide with particles. Is this possible?

drGonzo
08 August 2008, 09:28 AM
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;

}

DimensionalPunk
08 August 2008, 09:18 PM
That's a great idea, thank you.

Aikiman
08 August 2008, 02:03 AM
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;

}

nice lateral thinking:thumbsup:

drGonzo
08 August 2008, 08:32 AM
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>>)
{
particleShape1.velocity = particleShape1.collisionIncomingVelocity;
particleShape1.traceDepthPP = 0;
}
else
particleShape1.traceDepthPP = 10;

}

Aikiman
08 August 2008, 07:02 AM
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?

drGonzo
08 August 2008, 08:03 AM
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.

Aikiman
08 August 2008, 09:55 AM
Ahh thankyou

DimensionalPunk
09 September 2008, 01:21 AM
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:

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

Aikiman
09 September 2008, 02:04 AM
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:

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

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

DimensionalPunk
09 September 2008, 10:55 PM
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.

Aikiman
09 September 2008, 12:00 AM
Maybe you're not using ramp1 as your texture.

DimensionalPunk
09 September 2008, 01:26 AM
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.

Aikiman
09 September 2008, 01:36 AM
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.

DimensionalPunk
09 September 2008, 02:11 AM
But how did you assign black to one side and white to the other?

Aikiman
09 September 2008, 07:33 AM
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.

CGTalk Moderation
09 September 2008, 07:33 AM
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.

1