View Full Version : Particle stick on surface.

 dim1984kimo10-28-2009, 06:13 AMWhat should I do? I wanna make particle stick on surface, and that surface are moving. I knew how to do in houdini, but in maya I have no idea. Thanks*100000000000000.
Aikiman
10-28-2009, 06:25 AM
If you are using nParticles and nCloth you have the sticky attribute where setting a value of 1 on both surfaces will give you complete adhesion.

If you are using standard particles you can make collide, obtain the collision UVs then set the goal UVs the same value.

StefanAlbertz
10-28-2009, 09:03 AM
Could you explain the second technique (standard particles) a bit more? no need for complete code, but just the main mel commands for the expression would be great :)

stefan

TheRispo
10-28-2009, 03:46 PM
Could you explain the second technique (standard particles) a bit more? no need for complete code, but just the main mel commands for the expression would be great :)

stefan

with standard particles I usually do something like this:
I make the target object a goal for the particles, and make the particles collide with that object.. then I add "goalU", "goalV", "collisionU" and "collisionV" to the particle shape... Next, I set the goalPP of the particles to be 0 at creation and in a runtime expression I check if the particles are colliding with the object... if they are, then I set te goalPP to be 1, and the goalU to be the value of collisionU, same with goalV..
Sometimes it happens that the particles appear to be sliding or flickering in the surface instad of just sticking there.. this is because they are still colliding with the surface and thus changing its goal U and V values upon each collision, to get around this you should set "traceDepthPP" to be 0 so they won't collide with the surface anymore, at the end my expression is this:

//creation
particleShape1.goalPP =0;
//runtime
if (particleShape1.collisionU > -1){
particleShape1.goalPP =1;
particleShape1.goalU = particleShape1.collisionU;
particleShape1.goalV = particleShape1.collisionV;
particleShape1.traceDepthPP=0;
}

hope that helps

StefanAlbertz
10-28-2009, 04:34 PM
helps perfectly - thank you very much! if i understand this correctly, i also could then, after the particle stick, query the speed of the surface point and if itīs high enough, let the particle drop again, re-activating the traceDepthPP to make them query collisions again. Like drops shaken from salad or mud shaken from a shoe.

thanks again !

TheRispo
10-28-2009, 06:18 PM
yeah! .. you could query the particle's velocity and when its high enough detach it from the surface setting the goalPP to 0 and set traceDepthPP to a value bigger than 0 to make them collide again... Be aware, however, that if you do this, when the particles fly off and collide with another object, they will not stick to that surface, and instead will fly off to the original goal assigned... There are ways to make it work correctly.. but involve a bit more code

Aikiman
10-28-2009, 07:35 PM
In the case of multiple goal objects you can just use something like...

setAttr "particleShape1.goalWeight[0]" 1;
setAttr "particleShape1.goalWeight[1]" 0;

one thing to be aware of is that at any one time the particleShape1.goalWeight[n] needs to be one for any goals to work even when setting the goalPP to zero in creation because this is a multiplier.

andymoorer
10-28-2009, 08:38 PM
I have actually been looking at the same situation - I'm coming from xsi/ICE and needing to coat a polygonal surface with nParticles.

Do the goalU and goalV attributes work reliably with polygonal surfaces? Twiki has this entry where they suggest that you:

- emit particles from surface
- check emitter is in surface mode (often defaults back to omni), check 'need parent uvs'
- add general particle attributes goalU goalV parentU parentV goalPP
- set goal weight to 1
- set creation expression goalU = parentU; goalV = parentV;

Cool enough... and it works (though they left out that you need to define the goalPP on creation). But I also see that during the process maya reported an unspecified error after setting the goal to the same object I'm emitting from, and I have also had the goal seemingly inactive when I save and reload a scene with this setup.

I'd really like to use goals so that I can weight them against other forces. Any ideas or suggestions?

Aikiman
10-28-2009, 10:38 PM
I have actually been looking at the same situation - I'm coming from xsi/ICE and needing to coat a polygonal surface with nParticles.

Do the goalU and goalV attributes work reliably with polygonal surfaces? Twiki has this entry where they suggest that you:

- emit particles from surface
- check emitter is in surface mode (often defaults back to omni), check 'need parent uvs'
- add general particle attributes goalU goalV parentU parentV goalPP
- set goal weight to 1
- set creation expression goalU = parentU; goalV = parentV;

Cool enough... and it works (though they left out that you need to define the goalPP on creation). But I also see that during the process maya reported an unspecified error after setting the goal to the same object I'm emitting from, and I have also had the goal seemingly inactive when I save and reload a scene with this setup.

I'd really like to use goals so that I can weight them against other forces. Any ideas or suggestions?

Have you tried the stickiness attribute? This could make using goals obselete for nParticles.

andymoorer
10-29-2009, 01:57 AM
Haven't tried it yet... the reason I was going for goals is that I am playing forces and the goal-based "sticking" off of each other, forces trying to pull particles off while goal tries to get 'em back. :)

Aikiman
10-29-2009, 02:20 AM
Haven't tried it yet... the reason I was going for goals is that I am playing forces and the goal-based "sticking" off of each other, forces trying to pull particles off while goal tries to get 'em back. :)

I dont get that error, although I am using traditional particles. I also dont think that it makes any difference whether you use Nurbs or Poly these days.

StefanAlbertz
10-29-2009, 12:26 PM
...I also dont think that it makes any difference whether you use Nurbs or Poly these days...

Right, on polygon objects be sure to have proper UVs (no overlapping).

Edit: as you mentioned nParticles. Did you ever have problems on caching them with all custom attributes? I run into problem nearly every time when i try to cache nparticles while standard particles work without problems. One things i already nailed down is, that the cache path+cache file name mustnīt exceed 128 letters - and that was often the case in our filestructure.

StefanAlbertz
10-29-2009, 06:53 PM
@Rispo

I just played with the particle goal-and-throw-away. works flawless

// Runtime Expression

// Collide and stick
if (collisionU > -1){
goalPP =1;
goalU = collisionU;
goalV = collisionV;
traceDepthPP=0;
stickTimePP += 1;
}

// If already stuck, raise counter
if (stickTimePP > 0){
stickTimePP += 1;
}

// If particle velocity is fast enough, release
// the particle from the object
if ((mag(velocity) > 6)&&(stickTimePP > 10)){
goalPP = 0;
traceDepthPP = 3;
stickTimePP = 0;
}

I added stickTimePP for not throwing particles away at the same moment when they hit the surface, but make them stick at least 10 frames. Works quite nice. Next thing i add it some "release", so the they donīt fly away with the momentum of the objects movement, but a little more .. slimey.

andymoorer
10-30-2009, 09:24 PM
Yeah it works, looks like the problem was an error in the script I wrote to set up the system, I'm introducing a cycle somewhere - when I put my system together by hand the goal based approach works fine.

Thanks gang! Time to fine-tooth thru this script... :D

CGTalk Moderation
10-30-2009, 09:24 PM
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