LinchpinZA
04-01-2011, 02:41 PM
Hey guys,
I'm busy with a scene where there are bouncey balls (nparticles) colliding with mutliple cubes in the scene. The effect I'm going for is whenever a particle collides with a cube I want that cube to light up and then fade to its original colour again. So the bouncing particles make the cubes light up whenever they collide.
All I need to achieve this is a collision event to drive a value between 0 and 1 which will be used as a fade between 2 textures. When the value is 0 it displays texture A, when the value is 1 it displays texture B.
So far I have a MEL command running on a collision event with one surface. I'm getting the first collision to adjust the value of a multiplyDivide node from 0 to 1, but it just stays at that value after the first collision. I don't know how to make the mel script fade the value back to 0 after a given number of frames. and then push the value back to 1 on the next collision.
The MEL script for my event so far looks like this..
global proc shader_Switch (string $nParticle1, int $particleId, string $pPlane1)
{setAttr "multiplyDivide1.input1X" 1;}
shader_Switch is my collision event, nParticle1 is my particle object, pPlane 1 is the object the particle shape is colliding with.
So what I have at the moment is the first collision between particle and surface adjusting a value from 0 to 1, and then nothing further happens.
But what I need is that value to change from 0 to 1 and then fade back to 0 on each particle/surface collision.
Would love to know how to do this, the concept seems quite simple and I'm sure it's possible. Any help would be greatly appreciated. :)
Thanks,
Chris.
I'm busy with a scene where there are bouncey balls (nparticles) colliding with mutliple cubes in the scene. The effect I'm going for is whenever a particle collides with a cube I want that cube to light up and then fade to its original colour again. So the bouncing particles make the cubes light up whenever they collide.
All I need to achieve this is a collision event to drive a value between 0 and 1 which will be used as a fade between 2 textures. When the value is 0 it displays texture A, when the value is 1 it displays texture B.
So far I have a MEL command running on a collision event with one surface. I'm getting the first collision to adjust the value of a multiplyDivide node from 0 to 1, but it just stays at that value after the first collision. I don't know how to make the mel script fade the value back to 0 after a given number of frames. and then push the value back to 1 on the next collision.
The MEL script for my event so far looks like this..
global proc shader_Switch (string $nParticle1, int $particleId, string $pPlane1)
{setAttr "multiplyDivide1.input1X" 1;}
shader_Switch is my collision event, nParticle1 is my particle object, pPlane 1 is the object the particle shape is colliding with.
So what I have at the moment is the first collision between particle and surface adjusting a value from 0 to 1, and then nothing further happens.
But what I need is that value to change from 0 to 1 and then fade back to 0 on each particle/surface collision.
Would love to know how to do this, the concept seems quite simple and I'm sure it's possible. Any help would be greatly appreciated. :)
Thanks,
Chris.
