does setFluidAttr need a scriptJob?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2009   #1
does setFluidAttr need a scriptJob?

I am setting the fluid velocity in x, y, and z. When I execute the script, it changes the velocities for that frame, but then goes back to evaluating normally. When I replay the sim, my velocity values do nothing until I execute the script again. I even tried to use the -ad flag, but still the same.

I would like to add to the velocities already being simulated, hopefully injecting my own values into the mix.


cheers
Pixlmonky
 
Old 02 February 2009   #2
Sounds like you need to run a loop or condition for example if(frame<100) then setFluidAttr. If you use the -ad flag it just adds to the existing velocity but still will only calculate once unless you throw the if statement in.
__________________
Vimeo
 
Old 02 February 2009   #3
I have it in a for loop, within a for loop, within a for loop.

So if I put it in a condition, then it will continue to evaluate? I will try.


Edit>>>>>
I put the setFluidAttr in a condition....
float $time = `currentTime -q`;
if ($time > 1){

still the same results.

Last edited by Pixlmonky : 02 February 2009 at 03:05 AM.
 
Old 02 February 2009   #4
Its pretty hard to see what you are doing without the code to be honest.
__________________
Vimeo
 
Old 02 February 2009   #5
The code.....


float $resX = `getAttr fluidShape1.resolutionW`;
float $resY = `getAttr fluidShape1.resolutionH`;
float $resZ = `getAttr fluidShape1.resolutionD`;
float $fMult = `getAttr fluid1.fluidMult`;

int $row, $column, $depth;


for ($row = 0; $row < $resX; $row++){
for ($column = 0; $column < $resY; $column++){
for ($depth = 0; $depth < $resZ; $depth++){

float $time = `currentTime -q`;

//float $gTemp[] = `getFluidAttr -at "temperature" -xi $row -yi $depth -zi $column fluid1`;
float $gVelX[] = `getFluidAttr -at "velocity" -x -xi $row -yi $depth -zi $column fluid1`;
float $gVelY[] = `getFluidAttr -at "velocity" -y -xi $row -yi $depth -zi $column fluid1`;
float $gVelZ[] = `getFluidAttr -at "velocity" -z -xi $row -yi $depth -zi $column fluid1`;

float $velX = $gVelX[$depth];
float $velY = $gVelY[$depth];
float $velZ = $gVelZ[$depth];

float $velX = $velX * $fMult;
float $minValueX = $velX + ($velX/2);
float $maxValueX = $velX - ($velX/2);
float $nVelX = (noise( $velX )) * ($maxValueX-$minValueX) + $minValueX;

float $velY = $velY * $fMult;
float $minValueY = $velY + ($velY/2);
float $maxValueY = $velY - ($velY/2);
float $nVelY = (noise( $velY )) * ($maxValueY-$minValueY) + $minValueY;

float $velZ = $velZ * $fMult;
float $minValueZ = $velZ + ($velZ/2);
float $maxValueZ = $velZ - ($velZ/2);
float $nVelZ = (noise( $velZ )) * ($maxValueZ-$minValueZ) + $minValueZ;

if ($time > 1){

setFluidAttr -at "velocity" -ad -x -xi $row -yi $depth -zi $column -fv $nVelX fluid1;
setFluidAttr -at "velocity" -ad -y -xi $row -yi $depth -zi $column -fv $nVelY fluid1;
setFluidAttr -at "velocity" -ad -z -xi $row -yi $depth -zi $column -fv $nVelZ fluid1;
}
}
}
}
 
Old 02 February 2009   #6
Perhaps your expression node needs Always Evaluate set to 1. Are you on a Mac? Ive found whenever I alter some code -ae always goes back to zero and I have to copy and paste the code into a new expression node for it to work again.

Ive never had a need to use a script job to setFluidAttrs
__________________
Vimeo

Last edited by Aikiman : 02 February 2009 at 03:39 AM.
 
Old 02 February 2009   #7
on a PC.

Just to clarify... I am trying to get the velocities in x,y, and z. multiply that value by a variable. Then add noise to it. Then add it back into the velocity.



cheers
Pixlmonky
 
Old 02 February 2009   #8
I tested your code and it does seem to be evaluating every frame the only problem is its only doing the bottom voxels -yi 0 and nothing else.
__________________
Vimeo
 
Old 02 February 2009   #9
Wierd that it works for you. I play it thru and it does nothing after that frame that I executed it. Also not sure why it is only happening on the bottom.

I restarted Maya and still, only works on that frame, until I play it. Then it has no effect. If you rewind, does it still evaluate?


cheers
pixlmonky

Last edited by Pixlmonky : 02 February 2009 at 04:29 AM.
 
Old 02 February 2009   #10
I just noticed something in your code though, you have your $column and $depth in the wrong indices.
Also I think where the main problem is when I go to print $nVelX, $nVelZ, $nVelY I get zeros so I think it has to do with this block of code somehow.

So having a another look try correcting your code as follows...

float $velX = $gVelX[0];
float $velY = $gVelY[0];
float $velZ = $gVelZ[0];

This would explain why I was only getting values on the bottom row of the fluid because using an increment value meant that it was returning a bunch of zeros except on the first pass whereas there should be no incrementer in the $gVelX array just $gVelX[0].

Hope that works for you.
__________________
Vimeo

Last edited by Aikiman : 02 February 2009 at 06:45 AM.
 
Old 02 February 2009   #11
I see where it is breaking in the Y. You are right, it's in that statement. not sure why it works for x and z. I think it needs to be made with the [$depth]. The variable needs to be set differently for each voxel. A [0] would mean it only samples the first voxel. I think.
 
Old 02 February 2009   #12
No..

float $gVelX[] = `getFluidAttr -at "velocity" -x -xi $row -yi $depth -zi $column fluid1`;

returns all the x values in the first array indice [0]

From the way you have set it up you are only asking maya to return the velocity in the first array indice because you have three separate arrays for each of the axis. Therefore when the loop runs through the second time it is still the first indice that is used as the last one is overwritten, so all you need is $gVelX[0];

If you use an incrementer and have $gVelX[1]; in there it returns zero values.
__________________
Vimeo
 
Old 02 February 2009   #13
Having a hard time thinking that one thru. This is the first time I have worked with arrays within arrays.


EDIT>>>
I think I get it now. You can use [0] because the nested array is marching across the voxels in x,y, and z. So [0] is the next voxel in the array each time it progresses. Is that a correct assumption?

I was only using the 3 axis because the setFluidAttr only seemed to work if I used the -x, -y, -z flags. Is that needed when getting the velocities? Can I just get the velocities at each voxel in one variable?

I am printing the the values and it is taking so long. Is there a way to print just the highest and lowest value?

Last edited by Pixlmonky : 02 February 2009 at 11:25 PM.
 
Old 02 February 2009   #14
Yeah thats right, all the x values fall into the [0] index one after the other and again in the next pass through the loop. Therefore nothing is kept in [1] or [2] which is why it was only working on the first pass.

Quote: I am printing the the values and it is taking so long. Is there a way to print just the highest and lowest value?

Well you could just query the value like

if ( $gVelX[0] < 0.05 || $gVelX[0]>2.0)
print $gVelX[0];

Im not aware of any function that may do that for you.
__________________
Vimeo
 
Old 02 February 2009   #15
Cool, Thanks. I am in the process of rethinking this.

I think that trying to print the values that way will still take a long time since it still has to parse thru all the arrays. Gggrrrr.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:53 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.