PDA

View Full Version : Emitter rate based on Velocity??


hkspowers
12-17-2008, 07:22 PM
I desperately need to find an emitters velocity. I do not mean the particles but the emitter itself. I wish to base my emitter rate on the velocity of that emitter, so when it is still it emits particles and when it moves it does not emit particles. Can anyone help me with this script? The sooner the better.

Thanks in advance,
James

Derek Wolfe
12-17-2008, 08:03 PM
Sounds cool. What have you tried so far?

hto
12-17-2008, 08:21 PM
hello man..

I'm not sure if this is what do you want, but you could parent the emitter to an object (in case you have in your scene) or create an sphere. make that obj a passive rigid body, so you can animate the obj. and you can create an expression like this.


vector $vel = `rigidBody -q -velocity rigidBody1`;
if ($vel == 0 )
{
emitter1.rate = 200;
}
else
{
emitter1.rate = 0;
}

hope it helps.

hto

hkspowers
12-18-2008, 06:34 PM
I tried to do this in a quick mock up scene, and it did not seem to work. It just emitted like a normal emitter with a constant rate. I will have another look at it over the weekend. Thanks for the help, I am sure it works I am prob just experiencing user error!:beer:

hto
12-18-2008, 07:59 PM
I did try again.. and probably i missed something.

when you create the object, first make it active rigid body, create a keyframe. then if you want to move that object again to a different position, you wont be able to. then you have to change from active to passive, and keep doing you animation...

why first active and then passive, not sure...

Try in that way, and I think will work.

cheers.

hto

Derek Wolfe
12-18-2008, 11:24 PM
Or use a particle, and get it's worldVelocity.

Wick3dParticle
12-19-2008, 06:25 PM
I guess rather than trying to figure out different ways to gather velocity data, we should first figure out how you intend on driving the emitters. Then after thats established, find the best way to gather data from there.

~Ilan

YourDaftPunk
12-19-2008, 07:07 PM
Add one attribute to your emitter, make it a vector and call it OldPos. Then, use this expression:

$emissionRate = 1000;

$dx = emitter1.translateX - emitter1.OldPosX;
$dy = emitter1.translateY - emitter1.OldPosY;
$dz = emitter1.translateZ - emitter1.OldPosZ;
$vel = mag(<<$dx, $dy, $dz>>);

emitter1.rate = $vel * $emissionRate;

emitter1.OldPosX = emitter1.translateX;
emitter1.OldPosY = emitter1.translateY;
emitter1.OldPosZ = emitter1.translateZ;

Wick3dParticle
12-19-2008, 07:35 PM
Add one attribute to your emitter, make it a vector and call it OldPos. Then, use this expression:

$emissionRate = 1000;

$dx = emitter1.translateX - emitter1.OldPosX;
$dy = emitter1.translateY - emitter1.OldPosY;
$dz = emitter1.translateZ - emitter1.OldPosZ;
$vel = mag(<<$dx, $dy, $dz>>);

emitter1.rate = $vel * $emissionRate;

emitter1.OldPosX = emitter1.translateX;
emitter1.OldPosY = emitter1.translateY;
emitter1.OldPosZ = emitter1.translateZ;







If you do use this approach, then in order to get it to work the way you want run this expression instead:



$dx = emitter1.translateX - emitter1.OldPosX;
$dy = emitter1.translateY - emitter1.OldPosY;
$dz = emitter1.translateZ - emitter1.OldPosZ;
$vel = mag(<<$dx, $dy, $dz>>);

if ($vel != 0){
emitter1.rate = 0;

}
else {
emitter1.rate = 1000;

}

emitter1.OldPosX = emitter1.translateX;
emitter1.OldPosY = emitter1.translateY;
emitter1.OldPosZ = emitter1.translateZ;



~Ilan

hkspowers
12-19-2008, 08:35 PM
I have the emitters parented to objects which are animated. I found another way to do this not based off of velocity, but thanks everyone for your replies. I will test all of the above mentioned scripts and see how they work for me. :thumbsup:

James

CGTalk Moderation
12-19-2008, 08:35 PM
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.