maya ocean velocity


#1

hello,

I’m trying to use the velocity field of a fluid to control the ocean spray particle behaviour.
I made an ocean with a particle creation expression.
I create a 3D fluid container with a static velocity grid.

Now I’m trying this runtime expression (before dynamics?), but it doesn’t seem to work.

expression used:

Creation:

vector $pos = particleShape1.position;
float $px = $pos.x;
float $pz = $pos.z;
float $disp[] = colorAtPoint -u $px -v $pz oceanShader1;
float $py = $disp[0];

if( $disp[0] > oceanPlane1.sprayHeight ){
particleShape1.position=<<$pos.x, $py, $pos.z>>;
particleShape1.lifespanPP = rand(1) + 0.2;
} else {
particleShape1.lifespanPP = 0;
}

Runtime:

vector $pos = particleShape1.position;
float $px = $pos.x;
float $pz = $pos.z;
float $disp1[] = colorAtPoint -u $px -v $pz oceanShader1;
float $disp2[] = colorAtPoint -u $px -v $pz oceanShader2;
float $py1 = $disp1[0];
float $py2 = $disp2[0];
float $oceanVelocity = -($py1-$py2);

int $vox[]=fluidVoxelInfo -objectSpace false -cb -voxel ($pos.x) ($pos.y) ($pos.z) fluidShape1;
if (size($vox)>0){
setFluidAttr -at velocity -xi $vox[0] -yi $vox[1] -zi $vox[2] -vv (0) ($oceanVelocity) (0) fluidShape1;
}

What am I doing wrong?

thanks,

bern


#2

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.