Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2012
    Posts
    27

    Question Particle color change upon interaction

    I am trying to change the color of a particle when it comes in contact with an colliding object. Iv'e tried using the particle event editor, but that creates a new particle. Can anyone tell me how to achieve this using only one particle.

    say suppose the initial particle color is red, it should become blue when it comes in contact with the colliding plain and should remain blue(and should not change color while it is rolling down) until it touches another object.

    I tried changing the particle name to EVENT and wrote a script so that the particle changes color as the event changes. But the thing is, when the particle rolls down each contact with the plain is considered as an event and the color keeps changing.

    Could someone help me out.
    Thanks.

  2. #2
    Join Date
    Feb 2005
    Location
    /..
    Posts
    2,587
    This explains better than i could
    http://wiki.bk.tudelft.nl/toi-pedia/...le_Expressions

    I had to move then ramp pegs to the bottom to see a change when testing, but I think that's scene dependent.
    There is an exception to every rule, apart from this one.

  3. #3
    Join Date
    Oct 2012
    Posts
    27
    Thanks FAUX. Seems like your the one helping out with all my doubts.

    I tried out the expression in the script. But like I said before- the particle should not change color while it is rolling down. It should only change color once for every colliding object.

    I have attached an image. Please let me know if it is possible to do something about it.
    Click image for larger version. 

Name:	untitled.JPG 
Views:	294 
Size:	291.2 KB 
ID:	73268
    Thanks a bunch.

  4. #4
    Join Date
    Feb 2005
    Location
    /..
    Posts
    2,587
    Ahh I didn't see that you wanted to hold the colour, sorry.

    How about adding a collisionGeometryIndex attribute to the particle shape node?
    Go to the Add Dynamic Attribute rollout and click General, then swap the tab at the top over to Particle. In the list you should see collisionGeometryIndex, select it and click OK. Add in a per particle color attribute as per the link so you have a rgbPP.
    After that create a Runtime Expression on the collisionGeometryIndex with something like the following:
    Code:
    if (collisionGeometryIndex == 0)
    	rgbPP = <<1,0,0>>;
    else if (collisionGeometryIndex == 1)
    	rgbPP = <<0,1,0>>;
    Where == 0 refers to the first geo hit and 1 the second and so on. The <<vectors>> refer to the colours, <<r,g,b>>.

    The particles might start off black as they have no creation expression, more info here:
    http://download.autodesk.com/global/...collisions.htm

    There is an exception to every rule, apart from this one.

  5. #5
    Join Date
    Jul 2003
    Location
    N/W uk
    Posts
    211
    Don't forget that: particles can be deleted and replaced on any frame.
    ie: the blue particle "gets to" red particle position and is deleted, but re-spawns a different coloured sphere
    with a colour ramp to blend if needed and it can carry on its own pathway dynamically.
    Just another way of playing around in Maya, I'm sure there are more too.

  6. #6
    Join Date
    Oct 2012
    Posts
    27
    thanks for the reply guys.

    Faux, this is exactly what I wanted. thanks a lot.

    Sorry for the late reply. My internet was down.

    Thanks again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •