View Full Version : Fluid texture 2D to map for nCloth
I'm trying to map input attract map with output of color of fluid texture 2D with no luck.
Any idea would be apreciated...
Also I tried to "bake" or convert to file texture 2D fluid texture with no luck...
I'm kind of in a tight time frame, so I hope someone can come up with the idea.
I realise I can just render plane with fluid texture as a second solution, but I'd be glad if this could be interactive process. Could this just be a video card problem?
Thanks
Als
|
|
Duncan
10-22-2007, 06:34 PM
The fluidTexture2d does not derive from the base texture class and thus does not work in some contexts... specifically when used as a particle emission texture or a cloth mapping. Thus as mentioned you would need to convert the fluid animation to a sequence of file textures and use those.
It might be possible to script an expression that would work interactively but it would be a bit involved. Basically you can get the output color of a fluid texture 2d by doing a setAttr on the coordUV and a getAttr on the outColor. Or you can get the raw grid values using getFluidAttr. This can then be used to set per Vertex values on the nCloth( instead of using UV maps). The perVertex values are array attributes on the nCloth and need to be set all in one command( with a long string ). On my blog there is an example script that lets you select cloth vertices and set the per vertex values with a slider. You could pick apart this script to see how to set the per vertex attributes.
http://area.autodesk.com/index.php/blogs_duncan/blog_detail/ncloth_vertex_editor_mel_script/
Duncan
The idea is to do this as animation tool, so I would need to use expression.
Direct connection would be nice.
btw
...this is one of many times when I really wanted to do this (connect output of 2D fluid texture), so I hope we might see this feature in the future... ;)
Since this might be complicated expression to write, so could you please give me advice on which one would work faster, since this will be crucial for simulation. I'm aware this is dependend on coding too.
Also I'd like to know if there are some issues between fluids and ncloth, and was wondering if there is anything to be aware of when trying to use fluids as fields for ncloth.
The idea is to make fluid drive the attractivness or rigidness of ncloth, which could have many very cool uses...
I'm also using the blastcode as a tool to design/create the way the ncloth will fall apart.
It works as making image in photoshop of cracks, and then blastcode aplies this to nurbs plane, which creates edges in polygon geometry. This type of tool would really help a lot for ncloth tearing. Alternative way would be to be able to paint polygons, or edges directly on polygon model, or trim curves on polygons, similar to trim tool on nurbs.
I'm certain many would like this type of tool...
Thanks
Als
Duncan
10-26-2007, 12:04 AM
If you are asking which is faster to get values off of the fluid..
getFluidAttr
or
setAttr fluid.coordUV, followed by getAttr fluid.outColor
Then getFluidAttr will be faster, although it won't give you the effect of the ramps and such on the fluid. Baking the fluid to file textures and using them will evaluate by far the fastest, although you have to bake the fluid to a texture.
I've attached a file with a simple expression that sets the input attract of a cloth plane to match the density from a 3d fluid texture. It simulates as you playback.
Here is the expression used:
float $f[] = `getFluidAttr -at "density" fluidTexture2D1`;
int $numVals = size( $f );
string $c = ("setAttr nClothShape1.inputAttractPerVertex -type \"doubleArray\" "+ $numVals);
int $i;
for( $i= 0; $i < $numVals; $i++ ){
$c += (" " + $f[$i]);
}
eval $c;
In order to make the indexing match one needs to have the fluid XY resolution 1 unit larger than the subdivisionsWidthHeight on the polyPlane node. Also on the cloth the inputMeshAttract was set to 1 and the inputAttract mapping to "per vertex". One can do similar things with the other per vertex attributes.
Duncan
LOL! :thumbsup: :bounce:
Thanks!!!
Al
CGTalk Moderation
10-26-2007, 12:50 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.