PDA

View Full Version : Setting velocities for previous particles in runtimes


trancor
04-13-2008, 11:37 PM
Hey, I kinda realize this is a dynamic/mel issue rather than specifically mel. But I was wondering if I can set specific particle velocities from another particle's runtime.

Basically what I'm doing is just a test to see how far I can push the `rot` command and `cross` product command. So, everytime the (particleId % 3) == 0, I want to have the particle -2, -1, and particle 0 for the particleId, change velocities.

For clarity, lets say --
$id=particleId;
$x=$id-2;
$y=$id-1;
$z=$id;

So based off of the placement (pointPosition) of $x and $y, particle $z will find the vector between $x & $z -and - $y & $z and the cross product of those two vectors (being a perpendicular vector) will be taken on as the velocity on $z for the next frame before all of this math processes again.

(Each particle $x, $y, and $z, will go through this math for each of the other 2. basically forming a triangle plane in 3d space spinning around itself)

What I'm looking for is a way of assigning particle -2, particle -1, and particle 0 velocities all on one frame.


So is there some way of doing this --
particleShape1.pt[$x].velocity=$crossProdX;
particleShape1.pt[$y].velocity=$crossProdY;
particleShape1.velocity=$crossProdZ;
but with it working in mel.


I'm not really looking to make any extra per particle array attributes but, even if I had to make another attribute Per Particle on the particle system to maintain the vector arrays to be called on the next frame, sure, but how do I even set that
particleShape1.customVelocity[12]=$x math
particleShape1.customVelocity[13]=$y math
particleShape1.customVelocity[14]=$z math - CurrentFrame


I hope that was clear enough. I'm open to any suggestions if I should go about this another way. I'm just trying to get used to working with particles and runtime exps.

Thanks in advance

greatPumpkin
04-16-2008, 10:27 PM
I know zipp about particles, but what your trying to do sounds kind of neat-? Are you looking for a mel solution vs. an expression driven one? as far as mel goes you can use:

getAttr -time (time1.outTime - 1) particle.pt[$x]

to query a value on the previous frame (the time1 thing might need to be changed or fed to a variable? Haven't used any expressions in awihle- also not sure where worldspace position is stored below .pt? Does that help at all, not 100% sure I understood what you were asking-

trancor
04-19-2008, 04:50 AM
Well, its not that I'm looking for previous frame values for attributes, I'm looking to set velocity on a per particle level to an earlier particle that has already been processed.

Like imagine a big for loop, 0-1000, but every three objects that the for loop runs through, I want the for loop to do a setAttr for the previous objects in the for loop. But the only issue is, for particles, I don't know how to say particleShape1.pt[239].velocity because maya doesn't under stand that, what maya understands is particleShape1.velocity, because when maya throws out particles, it just assume when it says velocity in mel, you're talking about the particle it's currently making. (or am I mistaken, can maya understand pt[239].velocity? am I just writing it wrong?)

so I want maya to go back and change 2 previous particle velocities based on the current particles location.

I made a test, but because I don't know how to assign specific particles velocities, I just did it with 3 particles.

If I were to set up a full particle system in the method I have in the file, everything would be off a frame and would create a huge wave effect, what I'd want is a uniform move, thats why I'd like everything to happen in the current frame, to assign velocities to the per particle velocity array on the particles.

greatPumpkin
04-19-2008, 09:07 AM
looks like a prevPosPP attr might be what your looking for? check out this thread:

http://forums.cgsociety.org/showthread.php?t=54552

trancor
04-20-2008, 07:44 AM
I'm looking to assign not query, so, per particle attributes are like vector arrays, each element is the corisponding particle id. So I don't know if maya can assign vectors to previous elements in the array. Like if Maya is on id 5, if I can assign id 4 and id 3's velocities.

trancor
04-22-2008, 12:00 PM
Well, I got a basic solution to my problem, but it limites my extent of control. I've made userVectorArrays to maintain velocities for each particle until the next frame. I've also change my idea to having the 3 particles move and a 4th to be the center point of those 3, so I can control the 4th with gravity and fields and have the other 3 move based on the 4ths velocity and position.

and using this formula --
$id=542;
print (((ceil($id/4))*4)+4);
// 544
$id=543;
print (((ceil($id/4))*4)+4);
// 544
$id=544;
print (((ceil($id/4))*4)+4);
// 548

I could find the next master particle when I'm on the prior particles to know what array to call from.

CGTalk Moderation
04-22-2008, 12:00 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.