Jump to content

Particle collision with multiple primitives and changing to 1 colour value upon hit


atron

Recommended Posts

Hi there,

I'm trying to change the colour of a primitive once a particle collides with it….but i don't want to use an attribute transfer because that gives me a gradient of colour on the primitive and i want to change the colour back after it's been hit and have it be a solid colour. 
So hit == green (0,1,0)
not hit == red(1,0,0)
Another problem i'm having is when i don't use an attribute transfer and write it in a python sop(code below) i change all the primitives colours in one go rather than individually where the the particle collides with each primitive.

Not sure how to go about this, but here is the file attached.Any help would be much appreciated.

CODE FOR HIT COUNTER AND PRIMITIVE CHANGE COLOUR 
node = hou.pwd()
geo = node.geometry()
from hou.session import * 

inputs = node.inputs() # bring in city searcher data 

pointcolliders = inputs.geometry().points()


ship = geo.prims()
if hou.frame() == 1: 
hitCount = 0


for p in pointcolliders:

store = p.attribValue(“hittotal”) # get hittotal attribute from the pop solver 
hitCount += store # hitcount += store (to add number of hits to hou.session)
hits = store 


green = (0.0,1.0,0.0)
red = (1.0,0.0,0.0)

#change colour of second input so object

for s in ship:

if hits == 1:
s.setAttribValue('Cd', green) 
else:
s.setAttribValue('Cd', red)

particles hit each prim.hipnc

3.JPG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...