PDA

View Full Version : Particle stick on collision?


dangermouse
08-12-2008, 05:54 AM
I'm shooting a bunch of particles at a polygon mesh, killing them on collision, and emitting a new one in the same place into a new particle object. No problem.

I need the new particle in the new particle shape to stay stuck to the animated mesh though. Any ideas on how to do this? I suspect the answer is simple and i'm just missing something...

It does need to be two particle objects, they'll be rendered in 2 passes, with a glow added to the 'stuck' ones.

Thanks guys :)

Aikiman
08-12-2008, 06:44 AM
Somehow you want to use the collision info as the goal info, not at my computer right now so cant have a play.

dangermouse
08-12-2008, 09:27 AM
Hmmmm, after hunting through the particle attributes, there is collisionU and collisionV, which i could use for goalupp and goalvpp BUT

U and V positions of the NURBS surface where a particle collided in the current frame. For polygonal surfaces, the values are always 0. The values are reset to -1 at the start of each frame. Values change only in frames where collision occurs. These are read-only attributes.

... And I'm using a polygon mesh.

Any idea of any other way or workaround?

Aikiman
08-12-2008, 10:17 AM
Arr I think it still works with a poly plane the problem is that you have to get the collision value of particle1Shape and use that as particle2Shape's goal value, thats the theory Im not sure of the mel.

ctp
08-12-2008, 01:41 PM
Yes, it does work on polys, docs are just not updated.

Put this (adjust for your specific particle names) in your runtime expression, and it will do the trick:

if(particleShape1.collisionU != -1) {
float $goalU = particleShape1.collisionU;
float $goalV = particleShape1.collisionV;

emit -object particle2 -pos 0 0 0 -at goalU -fv ($goalU) -at goalV -fv ($goalV);

particleShape1.lifespanPP = 0;
}

So the setup here is, there's an emitter which emits into particle1. Lifespan on partticle1 is set to lifespanPP, so you can kill them via the expression upon collision. It does not update properly is you use the particle collision events editor to set that they die upon collision.

a second particle object, particle2, was created and goaled to the geometry which particle1 collides with.

The expression above, running for particle1, tests for collisions and emits into particle2, using the emit command.

So just make sure to have added the collisionU and collisionV per particle attributes for particle1, and goalU and goalV for particle2.

Aikiman
08-12-2008, 06:17 PM
Thought of using the emit command, but I was still unsure as to how to implement it, here you use -at goalU flags etc. Nice one!

dangermouse
08-13-2008, 10:35 AM
Dude, you rock my world! That worked perfectly!

First, thank you both for letting me know that collionU and V works for poly's despite what the help says, that was my main stumbling block!

But to go above and beyond by giving me the code saving extra hours of me fumbling around? You win my person of the day award ;) I really do appreciate the time you took to do that for me.

Thanks again
Dave

ctp
08-13-2008, 10:39 AM
You're welcome! ;)

CGTalk Moderation
08-13-2008, 10:39 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.