View Full Version : Quick and Dirty Fluid simulation?

 stzaske04-23-2003, 07:33 PMOkay okay, Maya may have fluid simulators and all that tricky stuff, but one, I only have Maya Complete 4.5, and two, I'm interested in a really fast and simple solution. I want to create a poly object, and then simply have its top most surface stay perfectly horizontal. I do not need surface deformations. I'm thinking I can achieve this effect using a cluster, or a sculpt deformer, and maybe a sprinkle of MEL. If anyone has any pointers or ideas, I'm all ears.
sp0rk3d
04-23-2003, 10:15 PM
well that effect seems simple enough and you will need deformers to do it... like clusters for instance you could assign the whole object on to two clusters one for the top surface and the other for the rest of the mesh.... point constrain the top cluster to your control then point and orient canstrain the bottom to your control.... (use groups to offset your transforms) then when you move your control the top will not rotate even if the bottom does...

hope that helps.. :)

04-24-2003, 02:37 PM
Well it appears this is not so quick OR dirty. I've tried 2-1000 ways to do this last night, and now I'm just going to friggin keyframe the whole damned thing by hand. If anyone wants to give this little experiment a try, have at it.

Here is the "test", create a coffee cup, place a solid fluid element within it, then write a procedure to keep the top flat surface of your "fluid" such that it is horizontal at all time. I could not figure it out on day #1.

I was up until 3am this morning trying to get it to work...and had to get up at 5:30 am to go to work.

I attempted what you were suggesting, but ran into a few problems.

1. The top surface, when extremely rotated (anything over say 30%), will pull the edges away from my glass cup. In my example my cup is not round so that even further causes problems
2. I found a solution to that problem, but then my "solution" ran into more and more problems.

1. Took my fluid nurb and applied a cube lattice using 2x2x2
2. Made a cluster out of each corner lattice point on the top edge of my lattice.
3. Now translating those four clusters, only on the Y axis, allowed me to raise or lower my fluid within my cup, without the fluid pulling away from the cup itself.
4. Now I placed a locator on the exact middle of my fluid top surface and parented it to my cup. This would be the height of my fluid.
5. Duplicate that locator and unparent it. Point constrain this second locator to the first. Now this 2nd locator would be my "always horizontal" location.
6. create 4 more locators and parent them to the "always horizontal" locators.
7. Align each of these 4 locators to each of the four corners of my lattice (and where each of the clusters are now located).
8. Point constrain each of the four clusters to these four "always horizontal" locators.

I'd of thought this would work, as the locators DO stay horizontal, and the lattice corners stay point constrained to the horizontal locations. But as you move the cup, and the fluid within it, the fluid warps crazily out of the cup. It seems point constraining a cluster is not a doable thing as the transforms get multipled and all hell breaks loose.

My only "quick solution" is to just hand keyframe the four corners of my lattice. Again, I'd by very interested if someone else could find a solution to this strangeness.

-=STZ=-

ps. Does anyone know of a MEL command to find the world location of an object? I think I might have been able to get this working if I knew of a way to find the Fluid.world_ty location.

AroundTheFur
04-24-2003, 03:27 PM
im not sure this is just an idea but couldnt you do some expressions or set driven key on the lattice you have there, so that the top cluster will rotate in the opposite direction that the other two do, create the illusion that the top isnt rotating at all. just a thought. :buttrock:

Duncan
04-24-2003, 03:50 PM
ps. Does anyone know of a MEL command to find the world location of an object? I think I might have been able to get this working if I knew of a way to find the Fluid.world_ty location.

To get the worldspace location of "Fluid":

float \$location[3] = `xform -q -ws -t Fluid`;

Duncan

alesmav
04-24-2003, 05:07 PM
Is it that you complicated the whole thing as hell or I don't quite understand your problem stzaske...

If I get it right, I think you are trying to create a surface inside a cup that is alwas horizontal even though the cup is rotating. I haven't tried this yet, but I would approach the problem fairly simply:

I see a flat liquid surface inside the cup as a boolean (simple poly plane cut by the walls of the cup). Parent the poly plane to the cup first so that when the cup moves, the plane (and the the new boolean surface) follows. Next step is even more simple. Create a locator and Orient constraint the poly plane (not the Boolean surface) to that locator. Some tweaking of the orient constraint settings may be needed to get the poly plane to orient properly.
Voila! Now you can move the cup, and the Boolean surface will follow... if you rotate the cup, the Boolean surface will update (read: will stay horizontal all the time), cos the poly plane allways has the same orientation as the locator you previously created.

The boolean update speed of course depends on the density of your geometry. If it's very high, put the boolen surface in a layer and hide it as you animate. Unhide when you render.

