PDA

View Full Version : fluid as an AIR field

 SEVA01-05-2009, 04:45 AMTrying to figure out how to use a fluid as an AIR field, as opposed to a force style field. Here's the difference with a fluid acting as a force style particles will continually accelerate the particle and the reason why you need to reduce particle conserve to a very low value ( zero in most cases ) What I need is some guidance with is having fluid act as an Air Field in which particle moving faster then fluids would in turn slow it down. Any suggestions ? my thought was to try and use fluidVoxelInfo in a particle expression. Be need some help with that Maybe this question should be posed to the Master of fluids "duncan" :-) cheers
Phlok
01-05-2009, 10:47 AM
Hi SEVA,

maybe this thread here could be helpful:

If you have further questions, just ask.

Cheesestraws
01-05-2009, 01:14 PM
Duncan says here (http://forums.cgsociety.org/showpost.php?p=5527808&postcount=338) that at one point he would like to add the ability to use a fluid as an air field and comes up with a way of emulating it within the current capabilities of maya.

Aikiman
01-05-2009, 09:00 PM
Duncan says here (http://forums.cgsociety.org/showpost.php?p=5527808&postcount=338) that at one point he would like to add the ability to use a fluid as an air field and comes up with a way of emulating it within the current capabilities of maya.

Im assuming he just uses the velocity info and applies it directly as particle velocity, Im wondering if he needed to change the vectors at all, or is it a case of just raising the conserve back to 1 and letting the expressions do the rest? Have you tried it out Cheesestraws?

 I just tried it out but my code makes it run really slowly so the method is either too inpractical or my code is not very efficient, any suggestions would help a lot.

vector \$pos = particleShape1.position;
int \$voxels[] = `fluidVoxelInfo -v (\$pos.x) (\$pos.y) (\$pos.z) fluid1`;
if(`fluidVoxelInfo -ib \$voxels[0] \$voxels[1] \$voxels[2] fluid1`) {
float \$vel[] = `getFluidAttr -at "velocity" fluid1`;
vector \$particleVel = <<\$vel[0], \$vel[1], \$vel[2]>>;
particleShape1.velocity = \$particleVel;
}

SEVA
01-06-2009, 12:52 AM
Aikiman,

My code is similiar to yours and had the same results hence my question to the board.
Thinking out loud here but may try using the inputForce of the fluid and incorprate that in the particle expression. Still trying out different ways.
In theory it seems straignt forward via the fluidVoxelInfo and getFluidAttr. Maybe not as straight forwards as one may think.

Aikiman
01-06-2009, 01:28 AM
Aikiman,

My code is similiar to yours and had the same results hence my question to the board.
Thinking out loud here but may try using the inputForce of the fluid and incorprate that in the particle expression. Still trying out different ways.
In theory it seems straignt forward via the fluidVoxelInfo and getFluidAttr. Maybe not as straight forwards as one may think.

my getFluidAttr needs to include which voxels I am getting rather than the whole fluid itself, I think that should work.

vector \$pos = particleShape1.position;
int \$voxels[] = `fluidVoxelInfo -v (\$pos.x) (\$pos.y) (\$pos.z) fluid1`;
if(`fluidVoxelInfo -ib \$voxels[0] \$voxels[1] \$voxels[2] fluid1`) {
float \$vel[] = `getFluidAttr -at "velocity" -xi \$voxels[0] -yi \$voxels[1] -zi \$voxels[2] fluid1`;
vector \$particleVel = <<\$vel[0], \$vel[1], \$vel[2]>>;
particleShape1.velocity = \$particleVel;
}

this works a treat!

Duncan
01-06-2009, 06:46 PM
Your original expression might have been slow because getFluidAttr returns the entire fluid grid into the \$vel[] array when you don't specify a specific voxel!

Duncan

Aikiman
01-06-2009, 08:49 PM
Your original expression might have been slow because getFluidAttr returns the entire fluid grid into the \$vel[] array when you don't specify a specific voxel!

Duncan

Hi Duncan,

thanks for dropping in...yes you are right, thanks to the wonderful F1 help I found that out and promptly added the voxel info in there. Actually I had to reboot Maya after my print command wouldnt stop printing vectors in the script editor!

SEVA
01-07-2009, 12:44 AM
A thank you to Jeremy and duncan for your time and input. I managed to get my code to work and realized the same issue with "getAttr".

cheers

CGTalk Moderation
01-07-2009, 12:44 AM
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.