View Full Version : WindTunnel script deconstruction HELP

10 October 2005, 10:14 PM

I'm doing a dvd with some complex fluids expressions. Having a very basic understanding of MEL right now, cannot fullly understand the teachings of the lessons.

Trying to get some pratice on the examples that ship with maya6.5 via Fluid Effects>Get Fluid Examples>

Was hoping someone could help me with the Q & A's.... expression reads:
float $vel = windTunnelShape.windSpeed;
int $tracers = windTunnelShape.tracers;
int $yres = windTunnelShape.resolutionH;
float $density = 3.0;
setFluidAttr -at velocity -xi 0 -vv $vel 0 0 windTunnelShape;
int $i;
for($i = 0; $i < $tracers; $i++ ){
int $yIndex = (float)$yres *(((float)$i + 0.5)/(float)$tracers);
setFluidAttr -at density -xi 0 -yi $yIndex -fv $density windTunnelShape;
The "resolutionH" is defined as "Resolution of the grid - height". Besides the varialbe $yres, can I control the "resolutionH" buy going into the attribute editor and changing the value in the "Resoluiton Y" field? Is the "Resolution Y" field defined as the "resolutionH"?

Much Thanks

10 October 2005, 06:57 PM
Yes, it's a bit confusing and also a bit inconsistent imo to name the resolution of the fluid as length, depth, and height, when you want to make it fit into a coordinate system.

But, yes, the resolutionH is the resolution attribute of the fluid in the y-direction. This attribute connects into the expression directly through the line int $yres = windTunnelShape.resolutionH; so changing the resolution attribute of the fluid in the attribute editor or channel box will feed the new value into the expression immediately and change its output. That's the beauty of expressions - they combine the power and stability of connecting attributes in the dependency graph with the power and versatility of mel.

10 October 2005, 07:18 PM

Thanks for responding:thumbsup: ,now that I've got that cleared up.....onward.

setFluidAttr -at velocity -xi 0 -vv $vel 0 0 windTunnelShape;
int $i;

velocity -xi 0 // set the velocity in the X index to a value of 0.

I don't understand where the "X index" is located via 2d/3d container(s).
Is it the voxels only in the X direction or just the first row of voxels or something else. What/Where exactly is the X index in regards to the container?

Appreciate any input on this

10 October 2005, 04:36 PM
I have never used this maya feature but I do know about voxels.

The velocity probably doesn't have any relationship with the fluid container. The voxels only describe the information within the container, and the container is a shoebox region of what 3d space to fill with voxels and define boundaries of the simulation.

Since we are talking a velocity, I bet it's in worldspace :)
Check it out and let me know what you find.


11 November 2005, 05:55 PM
The help docs pull the same old info about xIndex.

Don't see any relation to world space :surprised


11 November 2005, 06:53 PM
The x index is the index for the voxel along the local x-(length-) axis of the fluid container. I.e. if you have a 10 x 10 x 10 voxel fluid and look at the container with its z axis pointing away from you, index 0 0 0 is the bottom, leftmost and closest voxel, while index 9 9 9 is the top, rightmost and farthest voxel. the line

setFluidAttr -at velocity -xi 0 -vv $vel 0 0 windTunnelShape;

sets the velocity of all the voxels on the first YZ voxel plane (or the first Y voxel column in the ) to a value of $vel (which in turn is fed from the custom attribute windSpeed) in the fluids local x-direction.

By only supplying the x-index in the command, that value is set for all the voxels in the other axes.

11 November 2005, 10:24 PM

Appreciate your detailed explaination.

Took me a couple mornings to rap this code around my head before it made sense. :D

If I made a container, added some attributes (windspeed, tracers), wrote the epression. Would that be enough? Or do I have to connect some nodes (windspeed, tracers to container) in the connetion editor?

I'll try it and see what the heck happens.....


CGTalk Moderation
11 November 2005, 10:24 PM
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.