PDA

View Full Version : Fluid along a curve

 spiderman307-31-2008, 02:23 PMHi all, i would like toknow whether there is any possibility to make fluids travel on a curve like curve flow for particles.
AndersEgleus
07-31-2008, 06:54 PM
Well, fluids don't really work like particles in the sense that the density travels. Instead, they use a velocity grid to push the density. The elements of the fluid density can't really be thought of as individual entities like particles can, instead, think of the density as rows upon rows of little boxes which are more or less filled with some content. Depending on the velocity associated with each box, it moves by transfering some (or all) of the content in the box to a nearby box.

Because of this, the only way to actually make fluid content move is to affect the velocity grid somehow.

In your case, it would for instance be possible to create a curve and have particles flow along the curve (which you know how to do). You could then create a uniform field affecting the fluid (by having the fluid selected when you create the field), and have the particles be the source of the field, by selecting the particles and the field and selecting Fields/Use Selected as Source of Field. Make sure the field's maxDistance is a reasonable value and useMaxDistance and applyPerVertex is on. You would then have to add some per particle float attributes to control the field on a per-particle basis, namely uniformField1_directionX, uniformField1_directionY, uniformField1_directionZ, and uniformField1_magnitude, as well as a scalar float uniMult (so you can control the field's magnitude) and in the runtime before dynamics expression add the rows:

vector \$vel = velocity;
float \$mag = mag(\$vel);
\$vel = unit (\$vel); // not really necessary I think
particleShape1.uniformField1_directionX = \$vel.x;
particleShape1.uniformField1_directionY = \$vel.y;
particleShape1.uniformField1_directionZ = \$vel.z;
particleShape1.uniformField1_magnitude = \$mag * uniMult;

You could experiment with bringing the Viscosity and Damp values of the fluid up a bit to make the density follow the curve more closely.

As an alternative to the above technique, you could use the method Fluid Effects/Add/Edit Content/With Curve, but that will only work on static velocity grids.

phildog
08-01-2008, 05:14 AM
yes thats a great solution, and provides you with alot of control.
but you can actually drive the fluid with a curve continuously. I tried capturing the mel command to this (so i can run it as a script continuously not just for initial state) with no luck so i ended up making it myself.
it was fairly easy actually using pointOnCurve and reading the tangent off of it. etc
then driving both density and velocity off the curve .

Well, fluids don't really work like particles in the sense that the density travels. Instead, they use a velocity grid to push the density. The elements of the fluid density can't really be thought of as individual entities like particles can, instead, think of the density as rows upon rows of little boxes which are more or less filled with some content. Depending on the velocity associated with each box, it moves by transfering some (or all) of the content in the box to a nearby box.

Because of this, the only way to actually make fluid content move is to affect the velocity grid somehow.

In your case, it would for instance be possible to create a curve and have particles flow along the curve (which you know how to do). You could then create a uniform field affecting the fluid (by having the fluid selected when you create the field), and have the particles be the source of the field, by selecting the particles and the field and selecting Fields/Use Selected as Source of Field. Make sure the field's maxDistance is a reasonable value and useMaxDistance and applyPerVertex is on. You would then have to add some per particle float attributes to control the field on a per-particle basis, namely uniformField1_directionX, uniformField1_directionY, uniformField1_directionZ, and uniformField1_magnitude, as well as a scalar float uniMult (so you can control the field's magnitude) and in the runtime before dynamics expression add the rows:

vector \$vel = velocity;
float \$mag = mag(\$vel);
\$vel = unit (\$vel); // not really necessary I think
particleShape1.uniformField1_directionX = \$vel.x;
particleShape1.uniformField1_directionY = \$vel.y;
particleShape1.uniformField1_directionZ = \$vel.z;
particleShape1.uniformField1_magnitude = \$mag * uniMult;

You could experiment with bringing the Viscosity and Damp values of the fluid up a bit to make the density follow the curve more closely.

As an alternative to the above technique, you could use the method Fluid Effects/Add/Edit Content/With Curve, but that will only work on static velocity grids.

Aikiman
08-02-2008, 11:01 PM
Hi Phil, can you share the code for that? If not no worries.

spiderman3
08-03-2008, 05:47 AM
This is really cool......thanks a lot for the reply guys

CGTalk Moderation
08-03-2008, 05:47 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.