wuhao1117
Hi everyone, I am recently developing a plugin that can add physically accurate foam effects to Maya fluid. Right now I've finished how the bubbles interact with each other and only need velocity field to drive some of the forces.

After searching Maya API documentation and googling couple of forums, I still cannot figure out what kind of attribute I should use as my input attribute to the bubble simulation node. Also I found that fluidAttributeToArray node in SOuP is potentially useful but I don't know how to connect it with the fluidShape node.

I think I need either of the two questions to be answered in order to proceed.

1. If I connect the fieldData->fieldDataVelocity from fluidShape output attribute to my bubble simulation node, what should I do to create the input attribute? I think it should be one of of the derived classes of MFnAttribute right? But I cannot think of which one to use.

2. What pairs of attributes should I connect between fluidShape node and fluidAttributeToArray node? I assume if I can connect them right, I would be able to get velocity from the velocity output attribute and maybe connect it with a MFnVectorArray (not sure).

Greatly appreciated to any suggestions! Thanks a lot!

Reply 0 0
pshipkov
There are example scenes that show how to connect the fluidAttributeToArray node. Basically fluid.outMesh -> fluidAttributeToArray.inFluidMesh.
Then turn-on any of the channels you are interested in and on the output (all these out*PV attributes) you will get the data.
This basically answers and your second questions.

About your first question - what type of node you are making ? Dynamic field, or something else. If you go for dynamic field you can check the devkit examples how you can read data from within your node that belongs to the objects your field is attaching to (influencing, like particle positions, voxel velocities, etc). It is very straightforward and you won't need fluidAttributeToArray if you go this route.
Reply 0 0
wuhao1117
Sorry I am not sure what devkit examples I should refer to. I read all 3 examples related to MFnFluid Class reference, i.e. fluidInfoCmd.cpp, simpleFluidEmitter.cpp, and simpleFluidEmitter.h. But none of them seems to help.

In fluidInfoCmd.cpp, there is no node created, just a custom command and in the last two, no attribute is created and compute function is basically empty because the custom emitter is called by some internal mechnism. What I need is an attribute that can accept velocity field as input. I don't think I can find a suitable candidate from all the MFnAttribute function sets.

Could you enlighten me on the straightforward way you mentioned? I do use a dynamic field.

Thx!
Reply 0 0
pshipkov
there are few dynamic field examples - that's what you need.
Reply 0 0
wuhao1117
I think you might misunderstand me. By dynamic field, I actually mean dynamic grid in Maya fluid simulation, not a field that may apply any kind of forces to particles.
I checked dynExprField.cpp  and torusField.cpp , they do not seem to have anything to do with my case...Sorry if I miss anything.

Maybe I should explain more what I want to do with my bubble simulation node. It's basically a node that takes in velocity Maya fluid simulation and positions from bubble emitters (other nodes I create to emit bubbles), and does some internal processing to update bubble positions and outputs to an instancer along with a sphere.

Of course to get physically right simulation result, I should go for dynamic grid in Maya fluid simulator. But the problem is, I don't know how I should connect fluidShape and my bubbleSim node. To do this, I need to firstly figure out what is the type of input attribute that accepts the fluid velocities stored in grid cells.
Reply 0 0
pshipkov
You missed my point.
You asked how to access voxel velocity data.
I answered that you can take a look at dynamic field examples to see how it is done.
For dynamic field to apply some forces or other properties to dynamic objects it has first to read their parameters like position, velocity, mass, etc.
You can use the same technique to do it for your case.
Reply 0 0
wuhao1117
That solved my problem! Thanks for help!
Reply 0 0
Reply