Change ColorAttribute of Object based on Particle Collision?

   2062   10   0
User Avatar
Member
8 posts
Joined: 9月 2021
Offline
Hey there,

I have a simple setup where I generate a bunch of particles and let them drop on some spheres. I would like to achieve to change the Color of the Spheres based on hit by a particle.

With hitprim I was abled to change the color of primitives of the spheres but I would like to check based on the selected primitiv to select the whole Object.

Also I would like once the color changed from e.g. Black to Red to keep the color even after the particle passed through and left the object. And on top of that, if possible to add some time delay. So once the particle hit the object it takes like 20-30 Frames till the spheres to fade into that new color (but not sure if that is possible)...

Any idea how to achieve that or is there a different way. I tried with attribute Transfer but couldn't get it to work. Any help would be much appreciated.

Attachments:
Particle_hit_detection_changecolor_01.hip (571.3 KB)
qpjykwn8oef81.png (1.0 MB)

User Avatar
Member
136 posts
Joined: 3月 2016
Offline
Hello - Here is a quick vex solution also using a sop solver in the pop for the intial setup. Pretty sure there will be a simpler node setup up but im not sure how to do that.

Attachments:
Particle_hit_detection_changecolor_01.hiplc (608.7 KB)

Love Houdini
User Avatar
Member
8 posts
Joined: 9月 2021
Offline
Thanks Hatchery. This is exactly how I need it. Im not that much into VEX but I will dig through that code to understand it. Thank you so much!
User Avatar
Member
136 posts
Joined: 3月 2016
Offline
TBH it could probably be done more efficantly as it gets a bit slow having to loop over all the primatives, but quite like these little puzzels every so often to practice :-)
Love Houdini
User Avatar
Member
8 posts
Joined: 9月 2021
Offline
Yeah is really cool, I need to get into this. I'm currently trying to figure out if there is a way to not stick the particles to the surface of the spheres and just let them just pass through the geo. I guess it has something to do with the @stopped right? Is this setup possible without it?
User Avatar
Member
136 posts
Joined: 3月 2016
Offline
Yes, see _Alt file - you can change i@stopped to i@whatever but just need to update the name in the other wrangles and attribute delete node. Also the only problem with this is as the point passes through it stops being close enough to colour the sphere, if you wanted to maintain the colour then TBH its probably going to need to be redone done in a solver.

Or a quick and dirty meathod might be just to do a seperate copy of the pop net and use the point from that? Really depends what you need to happen and look like (also example attached)
Edited by Hatchery - 2022年2月5日 07:43:29

Attachments:
Particle_hit_detection_changecolor_Alt.hiplc (608.0 KB)
Particle_hit_detection_changecolor_01.hiplc (650.9 KB)

Love Houdini
User Avatar
Member
8 posts
Joined: 9月 2021
Offline
Yeah so @stopped is just like any variable just that its understood by Houdini as freezing the particles? But yeah probably gonna go with the 2nd Method. It's also what I though about. Thanks for taking the time to look at this. Helps me a lot.
User Avatar
Member
136 posts
Joined: 3月 2016
Offline
This is handy for a full list of built in attributes: https://mrkunz.com/blog/08_22_2018_VEX_Wrangle_Cheat_Sheet.html [mrkunz.com]
Love Houdini
User Avatar
Member
8 posts
Joined: 9月 2021
Offline
Thanks for the cheat sheet. I have an other question if you don't mind. You said that there might be a way to redo this in a solver. So do you mean by not using Particles for this at all? Cause I still can't get exactly the behavior I want. I would rather have that the particles are able to pass through the object and "infect" multiple spheres on its way down. I mean without using the stopped attribute is there a way to tell Houdini once the Object got hit to start the "timer" with the fade to red and stop at Red=1 ?
User Avatar
Member
136 posts
Joined: 3月 2016
Offline
Here you go - much simpler.
Basic pop emitter and then a solver to work out if the particle point is within the radius of the sphere and colour it.
Also way faster based on sticking with a simple sphere and no need to loop over all those prims.
Image Not Found

Attachments:
Rebuilt.hiplc (579.5 KB)

Love Houdini
User Avatar
Member
8 posts
Joined: 9月 2021
Offline
Wow nice yeah that seems much better. I never wanted it to stick, I think before I uploaded the scene I forgot to change it back. But I learned a lot from the other setup. Thanks you so much again. This is perfect! THANKS!
  • Quick Links