Hope this is dirty enough and that it solves your problem.
Post if it doesn't. :)

ALES

04-24-2003, 09:45 PM
Alesmav: Yes I was thinking of using booleans as well, but I'm not super familiar with them. Anyway, any time I've tried to use them they leave huge holes near the edges, no matter what I set the tesslation to. Another problem with using booleans for my current need is that instead of a cup, I'm actually animating a transparent perfume bottle, with the liquid being the visible perfume inside the bottle, so its important that I have a solid liquid object, and not just a plane.

I was going to look into booleans today, so I'll give your idea a shot and see how it works. I'll report back around 3am tonight and let you know how it turned out. I think I may try Ducan's World solution first however.

Duncan, to access the world location, in your example, would I use:

location\$[1] = X
location\$[2] = Y
location\$[3] = Z

?? I'd love to solve this using expressions. It makes me feel smart.

-=STZ=-

04-24-2003, 09:56 PM
AroundTheFur:

Hmmm, I like your suggest too, but in its current state, I don't believe the translate attributes ever show any changes, since the clusters and locators are parented, and they never move in relation to their parent.

What screwed up my solution was the fact that if you point constrain a cluster then the translate numbers DO change. It's just something strange about the difference between point constaining and actually moving a locator manually. In Maya it is NOT the same thing. If I move the locator/cluster manually, my effect works, and my fluid stays flat and everything is good. If I point constrain the cluster/locator it ends up in the same place (as my manual move), but the lattice wigs out (explodes). It's just a weird thing (perhaps bug).

Perhaps I'll post pictures tonight so everyone can get a better idea of the interesting problems to this puzzle.

-=STZ=-

Duncan
04-24-2003, 11:15 PM
You may wish to look at the mel doc a bit. The variable \$location I created is an array. Arrays have zero as the base index, so if you wanted to get at the value for X it would be
\$location[0]

The indices 1 and 2 would be y and z respectively.

So in your expression you could say something like
float \$val[3] = `xform -q -ws -t Fluid`;
myObject.ty = \$val[0];

Which would set the translateY of "myObject" to the worldspace translateY of "Fluid".

Also not the "\$" sign goes before the variable. When queried the xform command returns an array of 3 floats. You may wish to read the mel doc on this command for more info.

Duncan

altruizine
04-24-2003, 11:40 PM

I just tried this and it seems to work pretty well.

Create your fluid surface texture. in the transparency map put a blackand white matte image in the shape of your cup opening. Use a projection texture.

Parent that projection to the cup looking straight down.

Smack a plane in the cup. Constrain the location of the plane to the cup but not the rotation...

Voila. Now you can distort your plane all you want (jiggle it, displace it, deform it... all that) and the projection will always cut the plane to the shape of the cup no matter what the angle...

You can also then add a bump map for a miniscus (the rising liquid along the edges of the cup) and have that always be there...

No Mel, no craziness... gets what you're looking for.

Follow?

Hope that helps.

-Jeremy Fernsler

Duncan
04-25-2003, 12:15 AM
Another simple way, if you are using nurbs, is to take a plane, intersect it with the cylinder of your cup(editNurbs->intersectSurfaces) then trim, keeping the inside bit(select plane, trimTool and click on the center of the plane). With construction history the trim will hold as you animate the cup relative to the liquid surface.

Duncan

pyromania
04-25-2003, 03:49 AM
Well I tried using a combination of clusters and set driven keys. Create a planar surface for the liquid surface, then assign clusters, to each side of the surface. Now you have 4 clusters that can strech the surface for your X, Z directon. Then you just use set driven key so that the X ,Z rotation of the cup, stretches the liquid surface to fill in the gaps. It looks pretty good, but because of the clusters, you can't move the cup Grrrr!!!. Maybe I'll try blendshapes.

04-25-2003, 06:28 AM
Originally posted by Duncan
Another simple way, if you are using nurbs, is to take a plane, intersect it with the cylinder of your cup(editNurbs->intersectSurfaces) then trim, keeping the inside bit(select plane, trimTool and click on the center of the plane). With construction history the trim will hold as you animate the cup relative to the liquid surface.

Duncan

Okay, now I'm pissed because Duncan came up with such a EASY solution. THANKS FOR MAKING ME FEEL STUPID! :rolleyes:

Thanks for the suggestion, that worked great. :thumbsup:

-=STZ=-

rabban
05-30-2003, 05:11 AM
I guess this is pretty late and all but cant a ocean shader help out in this as well?

Jozvex
05-30-2003, 11:32 PM
He doesn't have Fluid Effects though, he's only got Maya Complete.

CGTalk Moderation
01-15-2006, 12:00 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.

1